Lab Environment:
Two MARIADB servers 172.16.10.20 172.16.10.21
fip:172.16.10.28
MARIADB file storage share: 172.16.10.22
Experiment Preparation:
1, two node host name and corresponding IP address resolution service can work, and the host name of each node needs to be consistent with the results of the "uname-n" command
Vim/etc/hosts 172.16.10.20 21.xuphoto.com 20xu 172.16.10.21 22.xuphoto.com 21xu Node1: # sed-i ' [email p Rotected]\ (hostname=\). *@\[email protected] ' # HOSTNAME 21.xuphoto.com Node2: # sed-i ' [Email protected]\ (HOS tname=\). *@\[email protected] ' # hostname 22.xuphoto.com
2, each node time consistency can add unified NTP Server Synchronization task:
CRONTAB-E */3 * * * */usr/sbin/ntpdate 172.16.0.1 &>/dev/null
3, between the nodes can be based on the key to verify SSH without password
ssh-keygen-t RSA Ssh-copy-id-i [email protected] # node1 node ssh-keygen-t RSA Ssh-copy-id -I [email protected] # Node1 Node
4, Configuration Installation Corosync/pacemaker
Yum Install Corosync pacemaker-y
5. Configure and install DRBD
1, provide disk space (2 node space is the same size)
FDISK/DEV/SDA # Create a 5G Primary Partition
2 , installation
RPM-IVH kmod-drbd84-8.4.5-504.1.el6.x86_64.rpm drbd84-utils-8.9.1-1.el6.elrepo.x86_64.rpm
3 , Common Files
& nbsp /etc/drbd.d/global_common.conf
#usage-countno; Disk {on-io-error Detach;net {cram-hmac-alg "SHA1"; #设置密码算法 Shared-secret "um+b1fjxtqcl14ldvkz/3q" # Set key Syncer {rate 500M; #设置传输速率}
4. Create a resource file /etc/drbd.d/mysqlnf . Res
Resource Mysqlnfs {device/dev/drbd0; DISK/DEV/SDA4; Meta-disk internal; On 20.xuphoto.com {address 172.16.10.20:7789; #}
On 21.xuphoto.com {address 172.16.10.21:7789;}
4 , copy the configuration file to another server;
SCP Web.res global_common.conf 21xu:/etc/drbd.d/
5, initialize the resources;
#drbdadmcreate-MD WEB
6 , two node start service
Service DRBD start; SSH 21xu ' service drbd start '
7 , view status
Cat/proc/drbd
8 , set the master node
# Drbdadm Primary--force Resource
Defining rules using CRM
CRM (Live) configure#property no-quorum-policy=ignore #定义全局属性crm (live) configure#property stonith-enabled=false #定义全局属性crm (Live) configure#primitive myip ocf:heartbeat : ipaddr params ip=172.16.10.28 nic=eth0cidr_netmask=16 op monitor interval=20 timeout=20 #定义fip =172.16.10.28crm (live) #primitive mystor ocf:linbit:drbd Params drbd_resource=mysqlfs op monitorrole=master interval=10s timeout=20 op monitor role=slave interval=20 timeout=20op start timeout=240 op stop timeout=100 #定义drbd Main Resources CRM (live) configure# ms ms_mystor mystor meta clone-max=2 clone-node-max=1 master-max=1master-node-max=1 notify=true # Define Master Resource cloning Properties CRM (live) configure# primitive mydata ocf:heartbeat:filesystem params Device= ' dev/drbd0 ' directory= '/mydata ' fstype= ' Ext4 ' op monitor interval=20s timeout=20s opstart timeout=60s op stop timeout=60s #定义挂载点crm (Live) Configure#primitive mysql lsb:mysqld op monitor interval=20 timeout=20 #定义mysql资源crm (Live) #colocation mydata_with_ms_mystor_master inf: mydata ms_mystor:Master #定义排列约束 mount point and DRBD master must be together with CRM (live) Configure#colocation mysql_with_mydata inf: mysql mydata #定义mysql和文件挂载点必须在一起crm (Live) Configure#colocation myip_with_mystor_master inf: myip ms_mystor:Master #定义FIP必须和drbd主资源在一起ordermydata_after_mystor mandatory: ms_mystor:promote mydata:start #定义顺序约束 Mount the file system when DRBD switches to master Ordermysql_after_mydata mandatory: mydata :start mysql:start #定义顺序约束, MySQL does not start after file system mount is complete
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/ED/wKiom1VvA9LAh5ezAAGLX0v8Adw208.jpg "title=" image 0603.jpg "alt=" Wkiom1vva9lah5ezaaglx0v8adw208.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/ED/wKiom1VvBFbyf2wXAAL_0PLfqTc048.jpg "title=" image 0603 (4). jpg "alt=" wkiom1vvbfbyf2wxaal_0plfqtc048.jpg "/>
Corosync +DRBD Implement Ha MariaDB