当前准备了4台虚拟机,每台虚拟机都是4核8G,200G硬盘
192.168.10.211 master
192.168.10.212
192.168.10.213
192.168.10.214
先在master上安装mysql-server
然后登录,因为我这里安装好之后是空密码
mysql -u root -p
直接登陆,然后执行以下sql
CREATE USER 'replica'@'%' IDENTIFIED BY '233233@Digi';
GRANT REPLICATION SLAVE ON *.* TO 'replica'@'%';
ALTER USER 'root'@'localhost' IDENTIFIED BY '233233@Digi';
FLUSH PRIVILEGES;
然后修改/etc/my.cnf.d/mysql-server.cnf
log_bin = /var/log/mysql/mysql-bin.log
server_id = 1
然后重启mysql
systemctl restart mysqld
开放一下master的3306端口
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
mysql -u root -p233233@Digi
SHOW MASTER STATUS;
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 1901 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
看到这里的File和Position了吗?等会下面需要使用
在从机上安装mysql,然后修改/etc/my.cnf.d/mysql-server.cnf
按照实际情况增加
server_id = 2
server_id = 3
server_id = 4
然后依次在每台从服务器上执行
mysql -u root -p233233@Digi
CHANGE MASTER TO
MASTER_HOST='192.168.10.211',
MASTER_USER='replica',
MASTER_PASSWORD='233233@Digi',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=1901,
get_master_public_key=1;
START SLAVE;
SHOW SLAVE STATUS\G
然后看到如下图这样,只要没有error信息,就算是成功了.
标签:部署,192.168,server,--,MASTER,Digi,mysql From: https://blog.csdn.net/surfer00/article/details/145209189