centos7安裝配置mysqlroute
阿新 • • 發佈:2022-05-09
安裝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