规划:
主服务器:192.168.1.254
从服户端:192.168.1.215
系统环境:
操作系统 CentOS6.4_x64
mysql mysql-server-5.1.73-3.el6_5.x86_64
一、配置主服务端
1.编辑配置文件 vim /etc/my.cnf [mysqld] innodb_file_per_table=1 log_bin=master-bin log_bin_index=master-bin.index server-id=1 sync_binlog=1 2.创建具有权限的用户 mysql> GRANT REPLICATION SLAVE ON *.* to ‘repluser‘@‘192.168.1.%‘ IDENTIFIED BY ‘replpass‘; Query OK, 0 rows affected (0.09 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.10 sec)
二、配置从服户端
1.编辑配置文件 vim /etc/my.cnf [mysqld] relay_log=slave-log relay_log_index=slave-log.index innodb_file_per_table=1 relay-log=relay-log relay-log=relay-log.index server-id=11 read-only=1 2.配置参数mysql> CHANGE MASTER TO MASTER_HOST=‘192.168.1.254‘,MASTER_USER=‘repluser‘,MASTER_PASSWORD=‘replpass‘,MASTER_LOG_FILE=‘master-bin.000001‘,MASTER_LOG_POS=339 mysql> SHOW SLAVE STATUS/G Slave_IO_State: Master_Host: 192.168.1.254 Master_User: repluser Master_Port: 3306 Connect_Retry: 60 Master_Log_File: master-bin.000001 Read_Master_Log_Pos: 339 Relay_Log_File: slave-log.000001 Relay_Log_Pos: 4 Relay_Master_Log_File: master-bin.000001 Slave_IO_Running: No Slave_SQL_Running: No 3.启动服务 mysql> START SLAVE; mysql> SHOW SLAVE STATUS\G; Slave_IO_Running: Yes Slave_SQL_Running: Yes
原文地址:http://5127276.blog.51cto.com/5117276/1563075