heartbeat 3.0.4-drbd 8.9-Mysql 5.6--雙機互備高可用部署

清風艾艾發表於2017-09-04

   heartbeat 3.0.4-drbd 8.9- 5.6協同工作原理:首先,heartbeat作為高可用的控制角色,負責drbd儲存服務目錄的掛載(這裡,drbd的啟動個人理解是隨主機啟動自動

啟動的,其作用就是將主節點本地的一塊盤與對端備節點的一塊盤做資料同步、保證兩端主機drbd相關的資料盤中資料完全一致),drbd的儲存目錄只在主節點掛載、接受讀

寫,而備機保持不可用;當heartbeat完成drbd儲存目錄掛載後,啟動mysql,同時heartbeat負責檢測drbd儲存、mysql服務的狀態,當服務異常,透過超時機制將資源

在備機啟動,從而達到mysql雙機互備高可用的目的。

    前提條件:

    按照博文linux-ha heartbeat高可用的安裝配置(http服務高可用)完成heartbeat的安裝配置

    按照博文MySQL 5.6 for REHL 6.4編譯安裝完成mysql的安裝配置


heartbeat安裝參考日誌:linux-ha heartbeat高可用-基於http服務的安裝配置
mysql的編譯安裝參考日誌:MySQL安裝方式-MySQL編譯安裝
一、DRBD軟體的安裝配置
主機名稱
mymongo1
arbiter
管理IP
eth0:192.168.199.131
eth0:192.168.199.134
DRBD管理名稱
/data
/data
DRBD邏輯裝置
/dev/drbd0
/dev/drbd0
DRBD對接IP
eth1:192.168.144.132
eth1:192.168.144.111
DRBD儲存裝置
/dev/sdb1
/dev/sdb1
DRBD META裝置
/dev/sdb2 [0]
/dev/sdb2 [0]
虛擬IP
eth1:192.168.144.122
eth1:192.168.144.122





1、兩臺vmware linux 虛擬機器arbiter和mymongo1(兩臺主機需要新新增虛擬硬碟sdb),基本資訊
mymongo1
[root@mymongo1 ~]# hostname
mymongo1
[root@mymongo1 ~]# uname -a
Linux mymongo1 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@mymongo1 ~]# fdisk -l

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00061eae

Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2350 18566144 83 Linux
/dev/sda3 2350 2611 2097152 82 Linux swap / Solaris
[root@mymongo1 ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@mymongo1 ~]#

