mysql -uroot -pas1a2nf3 mysql> grant replication slave on *.* to 'slave'@'172.16.1.%' identified by 'as1a2nf3'; mysql> grant all on *.* to "mha"@"172.16.1.%" identified by "as1a2nf3"; mysql> flush privileges; mysql> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | master-bin.000001 | 546 | | | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
mysql -uroot -pas1a2nf3 change master to master_host="172.16.1.12",master_user="slave",master_password="as1a2nf3",master_log_file="mysql-bin.000001",master_log_pos=546; start slave; show slave status\G # 出现以下则成功 Slave_IO_Running: Yes Slave_SQL_Running: Yes mysql> grant replication slave on *.* to 'slave'@'172.16.1.%' identified by 'as1a2nf3'; mysql> grant all on *.* to "mha"@"172.16.1.%" identified by "as1a2nf3"; mysql> flush privileges;
mysql -uroot -pas1a2nf3 change master to master_host="172.16.1.12",master_user="slave",master_password="as1a2nf3",master_log_file="mysql-bin.000001",master_log_pos=546; start slave; show slave status\G # 出现以下则成功 Slave_IO_Running: Yes Slave_SQL_Running: Yes mysql> grant replication slave on *.* to 'slave'@'172.16.1.%' identified by 'as1a2nf3'; mysql> grant all on *.* to "mha"@"172.16.1.%" identified by "as1a2nf3"; mysql> flush privileges;
[root@localhost ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:uNeSnO2vW67XhgcBMf0xTaRwxP9uU+jk1qxjS7rRxtU root@localhost The key's randomart image is: +---[RSA 2048]----+ | oo.oo+o| | ...o+..| | . ..+ | | . . . o| | . S . .E| | o = .oo.o| | . * o oB=+.| | . o oo=X.=| | =*=*o=.| +----[SHA256]-----+ # 传送时输入正确密码即可 [root@localhost ~]# ssh-copy-id root@172.16.1.12 [root@localhost ~]# ssh-copy-id root@172.16.1.13 [root@localhost ~]# ssh-copy-id root@172.16.1.14