6.0.128 172.16.0.129
auto_failback on (从节点修改为off)
?
node dbm128
node dbm129
respawn hacluster /usr/lib64/heartbeat/ipfail
respawn hacluster /usr/lib64/heartbeat/dopd
?
apiauth ipfail gid=haclient uid=hacluster
apiauth dopd gid=haclient uid=hacluster
增加到后面cat /etc/ha.d/authkeys
auth 1
1 sha1 HA_JACKBILLOW
增加到后面 cat /etc/ha.d/haresources
dbm128 drbddisk::r0 Filesystem::/dev/drbd1::/data mysql IPaddr::172.16.0.233/24/eth0
上面dbm128主机,如果dbm129修改本主机名。
启动heartbeat服务:
[root@dbm128 ~]/etc/init.d/heartbeat start
[root@dbm129 ~]/etc/init.d/heartbeat start
配置heartbeat 在启动级别3中自动启动:
[root@dbm128 ~]chkconfig --level 35 heartbeat on
[root@dbm129 ~]chkconfig --level 35 heartbeat on
观察heartbeat 启动日志是否正常
[root@dbm128 ~]# tail -f /var/log/ha-log
IPaddr[4782]: 2014/07/21_16:48:15 INFO: Success
heartbeat[4147]: 2014/07/21_16:48:57 info: dbm129 wants to go standby [foreign]
heartbeat[4147]: 2014/07/21_16:48:57 info: standby: acquire [foreign] resources from dbm129
heartbeat[5029]: 2014/07/21_16:48:57 info: acquire local HA resources (standby).
ResourceManager[5042]: 2014/07/21_16:48:57 info: Acquiring resource group: dbm128 drbddisk::r0 Filesystem::/dev/drbd1::/data mysql IPaddr::172.16.0.233/24/eth0
Filesystem[5083]: 2014/07/21_16:48:58 INFO: Running OK
IPaddr[5158]: 2014/07/21_16:48:58 INFO: Running OK
heartbeat[5029]: 2014/07/21_16:48:58 info: local HA resource acquisition completed (standby).
heartbeat[4147]: 2014/07/21_16:48:58 info: Standby resource acquisition done [foreign].
heartbeat[4147]: 2014/07/21_16:48:58 info: remote resource transition completed.
测试一下,看172.16.0.233是VIP,在两台主机之间漂移。
11.主从复制的配置
修改dbs130,dbs131主的my.cnf的server-id=1,每个同步服务都必须设定一个唯一的编号。
在Master(这里为dbm128机器)上增加一个用于复制的账号:
mysql>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'172.16.0.%' IDENTIFIED BY '123456';
mysql>FLUSH REPLICATION;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000018 | 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
设置Slave 主机
修改my.cnf的server-id,内容如下:
dbs130主机
server-id=3
dbs130主机
server-id=4
开启Master与Slave的同步
在Slave上执行如下命令
mysql>CHANGE MASTER TO MASTER_HOST='172.16.0.233',
->MASTER_USER='repl',
->MASTER_PASSWORD='123456',
->MASTER_LOG_FILE=' mysql-bin.000018',
->MASTER_LOG_POS=107;
之后执行
mysql>slave start;
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.0.233
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000018
Read_Master_Log_Pos: 107
Relay_Log_File: dbs130-relay-bin.000007
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000018
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 107
Relay_Log_Space: 556
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_