时间:2021-07-01 10:21:17 帮助过:9人阅读
`sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf`
# enable remote connection bind-address = 0.0.0.0 ... # 2017-5-19 16:35 server-id = 1 log_bin = /var/log/mysql/mysql-bin.log
`sudo service mysql restart`
`grant replication slave on *.* to ‘replication‘@‘192.168.68.%‘ identified by ‘replication‘;`
`mysqldump -uroot -p --all-databases > /tmp/mysql_bak.sql`
`scp /tmp/mysql_bak.sql test@192.168.68.23:/tmp/mysql_bak.sql`
3. 配置从服务器
`sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf`
# enable remote connection bind-address = 0.0.0.0 ... # 2017-5-19 16:35 该值需要与主服务器不一样 server-id = 2
`sudo service mysql restart`
`mysql -uroot -p < /tmp/mysql_bak.sql`
mysql> CHANGE MASTER TO
-> MASTER_HOST=‘192.168.68.24‘,
-> MASTER_PORT=3306,
-> MASTER_USER=‘replication‘,
-> MASTER_PASSWORD=‘replication‘,
-> MASTER_LOG_FILE=‘mysql-bin.000001‘,
-> MASTER_LOG_POS=120;
`start slave;`
` show slave status \G`
Slave_IO_Running/Slave_SQL_Running为Yes则表示成功
4. 遇到问题
The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work?
解决方案:http://www.chriscalender.com/resolving-error-master-and-slave-have-equal-mysql-server-uuids/
a) `mv /var/lib/mysql/auto.cnf /tmp/auto.cnf`
b) `sudo service mysql restart`
Mysql主从配置
标签:scp targe mysq mysql配置 pre ice 主服务器 base diff