CLUSTERPRO + MySQL

node1: mmm121 CentOS7 MySQL8.0
node2: mmm122 CentOS7 MySQL8.0
iSCSItarget: mmm123 CentOS7
管理サーバ: mmm161 Windows Server2012R2


構築手順

1. フェイルオーバグループの作成
→「CLUSTERPROインストール」参照

2. MySQL のインストール[node1,node2]

yum update -y

--mariaDB削除
yum remove -y mariadb-libs
rm -rf /var/lib/mysql/

--yum リポジトリの追加
yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum info mysql-community-server

--インストール
yum install -y mysql-community-server
mysqld --version

--DB起動
systemctl restart mysqld
systemctl status mysqld


--初期パスワードの確認
cat /var/log/mysqld.log | grep password

--セキュリティ設定
mysql_secure_installation

rV9ldP;bLFtu


--設定ファイル
vim /etc/my.cnf

[mysqld]
character_set_server = utf8mb4

max_connections = 300
max_allowed_packet = 1M

max_heap_table_size = 16M
table_open_cache = 500

sort_buffer_size = 2M
read_buffer_size = 128K
read_rnd_buffer_size = 256K
join_buffer_size = 128K
tmp_table_size = 16M

innodb_buffer_pool_size = 800M
innodb_log_file_size = 128M
innodb_log_buffer_size = 20M


systemctl restart mysqld
systemctl status mysqld
systemctl disable mysqld

--DB接続
mysql -u root -p

 

3. データベースディレクトリの変更[node1,node2]

--node1での作業

mkdir -p /mnt/sdc2/mysql
chown -R mysql:mysql /mnt/sdc2/mysql
chmod -R 755 /mnt/sdc2/mysql


systemctl stop mysqld
systemctl status mysqld

cp -a /var/lib/mysql/* /mnt/sdc2/mysql

vim /etc/my.cnf

(修正)
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

datadir=/mnt/sdc2/mysql
socket=/mnt/sdc2/mysql/mysql.sock


(追加)
[client]
socket=/mnt/sdc2/mysql/mysql.sock

systemctl restart mysqld

 


--node2での作業

systemctl stop mysqld
systemctl status mysqld

vim /etc/my.cnf

(修正)
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

datadir=/mnt/sdc2/mysql
socket=/mnt/sdc2/mysql/mysql.sock


(追加)
[client]
socket=/mnt/sdc2/mysql/mysql.sock


4. CLUSTERPRO へのサービスの組み込み[管理サーバ]

タイプ: execute resource
名前: mysql

依存するリソース: disk1,fip1


--start.sh
同期
タイムアウト:300秒

#! /bin/sh
#***************************************
#* start.sh *
#***************************************

#ulimit -s unlimited

if [ "$CLP_EVENT" = "START" ]
then
if [ "$CLP_DISK" = "SUCCESS" ]
then
echo "NORMAL1"

systemctl start mysqld
sleep 10

if [ "$CLP_SERVER" = "HOME" ]
then
echo "NORMAL2"
else
echo "ON_OTHER1"
fi
else
echo "ERROR_DISK from START"
exit 1
fi
elif [ "$CLP_EVENT" = "FAILOVER" ]
then
if [ "$CLP_DISK" = "SUCCESS" ]
then
echo "FAILOVER1"

systemctl start mysqld
sleep 10


if [ "$CLP_SERVER" = "HOME" ]
then
echo "FAILOVER2"
else
echo "ON_OTHER2"
fi
else
echo "ERROR_DISK from FAILOVER"
exit 1
fi
else
echo "NO_CLP"
exit 1
fi
echo "EXIT"
exit 0


--stop.sh
同期
タイムアウト:300秒

#! /bin/sh
#***************************************
#* stop.sh *
#***************************************

#ulimit -s unlimited

if [ "$CLP_EVENT" = "START" ]
then
if [ "$CLP_DISK" = "SUCCESS" ]
then
echo "NORMAL1"

systemctl stop mysqld
sleep 10

if [ "$CLP_SERVER" = "HOME" ]
then
echo "NORMAL2"
else
echo "ON_OTHER1"
fi
else
echo "ERROR_DISK from START"
exit 1
fi
elif [ "$CLP_EVENT" = "FAILOVER" ]
then
if [ "$CLP_DISK" = "SUCCESS" ]
then
echo "FAILOVER1"

systemctl stop mysqld
sleep 10


if [ "$CLP_SERVER" = "HOME" ]
then
echo "FAILOVER2"
else
echo "ON_OTHER2"
fi
else
echo "ERROR_DISK from FAILOVER"
exit 1
fi
else
echo "NO_CLP"
exit 1
fi
echo "EXIT"
exit 0

 

 

5. 監視リソースの設定[管理サーバ]

タイプ:custom monitor
名前: mysql_mon

監視タイプ:同期

--genw.sh


#! /bin/sh
#***********************************************
#* genw.sh *
#***********************************************

ulimit -s unlimited

CNT=`ps -ef | grep /usr/sbin/mysqld | grep -v grep | wc -l`

if [ $CNT -ne 1 ]; then
exit 1
fi

exit 0


回復動作: failover1に対してフェイルオーバ実行