MySQL ROUTER安装部署

MySQL ROUTER安装部署

在前一篇文章,测试安装了MySQL MGR集群,在磁盘文章中通过测试MySQL router实现VIP的功能和读写分离。

总体设计架构如下图

复制代码
[root@mgrouter bin]# adduser mgrrouter
[root@mgrouter bin]# ./mysqlrouter --bootstrap root@192.168.56.104:3309 --directory /opt/mysql_router/mgrrouter/data  --name='gsprouter' --user=mgrrouter --force-password-validation
Please enter MySQL password for root: 
Error: Unable to connect to the metadata server: Error connecting to MySQL server at 192.168.56.104:3309: Access denied for user 'root'@'192.168.56.107' (using password: YES) (1045)
[root@mgrouter bin]# ./mysqlrouter --bootstrap mgrouter@192.168.56.104:3309 --directory /opt/mysql_router/mgrrouter/data  --name='gsprouter' --user=mgrrouter --force-password-validation
Please enter MySQL password for mgrouter: 
Error: Expected MySQL Server '192.168.56.104:3309' to contain the metadata of MySQL InnoDB Cluster, but the schema does not exist.
Checking version of the metadata schema failed with: Error executing MySQL query "SELECT * FROM mysql_innodb_cluster_metadata.schema_version": Unknown database 'mysql_innodb_cluster_metadata' (1049)

See https://dev.mysql.com/doc/mysql-shell/en/deploying-production-innodb-cluster.html for instructions on setting up a MySQL Server to act as an InnoDB Cluster Metadata server

[root@mgrouter bin]# 


#########################
mysql router安装配置


##下载安装

##解压
mv mysql-router-8.0.27-linux-glibc2.12-x86_64 /usr/local/
ln -s mysql-router-8.0.27-linux-glibc2.12-x86_64/ mysql-router

##安装目录:
mkdir -p /opt/mysqlrouter/data
mkdir -p /opt/mysqlrouter/log
mkdir -p /opt/mysqlrouter/run
mkdir -p /opt/mysqlrouter/config

cp /usr/local/mysql-router/share/doc/mysqlrouter/sample_mysqlrouter.conf /opt/mysqlrouter/config/mysqlrouter.conf

##添加环境变量
vi /etc/profile 

export PATH=/usr/local/mysql-router/bin:$PATH

source /etc/profile 

##读写分离配置

vi /opt/mysqlrouter/config/mysqlrouter.conf

chown mysql.mysql /opt/mysqlrouter/config/mysqlrouter.conf
 
[DEFAULT]
logging_folder         = /opt/mysql_router/mgrrouter/log
plugin_folder          = /opt/mysql_router/mgrrouter/lib/mysqlrouter
config_folder          = /opt/mysql_router/mgrrouter/config
runtime_folder         = /opt/mysql_router/mgrrouter/run
data_folder            = /opt/mysql_router/mgrrouter/data

client_connect_timeout = 2
connect_timeout        = 2
read_timeout           = 30
max_connections        = 512

[logger]
level = INFO
timestamp_precision = second
 
[routing:primary]
bind_address = 192.168.56.107
bind_port = 7001
destinations = 192.168.56.104:3309,192.168.56.105:3309,192.168.56.106:3309
routing_strategy = first-available
mode = read-write

[routing:secondary]
bind_address = 192.168.56.107
bind_port = 7002
destinations = 192.168.56.105:3309,192.168.56.106:3309
routing_strategy = round-robin
mode = read-only


##启动 router 
/opt/mysql_router/mgrrouter/bin/mysqlrouter -c /opt/mysql_router/mgrrouter/config/mysqlrouter.conf &


##创建远程测试访问用户
CREATE USER root@'%' IDENTIFIED WITH sha256_password BY 'root';
GRANT REPLICATION SLAVE ON *.* TO root@'%';
GRANT all ON *.* TO root@'%';

FLUSH PRIVILEGES;

###登录测试验证
mysql -h 192.168.56.70 -uroot -proot -P 7002 -e "select @@hostname, @@read_only, @@super_read_only"
相关推荐
刺客-Andy1 天前
Python 第二十节 正则表达式使用详解及注意事项
python·mysql·正则表达式
zhangphil1 天前
Android GPU的RenderThread Texture upload上传Bitmap优化prepareToDraw
android
哈__1 天前
MongoDB 平替新方案:金仓多模数据库驱动电子证照国产化落地
数据库·1024程序员节
微学AI1 天前
国产数据库替代MongoDB的技术实践过程:金仓多模数据库在电子证照系统中的深度应用
数据库·人工智能·1024程序员节
TDengine (老段)1 天前
TDengine 数据函数 ROUND 用户手册
java·大数据·数据库·物联网·时序数据库·tdengine·1024程序员节
TDengine (老段)1 天前
TDengine 数学函数 RAND 用户手册
java·大数据·数据库·物联网·时序数据库·tdengine·涛思数据
柿蒂1 天前
聊聊SliverPersistentHeader优先消费滑动的设计
android·flutter
野犬寒鸦1 天前
从零起步学习MySQL || 第十章:深入了解B+树及B+树的性能优势(结合底层数据结构与数据库设计深度解析)
java·数据库·后端·mysql·1024程序员节
GZ_TOGOGO1 天前
Oracle OCP考试报名常见问题详解
数据库·oracle·ocp认证
睡不醒的猪儿1 天前
nginx日志同步阿里云datahub后写入数据库
数据库·nginx·阿里云