搭建MySQL和Tomcat集群
1、MySQL集群
1.1、MySQL主从复制
vim /etc/my.cnf
- master
server-id=1
log-bin=mysql-bin
log-slave-updates
slave-skip-errors=all
- slave1
server-id=2
log-bin=mysql-bin
log-slave-updates
slave-skip-errors=all
- slave2
server-id=3
log-bin=mysql-bin
log-slave-updates
slave-skip-errors=all
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/acb1fd6b897914a611f53455044f5acd.png#pic_center)
systemctl restart mysqld
mysql -u root -p
show VARIABLES like 'server_id';
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d6b4105670e775d4e9196bbee0105817.png#pic_center)
show master status;
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/33fb81b38d792fba86aa15c3652b8563.png#pic_center)
change master to
master_host='192.168.31.11',
master_user='root',
master_password='123456',
master_log_file='mysql-bin.000001',
master_log_pos=154;
start slave;
stop slave;
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/beac95e3db8f008492d764ac163f2fbb.png#pic_center)