mysql互为主从复制详解----mysql-mm(4)
B: /usr/local/mysql/bin/mysql -h'A_IP' -urepl2 -p
两台机器上均重启mysql
killall mysqld
ps aux |grep mysql
/usr/local/mysql/bin/mysqld_safe &
ps aux |grep mysql
进入MYSQL的SHELL
/usr/local/mysql/bin/mysql -uroot -p
A:
服务器锁表(锁表状态下不能终止mysql进程,否则会失败)
mysql> flush tables with read lock\G;
Query OK, 0 rows affected (0.01 sec)
----------------
查看 A 服务器主机状态(记录二进制开始文件,位置)
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000005
Position: 106
Binlog_Do_DB: test
Binlog_Ignore_DB: mysql
1 row in set (0.00 sec)
----------------
修改A服务器配置
mysql> change master to
-> master_host='211.100.97.250',
-> master_user='repl2',
-> master_password='123456',
-> master_log_file='mysql-bin.000014',
-> master_log_pos=98;
Query OK, 0 rows affected (0.01 sec)
说明:
master_host表示主机B(250)是A(246)的master
master_user表示允许A(246)上的账户repl1连接到master进行复制,建议两台主机的授权用户和密码完全相同。
master_password 表示授权用户repl1的密码
master_log_file 表示master上日志文件的名称
master_log_pos 表示日志文件的位置
----------------
mysql> slave stop;
mysql> change master to master_host='B_IP', master_user='repl1', master_password='123456', master_log_file='mysql-bin.000001', master_log_pos=106;
然后启动slave
mysql> slave start;
启动之后查看slave的状态
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 211.100.97.250
Master_User: repl1
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 106
Relay_Log_File: XKWB5510-relay-bin.000002
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>