arbiter
[root@arbiter ~]# uname -a
Linux arbiter 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@arbiter ~]# hostname
arbiter
[root@arbiter ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
[root@arbiter ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078b06

Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 549 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 549 2611 16567296 83 Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@arbiter ~]#

2、2臺虛擬機器sdb虛擬盤的分割槽表調整
[root@arbiter ~]# parted /dev/sdb mklabel gpt
Information: You may need to update /etc/fstab.
[root@arbiter ~]#

[root@mymongo1 ~]# parted /dev/sdb mklabel gpt
Information: You may need to update /etc/fstab.
[root@mymongo1 ~]#

3、2臺虛擬機器sdb(共2個G)分割槽成2個分割槽,一個分割槽一個G
[root@mymongo1 ~]# parted /dev/sdb mkpart primary 0 1024
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Information: You may need to update /etc/fstab.
[root@mymongo1 ~]#
[root@mymongo1 ~]# parted /dev/sdb mkpart primary 1025 2146
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Information: You may need to update /etc/fstab.
[root@mymongo1 ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024MB 1024MB primary
2 1025MB 2146MB 1121MB primary
[root@mymongo1 ~]#

[root@arbiter ~]# parted /dev/sdb mkpart primary 0 1024
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Information: You may need to update /etc/fstab.
[root@arbiter ~]# parted /dev/sdb mkpart primary 1025 2146
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Information: You may need to update /etc/fstab.
[root@arbiter ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024MB 1024MB primary
2 1025MB 2146MB 1121MB primary
[root@arbiter ~]#

4、2臺虛擬機器安裝drbd,透過網路yum安裝,保證兩臺主機能夠聯網
[root@arbiter ~]# wget ftp.scientificlinux.org/linux/scientific/6.9/x86_64/os/Packages/elrepo-release-6-6.el6.elrepo.noarch.rpm
--2017-08-23 23:14:54--
Resolving ftp.scientificlinux.org... 131.225.105.11
Connecting to ftp.scientificlinux.org|131.225.105.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7464 (7.3K) [application/x-rpm]
Saving to: ?.lrepo-release-6-6.el6.elrepo.noarch.rpm?

100%[====================================================================================>] 7,464 --.-K/s in 0.01s

2017-08-23 23:14:56 (544 KB/s) - ?.lrepo-release-6-6.el6.elrepo.noarch.rpm?.saved [7464/7464]

[root@arbiter ~]# ls
anaconda-ks.cfg Documents heartbeat mysql-5.6.36 Public test
cmake-2.8.10.2 Downloads install.log mysql-5.6.36.tar rpms Videos
cmake-2.8.10.2.tar elrepo-release-6-6.el6.elrepo.noarch.rpm install.log.syslog Pictures select
Desktop epel-release-6-8.noarch.rpm Music pkg Templates
[root@arbiter ~]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpm
warning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing... ########################################### [100%]
1:elrepo-release ########################################### [100%]
[root@arbiter ~]#
[root@arbiter ~]# ls
anaconda-ks.cfg Downloads install.log mysql-5.6.36.tar select
cmake-2.8.10.2 drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm install.log.syslog Pictures Templates
cmake-2.8.10.2.tar elrepo-release-6-6.el6.elrepo.noarch.rpm kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm pkg test
Desktop epel-release-6-8.noarch.rpm Music Public Videos
Documents heartbeat mysql-5.6.36 rpms
[root@arbiter ~]# rpm -ivh drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm
warning: drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEY
Preparing... ########################################### [100%]
1:drbd84-utils ########################################### [100%]
[root@arbiter ~]#
[root@arbiter yum.repos.d]# ls
elrepo.repo epel-testing.repo local.repo
[root@arbiter yum.repos.d]#
[root@arbiter yum.repos.d]# cat local.repo
[local]
name = local
baseurl=file:///mnt/
enabled = 1
gpgcheck = 0
gpgkey =file://mnt/RPM-GPG-KEY-CentOS-6
[root@arbiter yum.repos.d]#
[root@arbiter ~]# yum install -y kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
elrepo | 2.9 kB 00:00
elrepo/primary_db | 692 kB 00:12
Setting up Install Process
Examining kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
Marking kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package kmod-drbd84.x86_64 0:8.4.9-1.el6.elrepo will be installed
--> Processing Dependency: kernel(__dynamic_dev_dbg) = 0x4b1a6158 for package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
--> Processing Dependency: kernel(dev_printk) = 0xabd7b07b for package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
--> Finished Dependency Resolution
Error: Package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 (/kmod-drbd84-8.4.9-1.el6.elrepo.x86_64)
Requires: kernel(__dynamic_dev_dbg) = 0x4b1a6158
Error: Package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 (/kmod-drbd84-8.4.9-1.el6.elrepo.x86_64)
Requires: kernel(dev_printk) = 0xabd7b07b
You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of mysql-libs
[root@arbiter ~]# rpm -qa|grep kmod-drbd84
[root@arbiter ~]# yum install -y kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
elrepo | 2.9 kB 00:00
elrepo/primary_db | 692 kB 00:10
local | 4.0 kB 00:00 ...
local/primary_db | 4.7 MB 00:00 ...
Setting up Install Process
Examining kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
Marking kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package kmod-drbd84.x86_64 0:8.4.9-1.el6.elrepo will be installed
--> Processing Dependency: kernel(__dynamic_dev_dbg) = 0x4b1a6158 for package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
--> Processing Dependency: kernel(dev_printk) = 0xabd7b07b for package: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-642.el6 will be installed
--> Processing Dependency: kernel-firmware >= 2.6.32-642.el6 for package: kernel-2.6.32-642.el6.x86_64
--> Processing Dependency: dracut-kernel >= 004-388.el6 for package: kernel-2.6.32-642.el6.x86_64
--> Running transaction check
---> Package dracut-kernel.noarch 0:004-303.el6 will be updated
---> Package dracut-kernel.noarch 0:004-409.el6 will be an update
--> Processing Dependency: dracut = 004-409.el6 for package: dracut-kernel-004-409.el6.noarch
---> Package kernel-firmware.noarch 0:2.6.32-358.el6 will be updated
---> Package kernel-firmware.noarch 0:2.6.32-642.el6 will be an update
--> Running transaction check
---> Package dracut.noarch 0:004-303.el6 will be updated
---> Package dracut.noarch 0:004-409.el6 will be an update
--> Processing Conflict: kernel-2.6.32-642.el6.x86_64 conflicts bfa-firmware < 3.2.21.1-2
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package bfa-firmware.noarch 0:3.0.3.1-1.el6 will be updated
---> Package bfa-firmware.noarch 0:3.2.23.0-2.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
kmod-drbd84 x86_64 8.4.9-1.el6.elrepo /kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 696 k
Updating:
bfa-firmware noarch 3.2.23.0-2.el6 local 3.2 M
Installing for dependencies:
kernel x86_64 2.6.32-642.el6 local 32 M
Updating for dependencies:
dracut noarch 004-409.el6 local 127 k
dracut-kernel noarch 004-409.el6 local 28 k
kernel-firmware noarch 2.6.32-642.el6 local 28 M

Transaction Summary
===============================================================================================================================================
Install 2 Package(s)
Upgrade 4 Package(s)

Total size: 64 M
Total download size: 63 M
Downloading Packages:
-----------------------------------------------------------------------------------------------------------------------------------------------
Total 93 MB/s | 63 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of mysql-libs
Updating : kernel-firmware-2.6.32-642.el6.noarch 1/10
Updating : dracut-004-409.el6.noarch 2/10
Updating : dracut-kernel-004-409.el6.noarch 3/10
Installing : kernel-2.6.32-642.el6.x86_64 4/10
Installing : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 5/10
Working. This may take some time ...
Done.
Updating : bfa-firmware-3.2.23.0-2.el6.noarch 6/10
Cleanup : dracut-kernel-004-303.el6.noarch 7/10
Cleanup : dracut-004-303.el6.noarch 8/10
Cleanup : kernel-firmware-2.6.32-358.el6.noarch 9/10
Cleanup : bfa-firmware-3.0.3.1-1.el6.noarch 10/10
Verifying : dracut-kernel-004-409.el6.noarch 1/10
Verifying : dracut-004-409.el6.noarch 2/10
Verifying : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 3/10
Verifying : bfa-firmware-3.2.23.0-2.el6.noarch 4/10
Verifying : kernel-firmware-2.6.32-642.el6.noarch 5/10
Verifying : kernel-2.6.32-642.el6.x86_64 6/10
Verifying : dracut-kernel-004-303.el6.noarch 7/10
Verifying : dracut-004-303.el6.noarch 8/10
Verifying : kernel-firmware-2.6.32-358.el6.noarch 9/10
Verifying : bfa-firmware-3.0.3.1-1.el6.noarch 10/10

Installed:
kmod-drbd84.x86_64 0:8.4.9-1.el6.elrepo

Dependency Installed:
kernel.x86_64 0:2.6.32-642.el6

Updated:
bfa-firmware.noarch 0:3.2.23.0-2.el6

Dependency Updated:
dracut.noarch 0:004-409.el6 dracut-kernel.noarch 0:004-409.el6 kernel-firmware.noarch 0:2.6.32-642.el6

Complete!
[root@arbiter ~]#

[root@mymongo1 drbd]# wget ftp.scientificlinux.org/linux/scientific/6.9/x86_64/os/Packages/elrepo-release-6-6.el6.elrepo.noarch.rpm
--2017-08-23 23:15:15--
Resolving ftp.scientificlinux.org... 131.225.105.11
Connecting to ftp.scientificlinux.org|131.225.105.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7464 (7.3K) [application/x-rpm]
Saving to: ?.lrepo-release-6-6.el6.elrepo.noarch.rpm?

100%[==========================================================================>] 7,464 --.-K/s in 0s

2017-08-23 23:15:16 (223 MB/s) - ?.lrepo-release-6-6.el6.elrepo.noarch.rpm?.saved [7464/7464]
--mymongo1節點drbd的安裝
[root@mymongo1 drbd]# ls
elrepo-release-6-6.el6.elrepo.noarch.rpm
[root@mymongo1 drbd]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpm
warning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing... ########################################### [100%]
1:elrepo-release ########################################### [100%]
[root@mymongo1 drbd]#
[root@mymongo1 drbd]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpm
warning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing... ########################################### [100%]
1:elrepo-release ########################################### [100%]
[root@mymongo1 drbd]# yum install drbd kmod-drbd84 -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink | 4.6 kB 00:00
* base: mirrors.cn99.com
* elrepo: mirrors.tuna.tsinghua.edu.cn
* epel: mirror.premi.st
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.7 kB 00:00
elrepo | 2.9 kB 00:00
elrepo/primary_db | 692 kB 00:27
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 03:04
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
[Errno 12] Timeout on (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Trying other mirror.
updates/primary_db | 3.1 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package drbd84-utils.x86_64 0:8.9.8-1.el6.elrepo will be installed
---> Package kmod-drbd84.x86_64 0:8.4.9-1.el6.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
drbd84-utils x86_64 8.9.8-1.el6.elrepo elrepo 392 k
kmod-drbd84 x86_64 8.4.9-1.el6.elrepo elrepo 198 k

Transaction Summary
===================================================================================================================================
Install 2 Package(s)

Total download size: 590 k
Installed size: 1.7 M
Downloading Packages:
(1/2): drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm | 392 kB 00:11
(2/2): kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm | 198 kB 00:18
-----------------------------------------------------------------------------------------------------------------------------------
Total 19 kB/s | 590 kB 00:31
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
Importing GPG key 0xBAADAE52:
Userid : elrepo.org (RPM Signing Key for elrepo.org)
Package: elrepo-release-6-6.el6.elrepo.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of mysql-libs
Installing : drbd84-utils-8.9.8-1.el6.elrepo.x86_64 1/2
Installing : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 2/2
Working. This may take some time ...
Done.
Verifying : drbd84-utils-8.9.8-1.el6.elrepo.x86_64 1/2
Verifying : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 2/2

Installed:
drbd84-utils.x86_64 0:8.9.8-1.el6.elrepo kmod-drbd84.x86_64 0:8.4.9-1.el6.elrepo

Complete!
[root@mymongo1 drbd]#

[root@arbiter ~]# rpm -qa|grep drbd
kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
drbd84-utils-8.9.8-1.el6.elrepo.x86_64
[root@arbiter ~]#
[root@mymongo1 ~]# rpm -qa|grep drbd
drbd84-utils-8.9.8-1.el6.elrepo.x86_64
kmod-drbd84-8.4.9-1.el6.elrepo.x86_64
[root@mymongo1 ~]#

5、將drbd加入核心並設定drbd開機自啟動
[root@arbiter ~]# lsmod |grep drbd
[root@arbiter ~]# modprobe drbd
[root@arbiter ~]# lsmod |grep drbd
drbd 374888 0
libcrc32c 1246 1 drbd
[root@arbiter ~]# echo "modprobe drbd>/dev/null 2>&1">/etc/sysconfig/modules/drbd.modules
[root@arbiter ~]#

[root@mymongo1 ~]# lsmod |grep drbd
[root@mymongo1 ~]# modprobe drbd
[root@mymongo1 ~]# lsmod |grep drbd
drbd 374888 0
libcrc32c 1246 1 drbd
[root@mymongo1 ~]# echo "modprobe drbd>/dev/null 2>&1">/etc/sysconfig/modules/drbd.modules
[root@mymongo1 ~]#

6、編輯2個節點的drbd控制檔案
[root@mymongo1 ~]# drbdadm create-md data
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
[root@mymongo1 ~]# cat /etc/drbd.conf
global{
#minor-count 64;
#dialog-refresh 5; #5 seconds
#disable-ip-verification;
usage-count no;
}

common{
protocol C;
disk {
on-io-error detach;
no-disk-flushes;
no-md-flushes;
}
net {
sndbuf-size 512k;
#timout 60; #60 seconds
#connect-int 10; #10 seconds
#ping-int 10; #10seconds
#ping-timeout 5; #500 ms
max-buffers 8000;
unplug-watermark 1024;
max-epoch-size 8000;
#ko-count 4;
#allow-two-primaries;
cram-hmac-alg "sha1";
shared-secret "hdhwXes23sYEhart8t";
after-sb-0pri disconnect;
after-sb-1pri disconnect;
after-sb-2pri disconnect;
rr-conflict disconnect;
#data-integrity-alg "md5";
#no-tcp-cork;
}
syncer{
rate 330M;
al-extents 517;
}
}
resource data {
on arbiter {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.144.111:7788;
meta-disk /dev/sdb2 [0];
}
on mymongo1 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.144.132:7788;
meta-disk /dev/sdb2 [0];
}
}

[root@mymongo1 ~]#
[root@mymongo1 ~]# scp /etc/drbd.conf arbiter:/etc/
root@arbiter's password:
drbd.conf 100% 994 1.0KB/s 00:00
[root@mymongo1 ~]#

7、初始化兩個節點drbd源資料
[root@mymongo1 ~]# drbdadm create-md data
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
[root@mymongo1 ~]#
[root@arbiter ~]# drbdadm create-md data
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
[root@arbiter ~]#

8、啟動並檢視drbd
[root@mymongo1 ~]# drbdadm up data
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:WFConnection ro:Secondary/Unknown ds:Inconsistent/DUnknown C r----s
ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:999984
[root@mymongo1 ~]#
[root@arbiter ~]# drbdadm up data
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:999984
[root@arbiter ~]#

[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:999984
[root@mymongo1 ~]#

9、設定drbd角色,這裡設定mymongo1為主節點
[root@mymongo1 ~]# drbdadm -- --overwrite-data-of-peer primary data
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r---n-
ns:334220 nr:0 dw:0 dr:339075 al:8 bm:0 lo:0 pe:2 ua:5 ap:0 ep:1 wo:d oos:667184
[=====>..............] sync'ed: 33.9% (667184/999984)K
finish: 0:00:06 speed: 110,932 (110,932) K/sec
[root@mymongo1 ~]#
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
ns:0 nr:896000 dw:894976 dr:0 al:8 bm:0 lo:2 pe:5 ua:1 ap:0 ep:1 wo:d oos:105008
[================>...] sync'ed: 89.8% (105008/999984)K
finish: 0:00:00 speed: 99,440 (99,440) want: 102,400 K/sec
[root@arbiter ~]#

完成同步
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:999983 dw:999983 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]#
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:999983 nr:0 dw:0 dr:1000662 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#

10、2端機器建立相同的掛載點
[root@mymongo1 /]# mkdir data
[root@mymongo1 /]#

[root@arbiter /]# mkdir data
[root@arbiter /]#

11、格式化drbd0裝置(只在主節點)
[root@mymongo1 /]# mkfs.ext4 -b 4096 /dev/drbd0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
62592 inodes, 249995 blocks
12499 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
8 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@mymongo1 /]#
[root@mymongo1 /]# mount /dev/drbd0 /data
[root@mymongo1 /]# pwd
/
[root@mymongo1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 6.6G 9.9G 40% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
/dev/drbd0 946M 1.3M 896M 1% /data
[root@mymongo1 /]#

12、測試2端的資料同步
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1032457 nr:0 dw:32474 dr:1001355 al:19 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:1032457 dw:1032457 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]#

測試
[root@mymongo1 ~]# cp glib-2.22.5.tar /data/
[root@mymongo1 ~]#
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1032457 nr:0 dw:32474 dr:1001355 al:19 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1032457 nr:0 dw:32474 dr:1001363 al:19 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1032457 nr:0 dw:32474 dr:1001363 al:19 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1032485 nr:0 dw:32502 dr:1001363 al:19 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1072313 nr:0 dw:72330 dr:1001371 al:22 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1072325 nr:0 dw:72342 dr:1001371 al:22 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#

[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:1032457 dw:1032457 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:1032485 dw:1032485 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:1032485 dw:1032485 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:1072325 dw:1072325 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]#

備節點檢視
[root@arbiter ~]# drbdadm down data
[root@arbiter ~]# mount /dev/sdb1 /mnt
[root@arbiter ~]# cd /mnt
[root@arbiter mnt]# ll
total 39816
-rw-r--r--. 1 root root 40755200 Aug 24 01:53 glib-2.22.5.tar
drwx------ 2 root root 16384 Aug 24 01:50 lost+found
[root@arbiter mnt]#

備節點恢復
[root@arbiter ~]# drbdadm up data
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]#

二、heartbeat接管drbd服務資源
1、修改heartbeat的haresource配置檔案,2個節點相同
[root@mymongo1 ~]# cat /etc/ha.d/haresources
arbiter IPaddr::192.168.144.121/24/eth1 httpd

mymongo1 IPaddr::192.168.144.122/24/eth1 drbddisk::data Filesystem::/dev/drbd0::/data::ext4

#mysql master
#arbiter IPaddr::192.168.144.11/24/eth1 mysqld

#mysql salve
#mymongo1 IPaddr::192.168.144.12/24/eth1
[root@mymongo1 ~]#
2、重啟heartbeat服務
[root@mymongo1 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.

[root@mymongo1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
--檢視heartbeat的vip
[root@mymongo1 ~]# ip add|grep 192.168.144.122
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth1
[root@mymongo1 ~]#
--檢視drbd狀態
[root@mymongo1 ~]# ip add|grep 192.168.144.122
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth1
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:1072437 nr:8 dw:72462 dr:1002067 al:22 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#
--檢視drbd是否自動掛載
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 6.6G 9.9G 40% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
/dev/drbd0 946M 1.3M 896M 1% /data
[root@mymongo1 ~]#

arbiter節點處理
[root@arbiter ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.
[root@arbiter ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@arbiter ~]# ip add|grep 192.168.144.122
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:8 nr:112 dw:120 dr:696 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 8.3G 6.4G 57% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]#

3、heartbeat接管drbd資源的測試
--停止mymongo1的heartbeat模擬故障
[root@mymongo1 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.

[root@mymongo1 ~]#
--檢視備節點drbd服務目錄的接管
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:8 nr:112 dw:120 dr:696 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 8.3G 6.4G 57% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:12 nr:116 dw:128 dr:1392 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# ip add|grep 192.168.144.122
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth1
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 8.3G 6.4G 57% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
/dev/drbd0 946M 1.3M 896M 1% /data
[root@arbiter ~]#
--檢視主節點drbd服務目錄資源的釋放
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:1072441 nr:12 dw:72470 dr:1002067 al:22 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#
[root@mymongo1 ~]# ip add|grep 192.168.144.122
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 6.6G 9.9G 40% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
[root@mymongo1 ~]#
--從實驗看當主節點出故障後,heartbeat能夠自動接管drbd資源
--調整drbd、heartbeat不開機自動啟動,防止生產中資料破壞或資料不一致,首先人工處理
注意2節點最好對drbd、heartbeat不要自動啟動
[root@arbiter ~]# chkconfig heartbeat off
[root@arbiter ~]# chkconfig drbd off

[root@mymongo1 ~]# chkconfig heartbeat off
[root@mymongo1 ~]# chkconfig drbd off

--drbd重新連線資料
drbdadm connect data

heartbeat接管drbdadm的配置完成

三、在drbd的主節點(當前是mymongo1)初始化mysql資料庫
1、在drbd資料分割槽中安裝mysql資料庫
修改/data/mysql5.6的許可權宿主
[root@mymongo1 scripts]# chown -R mysql:mysql /data/mysql5.6/
[root@mymongo1 scripts]# chmod 775 /data/mysql5.6/
[root@mymongo1 scripts]#cd /application/mysql-5.6.36
[root@mymongo1 scripts]# pwd
/application/mysql/scripts
[root@mymongo1 scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/data/mysql5.6/data --user=mysql
2、修改mysql啟動控制檔案
[root@mymongo1 scripts]# cat /etc/my.cnf
[client]
port = 3306
socket =/data/mysql5.6/tmp/mysql.sock

[mysql]
no-auto-rehash

[mysqld]
datadir=/data/mysql5.6/data
socket=/data/mysql5.6/tmp/mysql.sock
user=mysql
port=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=/data/mysql5.6/mysql-bin
open_files_limit =1024
back_log = 600
max_connections = 800
max_connect_errors = 3000
#table_cache = 614
external-locking =FALSE
thread_stack =192k
#transaction_isolation=READ-COMMITTED
tmp_table_size =2M
max_heap_table_size=2M
long_query_time=1
pid-file =/data/mysql5.6/run/mysqld/mysql_mysqld.pid
relay-log =/data/mysql5.6/relay-bin
relay-log-info-file = /data/mysql5.6/relay-log.info
binlog_cache_size =1M
max_binlog_cache_size=1M
max_binlog_size=2M
expire_logs_days=7
key_buffer_size=16M
read_buffer_size =1M
read_rnd_buffer_size=1M
bulk_insert_buffer_size=1M
lower_case_table_names=1
skip-name-resolve
slave-skip-errors=1031,1062
replicate-ignore-db=mysql
server-id=1
innodb_additional_mem_pool_size=4M

[mysqld_safe]
log-error=/data/mysql5.6/log/mysql.log
pid-file=/data/mysql5.6/run/mysqld/mysqld.pid
[root@mymongo1 scripts]#

3、安裝資料庫
[root@mymongo1 scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/data/mysql5.6/data --user=mysql
Installing MySQL system tables...2017-08-24 23:14:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-24 23:14:36 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-08-24 23:14:36 0 [Note] /application/mysql/bin/mysqld (mysqld 5.6.36-log) starting as process 26813 ...
2017-08-24 23:14:36 7fbd0d5fd720 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2017-08-24 23:14:36 26813 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-08-24 23:14:36 26813 [Note] InnoDB: The InnoDB memory heap is disabled
2017-08-24 23:14:36 26813 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-24 23:14:36 26813 [Note] InnoDB: Memory barrier is not used
2017-08-24 23:14:36 26813 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-08-24 23:14:36 26813 [Note] InnoDB: Using CPU crc32 instructions
2017-08-24 23:14:36 26813 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-08-24 23:14:36 26813 [Note] InnoDB: Completed initialization of buffer pool
2017-08-24 23:14:36 26813 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-08-24 23:14:36 26813 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-08-24 23:14:36 26813 [Note] InnoDB: Database physically writes the file full: wait...
2017-08-24 23:14:36 26813 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-08-24 23:14:36 26813 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-08-24 23:14:36 26813 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-08-24 23:14:36 26813 [Warning] InnoDB: New log files created, LSN=45781
2017-08-24 23:14:36 26813 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-08-24 23:14:36 26813 [Note] InnoDB: Doublewrite buffer created
2017-08-24 23:14:36 26813 [Note] InnoDB: 128 rollback segment(s) are active.
2017-08-24 23:14:36 26813 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-24 23:14:36 26813 [Note] InnoDB: Foreign key constraint system tables created
2017-08-24 23:14:36 26813 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-08-24 23:14:36 26813 [Note] InnoDB: Tablespace and datafile system tables created.
2017-08-24 23:14:36 26813 [Note] InnoDB: Waiting for purge to start
2017-08-24 23:14:36 26813 [Note] InnoDB: 5.6.36 started; log sequence number 0
2017-08-24 23:14:37 26813 [Note] Binlog end
2017-08-24 23:14:37 26813 [Note] InnoDB: FTS optimize thread exiting.
2017-08-24 23:14:37 26813 [Note] InnoDB: Starting shutdown...
2017-08-24 23:14:38 26813 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2017-08-24 23:14:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-24 23:14:38 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-08-24 23:14:38 0 [Note] /application/mysql/bin/mysqld (mysqld 5.6.36-log) starting as process 26835 ...
2017-08-24 23:14:38 7f5a5b3cd720 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2017-08-24 23:14:38 26835 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-08-24 23:14:38 26835 [Note] InnoDB: The InnoDB memory heap is disabled
2017-08-24 23:14:38 26835 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-24 23:14:38 26835 [Note] InnoDB: Memory barrier is not used
2017-08-24 23:14:38 26835 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-08-24 23:14:38 26835 [Note] InnoDB: Using CPU crc32 instructions
2017-08-24 23:14:38 26835 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-08-24 23:14:38 26835 [Note] InnoDB: Completed initialization of buffer pool
2017-08-24 23:14:38 26835 [Note] InnoDB: Highest supported file format is Barracuda.
2017-08-24 23:14:38 26835 [Note] InnoDB: 128 rollback segment(s) are active.
2017-08-24 23:14:38 26835 [Note] InnoDB: Waiting for purge to start
2017-08-24 23:14:38 26835 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2017-08-24 23:14:38 26835 [Note] Binlog end
2017-08-24 23:14:38 26835 [Note] InnoDB: FTS optimize thread exiting.
2017-08-24 23:14:38 26835 [Note] InnoDB: Starting shutdown...
2017-08-24 23:14:39 26835 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h 192.168.144.132 password 'new-password'

Alternatively you can run:

/application/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; /application/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at

The latest information about MySQL is available on the web at


Support MySQL by buying support/licenses at

WARNING: Found existing config file /application/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /application/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@mymongo1 scripts]#

4、啟動資料庫
[root@mymongo1 log]# mkdir -p /data/mysql5.6/run/mysqld
[root@mymongo1 log]# chown -R mysql:mysql /data/mysql5.6/run/mysqld
[root@mymongo1 scripts]# mkdir /data/mysql5.6/tmp -p
[root@mymongo1 log]# chmod 755 /data/mysql5.6/run/mysqld
[root@mymongo1 scripts]# chown -R mysql:mysql /data/mysql5.6/tmp
[root@mymongo1 scripts]# mkdir -p /data/mysql5.6/log/
[root@mymongo1 scripts]# chown mysql:mysql /data/mysql5.6/log/
[root@mymongo1 scripts]# chmod 775 /data/mysql5.6/log/ -R
[root@mymongo1 scripts]# touch /data/mysql5.6/log/mysql.log
[root@mymongo1 log]# chown mysql:mysql /data/mysql5.6/log/mysql.log
[root@mymongo1 scripts]# ps -ef|grep mysql
root 26877 20324 0 23:18 pts/2 00:00:00 grep mysql
[root@mymongo1 scripts]# cd ..
[root@mymongo1 log]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@mymongo1 log]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye
[root@mymongo1 log]#
--主節點停止mysql,到備節點啟動mysql
[root@arbiter ~]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[root@arbiter ~]# ps -ef|grep mysql
root 5344 1 0 01:13 pts/2 00:00:00 /bin/sh /application/mysql-5.6/bin/mysqld_safe --datadir=/data/mysql5.6/data --pid-file=/data/mysql5.6/run/mysqld/mysql_mysqld.pid
mysql 5860 5344 8 01:13 pts/2 00:00:01 /application/mysql-5.6/bin/mysqld --basedir=/application/mysql-5.6 --datadir=/data/mysql5.6/data --plugin-dir=/application/mysql-5.6/lib/plugin --user=mysql --log-error=/data/mysql5.6/log/mysql.log --open-files-limit=1024 --pid-file=/data/mysql5.6/run/mysqld/mysql_mysqld.pid --socket=/data/mysql5.6/tmp/mysql.sock --port=3306
root 5893 4987 0 01:13 pts/2 00:00:00 grep mysql
[root@arbiter ~]# netstat -antup|grep 33
tcp 0 0 :::3306 :::* LISTEN 5860/mysqld
tcp 0 0 :::11733 :::* LISTEN 1983/rpc.statd
[root@arbiter ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye
[root@arbiter ~]#

5、修改2個節點的heartbeat的資源配置檔案haresources
[root@mymongo1 ~]# cat /etc/ha.d/haresources
arbiter IPaddr::192.168.144.121/24/eth1 httpd

mymongo1 IPaddr::192.168.144.122/24/eth1 drbddisk::data Filesystem::/dev/drbd0::/data::ext4 mysqld

#mysql master
#arbiter IPaddr::192.168.144.11/24/eth1 mysqld

#mysql salve
#mymongo1 IPaddr::192.168.144.12/24/eth1
[root@mymongo1 ~]#

6、啟動heartbeat
[root@mymongo1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@mymongo1 ~]#

[root@arbiter ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@arbiter ~]#

7、檢視狀態
--drbd的同步狀態
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:2333919 nr:0 dw:1333936 dr:1011915 al:190 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]#
--drbd的儲存掛載
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 9.8G 6.8G 60% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
/dev/drbd0 946M 113M 784M 13% /data
[root@mymongo1 ~]#
--heartbeat高可用的虛擬IP的狀態
[root@mymongo1 ~]# ip add|grep 192.168.144.122
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth1
--mysql的3306埠的狀態
[root@mymongo1 ~]# ss -antup|grep 33
tcp LISTEN 0 128 127.0.0.1:6013 *:* users:(("sshd",3306,23))
tcp LISTEN 0 128 ::1:6013 :::* users:(("sshd",3306,20))
tcp LISTEN 0 128 :::3306 :::* users:(("mysqld",26363,17))
tcp LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",3306,8))
tcp LISTEN 0 128 ::1:6010 :::* users:(("sshd",3306,7))
tcp LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",3306,13))
tcp LISTEN 0 128 ::1:6011 :::* users:(("sshd",3306,10))
tcp LISTEN 0 128 127.0.0.1:6012 *:* users:(("sshd",3306,18))
tcp LISTEN 0 128 ::1:6012 :::* users:(("sshd",3306,15))
tcp ESTAB 0 0 192.168.144.132:22 192.168.144.1:49249 users:(("sshd",3306,3))
--mysql登入測試-主節點
[root@mymongo1 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
[root@mymongo1 ~]#
--對端節點arbir
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 9.3G 5.4G 64% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:464 dw:464 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# ip add |grep 192.168.144.122
[root@arbiter ~]# ss -antup|grep 3306
[root@arbiter ~]#

8、heartbeat的資源切換接管測試
--當前主節點停止heartbeart
[root@mymongo1 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.

[root@mymongo1 ~]#
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 9.8G 6.8G 60% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
[root@mymongo1 ~]# ip add|grep 192.168.144.122
[root@mymongo1 ~]# ps -ef|grep mysql
root 27156 3962 0 01:28 pts/2 00:00:00 grep mysql
[root@mymongo1 ~]#
--有程式在,好奇怪
[root@mymongo1 ~]# netstat -antup|grep 3306
tcp 0 0 127.0.0.1:6013 0.0.0.0:* LISTEN 3306/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3306/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 3306/sshd
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN 3306/sshd
tcp 0 52 192.168.144.132:22 192.168.144.1:49249 ESTABLISHED 3306/sshd
tcp 0 0 ::1:6013 :::* LISTEN 3306/sshd
tcp 0 0 ::1:6010 :::* LISTEN 3306/sshd
tcp 0 0 ::1:6011 :::* LISTEN 3306/sshd
tcp 0 0 ::1:6012 :::* LISTEN 3306/sshd
[root@mymongo1 ~]#
--備節點檢視drbd服務目錄、mysql服務的接管情況
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:456 nr:656 dw:1112 dr:7028 al:6 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 9.3G 5.4G 64% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
/dev/drbd0 946M 113M 784M 13% /data
[root@arbiter ~]# ss -antup|grep 3306
tcp LISTEN 0 128 :::3306 :::* users:(("mysqld",8356,17))
[root@arbiter ~]#
[root@arbiter ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye
[root@arbiter ~]#

--測試heartbeat-drbd-mysql配合下mysql的資料同步
[root@arbiter ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.36-log Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zhulei;
Query OK, 1 row affected (0.00 sec)
mysql> use zhulei
Database changed
mysql> create table tt(id int,name varchar(15));
Query OK, 0 rows affected (0.06 sec)
mysql> insert into tt values(1,'zhulei');
Query OK, 1 row affected (0.01 sec)
mysql> select * from tt;
+------+--------+
| id | name |
+------+--------+
| 1 | zhulei |
+------+--------+
1 row in set (0.01 sec)
mysql> quit
Bye
[root@arbiter ~]#
--在mymongo1啟動heartbeat
[root@mymongo1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@mymongo1 ~]#
--檢視mymongo1的資源狀態
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:2334487 nr:2032 dw:1336536 dr:1019079 al:190 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 9.8G 6.8G 60% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
/dev/drbd0 946M 114M 784M 13% /data
[root@mymongo1 ~]# ip add|grep 192.168.144.122
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth1
[root@mymongo1 ~]# ss -antup|grep 3306
tcp LISTEN 0 128 127.0.0.1:6013 *:* users:(("sshd",3306,23))
tcp LISTEN 0 128 ::1:6013 :::* users:(("sshd",3306,20))
tcp LISTEN 0 128 :::3306 :::* users:(("mysqld",28610,18))
tcp LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",3306,8))
tcp LISTEN 0 128 ::1:6010 :::* users:(("sshd",3306,7))
tcp LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",3306,13))
tcp LISTEN 0 128 ::1:6011 :::* users:(("sshd",3306,10))
tcp LISTEN 0 128 127.0.0.1:6012 *:* users:(("sshd",3306,18))
tcp LISTEN 0 128 ::1:6012 :::* users:(("sshd",3306,15))
tcp ESTAB 0 120 192.168.144.132:22 192.168.144.1:49249 users:(("sshd",3306,3))
[root@mymongo1 ~]# ps -ef|grep mysql
root 28093 1 0 01:33 ? 00:00:00 /bin/sh /application/mysql-5.6/bin/mysqld_safe --datadir=/data/mysql5.6/data --pid-file=/data/mysql5.6/run/mysqld/mysql_mysqld.pid
mysql 28610 28093 1 01:33 ? 00:00:00 /application/mysql-5.6/bin/mysqld --basedir=/application/mysql-5.6 --datadir=/data/mysql5.6/data --plugin-dir=/application/mysql-5.6/lib/plugin --user=mysql --log-error=/data/mysql5.6/log/mysql.log --open-files-limit=1024 --pid-file=/data/mysql5.6/run/mysqld/mysql_mysqld.pid --socket=/data/mysql5.6/tmp/mysql.sock --port=3306
root 28672 5393 0 01:34 pts/3 00:00:00 grep mysql
[root@mymongo1 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zhulei |
+--------------------+
5 rows in set (0.01 sec)

mysql> use zhulei;
Database changed
mysql> show tables;
+------------------+
| Tables_in_zhulei |
+------------------+
| tt |
+------------------+
1 row in set (0.00 sec)

mysql> select * from tt;
+------+--------+
| id | name |
+------+--------+
| 1 | zhulei |
+------+--------+
1 row in set (0.02 sec)

mysql> quit
Bye
[root@mymongo1 ~]#

--節點arbiter的資源釋放情況
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:2032 nr:1180 dw:3212 dr:7220 al:9 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 9.3G 5.4G 64% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]# ip add|grep 192.168.144.122
[root@arbiter ~]# ps -ef|grep mysql
root 9105 4987 0 01:36 pts/2 00:00:00 grep mysql
[root@arbiter ~]# ss -antup|grep 3306
[root@arbiter ~]# netstat -antup|grep 3306
[root@arbiter ~]#
到此,實驗完成!

附錄:
正常停止Mysql-drbd-hearbeart
無資源節點先停止heartbeat
[root@arbiter ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.
[root@arbiter ~]#
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:2032 nr:1180 dw:3212 dr:7220 al:9 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 9.3G 5.4G 64% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]# ip add|grep 192.168.144.122
[root@arbiter ~]# ps -ef|grep mysql
root 9105 4987 0 01:36 pts/2 00:00:00 grep mysql
[root@arbiter ~]# ss -antup|grep 3306
[root@arbiter ~]# netstat -antup|grep 3306
[root@arbiter ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
ns:2032 nr:1388 dw:3420 dr:7220 al:9 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@arbiter ~]# ss -antup|grep 3306
[root@arbiter ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 9.3G 5.4G 64% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 59M 210M 22% /boot
[root@arbiter ~]#
資源節點停止heartbeat
[root@mymongo1 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.
[root@mymongo1 ~]#
[root@mymongo1 ~]# cat /proc/drbd
version: 8.4.9-1 (api:1/proto:86-101)
GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:15
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
ns:2334859 nr:2032 dw:1336908 dr:1019395 al:190 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
[root@mymongo1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 9.8G 6.8G 60% /
tmpfs 935M 72K 935M 1% /dev/shm
/dev/sda1 283M 39M 229M 15% /boot
[root@mymongo1 ~]# ip add|grep 192.168.144.122
[root@mymongo1 ~]# ss -antup|grep 3306
tcp LISTEN 0 128 127.0.0.1:6013 *:* users:(("sshd",3306,23))
tcp LISTEN 0 128 ::1:6013 :::* users:(("sshd",3306,20))
tcp LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",3306,8))
tcp LISTEN 0 128 ::1:6010 :::* users:(("sshd",3306,7))
tcp LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",3306,13))
tcp LISTEN 0 128 ::1:6011 :::* users:(("sshd",3306,10))
tcp LISTEN 0 128 127.0.0.1:6012 *:* users:(("sshd",3306,18))
tcp LISTEN 0 128 ::1:6012 :::* users:(("sshd",3306,15))
tcp ESTAB 0 52 192.168.144.132:22 192.168.144.1:49249 users:(("sshd",3306,3))
[root@mymongo1 ~]#
[root@mymongo1 ~]# /etc/init.d/drbd stop
Stopping all DRBD resources: .
[root@mymongo1 ~]#

[root@arbiter ~]# /etc/init.d/drbd stop
Stopping all DRBD resources: .
[root@arbiter ~]#

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29357786/viewspace-2144465/,如需轉載,請註明出處,否則將追究法律責任。

相關文章