centos7安装配置mysqlroute
安装mysqlrouter
创建目录:
mkdir -p /etc/mysqlrouter
cd /etc/mysqlrouter
下载mysql-router
wget https://cdn.mysql.com/archives/mysql-router/mysql-router-8.0.26-el7-x86_64.tar.gz
tar -zxvf mysql-router-8.0.26-el7-x86_64.tar.gz
mv mysql-router-8.0.26-el7-x86_64 mysql-router
新建配置文件
vi mysqlrouter.conf
[DEFAULT]
logging_folder = /var/log/mysqlrouter
runtime_folder = /var/run/mysqlrouter
config_folder = /etc/mysqlrouter
[logger]
level = INFO
# 从节点负载均衡配置
[routing:balancing]
# 绑定的IP地址
bind_address=127.0.0.1
# 监听的端口
bind_port = 7000
# 连接超时时间
connect_timeout = 3
# 最大连接数
max_connections = 1024
# 后端服务器地址
destinations = 10.252.252.2:3306,10.252.252.3:3306
# 模式:读还是写
mode = read-only
# If no plugin is configured which starts a service, keepalive
# will make sure MySQL Router will not immediately exit. It is
# safe to remove once Router is configured.
[keepalive]
interval = 60
新建系统服务
vi /usr/lib/systemd/system/mysqlrouter.service
[Unit]
Description=MySQL Router
After=network.target
After=syslog.target
[Service]
Type=notify
#User=mysqlrouter
#Group=mysqlrouter
User=root
Group=root
# Start main service
ExecStart=/etc/mysqlrouter/mysql-router/bin/mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
# Sets open_files_limit
LimitNOFILE = 10000
Restart=on-failure
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动
systemctl start mysqlrouter
systemctl enable mysqlrouter