|
规划:
主服务器:192.168.1.254
从服户端:192.168.1.215
系统环境:
操作系统 CentOS6.4_x64
mysql mysql-server-5.1.73-3.el6_5.x86_64
一、配置主服务端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| 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
ssl
ssl_ca=/etc/mysqld/ssl/cacert.pem
ssl_cert=/etc/mysqld/ssl/mysqld.crt
ssl_key=/etc/mysqld/ssl/mysqld.key
2.创建具有权限的用户
mysql> GRANT REPLICATION SLAVE ON *.* to 'repluser'@'192.168.1.%' IDENTIFIED BY 'replpass' REQUIRE ssl;
Query OK, 0 rows affected (0.09 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.10 sec)
|
二、配置从服户端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| 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.配置参数
CHANGE MASTER TO MASTER_HOST='192.168.1.254',MASTER_USER='repluser',MASTER_PASSWORD='replpass',MASTER_LOG_FILE='master-bin.000003',MASTER_LOG_POS=418,MASTER_SSL=1,MASTER_SSL_CA='/etc/mysqld/ssl/cacert.pem',MASTER_SSL_CERT='/etc/mysqld/ssl/mysqld.crt',MASTER_SSL_KEY='/etc/mysqld/ssl/mysqld.key';
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;
Master_SSL_Allowed: Yes
Master_SSL_CA_File: /etc/mysqld/ssl/cacert.pem
Master_SSL_CA_Path:
Master_SSL_Cert: /etc/mysqld/ssl/mysqld.crt
Master_SSL_Cipher:
Master_SSL_Key: /etc/mysqld/ssl/mysqld.key
|
|
|