前言
Master
它的缺點是
本文主要討論的是如何解決第
解決方案如下圖
# cd /usr/local/
# tar
# mv mysql
# groupadd mysql
# useradd
#passwd mysql
datadir=/u
server
log
先在ha
[root@ha
[root@ha
[root@ha
安裝mysql
[root@ha
#
# cp support
# chmod +x /etc/rc
# chkconfig
# /etc/rc
[root@ha
[root@ha
[root@ha
[root@ha
[root@ha
[root@ha
[root@ha
[root@ha
編輯/etc/ha
cat /etc/ha
顯示
auth
更改文件權限
chmod
[root@ha
debugfile /var/log/ha
logfile /var/log/ha
logfacility local
keepalive
deadtime
warntime
udpport
crm yes
node ha
bcast eth
auto_failback off
apiauth cibmon uid=hacluster
respawn hacluster /usr/lib
配置資源
[root@ha
ha
啟動的時候從左到右依次運行腳本
這個文件原名為haresources 在
將資源文件轉換成cib
[root@ha
[root@ha
[root@ha
/usr/lib
[root@ha
<primitive class=
<op id=
即每
成功
[root@ha
查看資源情況
============
Last updated: Tue Feb
Current DC: ha
============
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
[root@ha
[root@ha
[root@ha
heartbeat
[root@ha
Enter password:
Welcome to the MySQL monitor
Your MySQL connection id is
Server version:
Type
mysql> GRANT RELOAD
IDENTIFIED BY
mysql> show master status\G;
***************************
File: master
Position:
Binlog_Do_DB:
Binlog_Ignore_DB:
因為沒有數據
mysql> CHANGE MASTER TO MASTER_HOST=
MASTER_PORT =
MASTER_USER=
MASTER_PASSWORD=
MASTER_LOG_FILE=
MASTER_LOG_POS =
Query OK
mysql> start slave;
Query OK
mysql> show slave status\G;
***************************
Slave_IO_State:Waiting for master to send event
Master_Host:
Master_User: slave
Master_Port:
Connect_Retry:
Master_Log_File: master
Read_Master_Log_Pos:
Relay_Log_File: mysql
Relay_Log_Pos:
Relay_Master_Log_File: master
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
將ha
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
沒有問題
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
將ha
將ha
datadir=/u
[root@ha
root
mysql
root
root
[root@ha
[root@ha
root
在ha
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
Failed actions:
mysqld_
mysqld_
將ha
[root@ha
在ha
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
資源全部切換到ha
[root@ha
Enter password:
Welcome to the MySQL monitor
Your MySQL connection id is
Server version:
Type
root@test >create table t(t
root@test >insert into t values(
root@test >select * from t;
+
| t
+
|
+
在slave 查看是否同步
[root@mysql
Welcome to the MySQL monitor
Your MySQL connection id is
Server version:
Type
mysql> use test
Database changed
mysql> select * from t;
+
| t
+
|
+
在將資源切回到ha
[root@ha
Node: ha
Node: ha
Resource Group: group_
IPaddr_
Filesystem_
mysqld_
資源已經切回到ha
[root@ha
Enter password:
Welcome to the MySQL monitor
Your MySQL connection id is
Server version:
Type
mysql> insert into t values(
mysql> insert into t values(
mysql> select * from t;
+
| t
+
|
|
|
+
在slave 查看是否同步
mysql> select * from t;
+
| t
+
|
|
|
+
mysql> show slave status\G;
***************************
Slave_IO_State:Waiting for master to send event
Master_Host:
Master_User: slave
Master_Port:
Connect_Retry:
Master_Log_File: master
Read_Master_Log_Pos:
Relay_Log_File: mysql
Relay_Log_Pos:
Relay_Master_Log_File: master
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Master 切換後
寫個簡單的循環
[root@mysql
for ((num=
do
echo
/usr/local/mysql/bin/mysql
insert into t values($num);
if (( $? )); then
echo $num:no
else
echo $num:ok
fi
done
在寫入過程中
mysql> show slave status\G;
***************************
Slave_IO_State:
Master_Host:
Master_User: slave
Master_Port:
Connect_Retry:
Master_Log_File: master
Read_Master_Log_Pos:
Relay_Log_File: mysql
Relay_Log_Pos:
Relay_Master_Log_File: master
Slave_IO_Running: No
Slave_SQL_Running: Yes
查看slave 報錯日志
replication from impossible position ( server_errno=
impossible position
在master
查看master 的binlog
[root@ha
/*!*/;
# at
#
exec_time=
SET TIMESTAMP=
insert into t values(
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!
在master 上
mysql> stop slave;
Query OK
mysql> CHANGE MASTER TO MASTER_HOST=
=
ER_LOG_POS =
Query OK
mysql> start slave;
Query OK
mysql> show slave status\G;
***************************
Slave_IO_State:Waiting for master to send event
Master_Host:
Master_User: slave
Master_Port:
Connect_Retry:
Master_Log_File: master
Read_Master_Log_Pos:
Relay_Log_File: mysql
Relay_Log_Pos:
Relay_Master_Log_File: master
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
在這次斷電的切換過程中
查看資源狀態
#crm_mon –i
查看節點資源
#crm_resource
查看資源在那個節點上運行
# crm_resource
啟動/停止資源
#crm_resource
#crm_resource
將資源組從當前節點轉移到另個節點
#crm_resource
將資源組轉移到指定節點
#crm_resource
允許資源組回到正常的節點
#crm_resource
將資源從CRM 中刪除
#crm_resource
將資源組從CRM 中刪除
#crm_resource
將資源從CRM 中禁用
#crm_resource
將資源從新從CRM 中啟用
#crm_resource
重啟資源
#crm_resource
檢查所有節點上未在CRM 中的資源
#crm_resource
檢查指定節點上未在CRM 中的資源
#crm_resource
檢查所有節點上未在CRM 中的資源
#crm_resource
檢查指定節點上未在CRM 中的資源
#crm_resource
八
將數據文件放在NFS 上
From:http://tw.wingwit.com/Article/program/MySQL/201311/29350.html