heartbeat 3.0.4-drbd 8.9-MySQL5.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
eth2:192.168.144.132
eth2:192.168.144.111
DRBD存储设备
/dev/sdb1
/dev/sdb1
DRBD META设备
/dev/sdb2 [0]
/dev/sdb2 [0]
虚拟IP
eth2:192.168.144.122
eth2:192.168.144.122





1、两台vmware linux 虚拟机arbiter和mymongo1(两台主机需要新添加虚拟硬盘sdb),基本信息mymongo1[root@mymongo1 ~]# hostnamemymongo1[root@mymongo1 ~]# uname -aLinux 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 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00061eae
Device Boot Start End Blocks Id System/dev/sda1 * 1 39 307200 83 LinuxPartition 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-releaseCentOS release 6.8 (Final)[root@mymongo1 ~]#
arbiter[root@arbiter ~]# uname -aLinux 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 ~]# hostnamearbiter[root@arbiter ~]# cat /etc/redhat-releaseRed Hat Enterprise Linux Server release 6.4 (Santiago)[root@arbiter ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00078b06
Device Boot Start End Blocks Id System/dev/sda1 * 1 39 307200 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 39 549 4096000 82 Linux swap / SolarisPartition 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 gptInformation: 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? IgnoreInformation: You may need to update /etc/fstab.[root@mymongo1 ~]# parted /dev/sdb pModel: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 2147MBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags1 17.4kB 1024MB 1024MB primary2 1025MB 2146MB 1121MB primary[root@mymongo1 ~]#
[root@arbiter ~]# parted /dev/sdb mkpart primary 0 1024Warning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? IgnoreInformation: You may need to update /etc/fstab.[root@arbiter ~]# parted /dev/sdb mkpart primary 1025 2146Warning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? IgnoreInformation: You may need to update /etc/fstab.[root@arbiter ~]# parted /dev/sdb pModel: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 2147MBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags1 17.4kB 1024MB 1024MB primary2 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-- http://ftp.scientificlinux.org/linux/scientific/6.9/x86_64/os/Packages/elrepo-release-6-6.el6.elrepo.noarch.rpmResolving ftp.scientificlinux.org... 131.225.105.11Connecting to ftp.scientificlinux.org|131.225.105.11|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 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 ~]# lsanaconda-ks.cfg Documents heartbeat mysql-5.6.36 Public testcmake-2.8.10.2 Downloads install.log mysql-5.6.36.tar rpms Videoscmake-2.8.10.2.tar elrepo-release-6-6.el6.elrepo.noarch.rpm install.log.syslog Pictures selectDesktop epel-release-6-8.noarch.rpm Music pkg Templates[root@arbiter ~]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpmwarning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEYPreparing... ########################################### [100%]1:elrepo-release ########################################### [100%][root@arbiter ~]#[root@arbiter ~]# lsanaconda-ks.cfg Downloads install.log mysql-5.6.36.tar selectcmake-2.8.10.2 drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm install.log.syslog Pictures Templatescmake-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 testDesktop epel-release-6-8.noarch.rpm Music Public VideosDocuments heartbeat mysql-5.6.36 rpms[root@arbiter ~]# rpm -ivh drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpmwarning: drbd84-utils-8.9.8-1.el6.elrepo.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEYPreparing... ########################################### [100%]1:drbd84-utils ########################################### [100%][root@arbiter ~]#[root@arbiter yum.repos.d]# lselrepo.repo epel-testing.repo local.repo[root@arbiter yum.repos.d]#[root@arbiter yum.repos.d]# cat local.repo [local]name = localbaseurl=file:///mnt/enabled = 1gpgcheck = 0gpgkey =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-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.elrepo | 2.9 kB 00:00elrepo/primary_db | 692 kB 00:12Setting up Install ProcessExamining kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64Marking kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm to be installedResolving 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 ResolutionError: 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) = 0x4b1a6158Error: 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) = 0xabd7b07bYou 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.rpmLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.elrepo | 2.9 kB 00:00elrepo/primary_db | 692 kB 00:10local | 4.0 kB 00:00 ...local/primary_db | 4.7 MB 00:00 ...Setting up Install ProcessExamining kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm: kmod-drbd84-8.4.9-1.el6.elrepo.x86_64Marking kmod-drbd84-8.4.9-1.el6.elrepo.x86_64.rpm to be installedResolving 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 kUpdating:bfa-firmware noarch 3.2.23.0-2.el6 local 3.2 MInstalling for dependencies:kernel x86_64 2.6.32-642.el6 local 32 MUpdating for dependencies:dracut noarch 004-409.el6 local 127 kdracut-kernel noarch 004-409.el6 local 28 kkernel-firmware noarch 2.6.32-642.el6 local 28 M
Transaction Summary===============================================================================================================================================Install 2 Package(s)Upgrade 4 Package(s)
Total size: 64 MTotal download size: 63 MDownloading Packages:-----------------------------------------------------------------------------------------------------------------------------------------------Total 93 MB/s | 63 MB 00:00Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: 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-libsUpdating : kernel-firmware-2.6.32-642.el6.noarch 1/10Updating : dracut-004-409.el6.noarch 2/10Updating : dracut-kernel-004-409.el6.noarch 3/10Installing : kernel-2.6.32-642.el6.x86_64 4/10Installing : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 5/10Working. This may take some time ...Done.Updating : bfa-firmware-3.2.23.0-2.el6.noarch 6/10Cleanup : dracut-kernel-004-303.el6.noarch 7/10Cleanup : dracut-004-303.el6.noarch 8/10Cleanup : kernel-firmware-2.6.32-358.el6.noarch 9/10Cleanup : bfa-firmware-3.0.3.1-1.el6.noarch 10/10Verifying : dracut-kernel-004-409.el6.noarch 1/10Verifying : dracut-004-409.el6.noarch 2/10Verifying : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 3/10Verifying : bfa-firmware-3.2.23.0-2.el6.noarch 4/10Verifying : kernel-firmware-2.6.32-642.el6.noarch 5/10Verifying : kernel-2.6.32-642.el6.x86_64 6/10Verifying : dracut-kernel-004-303.el6.noarch 7/10Verifying : dracut-004-303.el6.noarch 8/10Verifying : kernel-firmware-2.6.32-358.el6.noarch 9/10Verifying : 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-- http://ftp.scientificlinux.org/linux/scientific/6.9/x86_64/os/Packages/elrepo-release-6-6.el6.elrepo.noarch.rpmResolving ftp.scientificlinux.org... 131.225.105.11Connecting to ftp.scientificlinux.org|131.225.105.11|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 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]# lselrepo-release-6-6.el6.elrepo.noarch.rpm[root@mymongo1 drbd]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpmwarning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEYPreparing... ########################################### [100%]1:elrepo-release ########################################### [100%][root@mymongo1 drbd]#[root@mymongo1 drbd]# rpm -ivh elrepo-release-6-6.el6.elrepo.noarch.rpmwarning: elrepo-release-6-6.el6.elrepo.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEYPreparing... ########################################### [100%]1:elrepo-release ########################################### [100%][root@mymongo1 drbd]# yum install drbd kmod-drbd84 -yLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Install ProcessLoading mirror speeds from cached hostfileepel/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.cnbase | 3.7 kB 00:00elrepo | 2.9 kB 00:00elrepo/primary_db | 692 kB 00:27epel | 4.3 kB 00:00epel/primary_db | 5.9 MB 03:04extras | 3.4 kB 00:00updates | 3.4 kB 00:00http://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/repodata/2b0cc62da054bcf7c883b783de2de48c2372b9e502074246f7e0b046336f123d-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/repodata/2b0cc62da054bcf7c883b783de2de48c2372b9e502074246f7e0b046336f123d-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')Trying other mirror.updates/primary_db | 3.1 MB 00:00Resolving 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 kkmod-drbd84 x86_64 8.4.9-1.el6.elrepo elrepo 198 k
Transaction Summary===================================================================================================================================Install 2 Package(s)
Total download size: 590 kInstalled size: 1.7 MDownloading 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:31warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEYRetrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.orgImporting 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.orgRunning rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: 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-libsInstalling : drbd84-utils-8.9.8-1.el6.elrepo.x86_64 1/2Installing : kmod-drbd84-8.4.9-1.el6.elrepo.x86_64 2/2Working. This may take some time ...Done.Verifying : drbd84-utils-8.9.8-1.el6.elrepo.x86_64 1/2Verifying : 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 drbdkmod-drbd84-8.4.9-1.el6.elrepo.x86_64drbd84-utils-8.9.8-1.el6.elrepo.x86_64[root@arbiter ~]#[root@mymongo1 ~]# rpm -qa|grep drbddrbd84-utils-8.9.8-1.el6.elrepo.x86_64kmod-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 drbddrbd 374888 0libcrc32c 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 drbddrbd 374888 0libcrc32c 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 datainitializing activity logNOT initializing bitmapWriting meta data...New drbd meta data block successfully created.[root@mymongo1 ~]# cat /etc/drbd.confglobal{#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 msmax-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 logNOT initializing bitmapWriting meta data...New drbd meta data block successfully created.[root@mymongo1 ~]#[root@arbiter ~]# drbdadm create-md data initializing activity logNOT initializing bitmapWriting 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:150: cs:WFConnection ro:Secondary/Unknown ds:Inconsistent/DUnknown C r----sns: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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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)Kfinish: 0:00:06 speed: 110,932 (110,932) K/sec[root@mymongo1 ~]#[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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)Kfinish: 0:00:00 speed: 99,440 (99,440) want: 102,400 K/sec[root@arbiter ~]#
完成同步[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks62592 inodes, 249995 blocks12499 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=2600468488 block groups32768 blocks per group, 32768 fragments per group7824 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376
Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or180 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 -hFilesystem 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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]# lltotal 39816-rw-r--r--. 1 root root 40755200 Aug 24 01:53 glib-2.22.5.tardrwx------ 2 root root 16384 Aug 24 01:50 lost+found[root@arbiter mnt]#
备节点恢复[root@arbiter ~]# drbdadm up data[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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/haresourcesarbiter IPaddr::192.168.144.121/24/eth2 httpd
mymongo1 IPaddr::192.168.144.122/24/eth2 drbddisk::data Filesystem::/dev/drbd0::/data::ext4
#mysql master#arbiter IPaddr::192.168.144.11/24/eth2 mysqld
#mysql salve#mymongo1 IPaddr::192.168.144.12/24/eth2[root@mymongo1 ~]#2、重启heartbeat服务[root@mymongo1 ~]# /etc/init.d/heartbeat stopStopping High-Availability services: Done.
[root@mymongo1 ~]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.--查看heartbeat的vip[root@mymongo1 ~]# ip add|grep 192.168.144.122inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2[root@mymongo1 ~]#--查看drbd状态[root@mymongo1 ~]# ip add|grep 192.168.144.122inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2[root@mymongo1 ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 stopStopping High-Availability services: Done.[root@arbiter ~]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.[root@arbiter ~]# ip add|grep 192.168.144.122[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 stopStopping High-Availability services: Done.
[root@mymongo1 ~]#--查看备节点drbd服务目录的接管[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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.122inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2[root@arbiter ~]# df -hFilesystem 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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=mysql2、修改mysql启动控制文件[root@mymongo1 scripts]# cat /etc/my.cnf[client]port = 3306socket =/data/mysql5.6/tmp/mysql.sock
[mysql]no-auto-rehash
[mysqld]datadir=/data/mysql5.6/data socket=/data/mysql5.6/tmp/mysql.sockuser=mysqlport=3306# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-bin=/data/mysql5.6/mysql-binopen_files_limit =1024back_log = 600max_connections = 800max_connect_errors = 3000#table_cache = 614external-locking =FALSEthread_stack =192k#transaction_isolation=READ-COMMITTEDtmp_table_size =2Mmax_heap_table_size=2Mlong_query_time=1pid-file =/data/mysql5.6/run/mysqld/mysql_mysqld.pidrelay-log =/data/mysql5.6/relay-bin relay-log-info-file = /data/mysql5.6/relay-log.info binlog_cache_size =1Mmax_binlog_cache_size=1Mmax_binlog_size=2Mexpire_logs_days=7key_buffer_size=16Mread_buffer_size =1Mread_rnd_buffer_size=1Mbulk_insert_buffer_size=1Mlower_case_table_names=1skip-name-resolveslave-skip-errors=1031,1062replicate-ignore-db=mysqlserver-id=1innodb_additional_mem_pool_size=4M
[mysqld_safe]log-error=/data/mysql5.6/log/mysql.logpid-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=mysqlInstalling 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 pages2017-08-24 23:14:36 26813 [Note] InnoDB: The InnoDB memory heap is disabled2017-08-24 23:14:36 26813 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2017-08-24 23:14:36 26813 [Note] InnoDB: Memory barrier is not used2017-08-24 23:14:36 26813 [Note] InnoDB: Compressed tables use zlib 1.2.32017-08-24 23:14:36 26813 [Note] InnoDB: Using CPU crc32 instructions2017-08-24 23:14:36 26813 [Note] InnoDB: Initializing buffer pool, size = 128.0M2017-08-24 23:14:36 26813 [Note] InnoDB: Completed initialization of buffer pool2017-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 MB2017-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 MB2017-08-24 23:14:36 26813 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2017-08-24 23:14:36 26813 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02017-08-24 23:14:36 26813 [Warning] InnoDB: New log files created, LSN=457812017-08-24 23:14:36 26813 [Note] InnoDB: Doublewrite buffer not found: creating new2017-08-24 23:14:36 26813 [Note] InnoDB: Doublewrite buffer created2017-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 created2017-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 start2017-08-24 23:14:36 26813 [Note] InnoDB: 5.6.36 started; log sequence number 02017-08-24 23:14:37 26813 [Note] Binlog end2017-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 1625977OK
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 pages2017-08-24 23:14:38 26835 [Note] InnoDB: The InnoDB memory heap is disabled2017-08-24 23:14:38 26835 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2017-08-24 23:14:38 26835 [Note] InnoDB: Memory barrier is not used2017-08-24 23:14:38 26835 [Note] InnoDB: Compressed tables use zlib 1.2.32017-08-24 23:14:38 26835 [Note] InnoDB: Using CPU crc32 instructions2017-08-24 23:14:38 26835 [Note] InnoDB: Initializing buffer pool, size = 128.0M2017-08-24 23:14:38 26835 [Note] InnoDB: Completed initialization of buffer pool2017-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 start2017-08-24 23:14:38 26835 [Note] InnoDB: 5.6.36 started; log sequence number 16259772017-08-24 23:14:38 26835 [Note] Binlog end2017-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 1625987OK
To start mysqld at boot time you have to copysupport-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 testdatabases and anonymous user created by default. This isstrongly 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 http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
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 systemThis file will be read by default by the MySQL serverIf 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 mysqlroot 26877 20324 0 23:18 pts/2 00:00:00 grep mysql[root@mymongo1 scripts]# cd ..[root@mymongo1 log]# /etc/init.d/mysqld startStarting MySQL. SUCCESS![root@mymongo1 log]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quitBye[root@mymongo1 log]#--主节点停止mysql,到备节点启动mysql[root@arbiter ~]# /etc/init.d/mysqld startStarting MySQL.. SUCCESS![root@arbiter ~]# ps -ef|grep mysqlroot 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.pidmysql 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=3306root 5893 4987 0 01:13 pts/2 00:00:00 grep mysql[root@arbiter ~]# netstat -antup|grep 33tcp 0 0 :::3306 :::* LISTEN 5860/mysqldtcp 0 0 :::11733 :::* LISTEN 1983/rpc.statd[root@arbiter ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quitBye[root@arbiter ~]#
5、修改2个节点的heartbeat的资源配置文件haresources[root@mymongo1 ~]# cat /etc/ha.d/haresourcesarbiter IPaddr::192.168.144.121/24/eth2 httpd
mymongo1 IPaddr::192.168.144.122/24/eth2 drbddisk::data Filesystem::/dev/drbd0::/data::ext4 mysqld
#mysql master#arbiter IPaddr::192.168.144.11/24/eth2 mysqld
#mysql salve#mymongo1 IPaddr::192.168.144.12/24/eth2[root@mymongo1 ~]#
6、启动heartbeat[root@mymongo1 ~]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.[root@mymongo1 ~]#
[root@arbiter ~]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.[root@arbiter ~]#
7、查看状态--drbd的同步状态[root@mymongo1 ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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.122inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2--mysql的3306端口的状态[root@mymongo1 ~]# ss -antup|grep 33tcp 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 ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>[root@mymongo1 ~]#--对端节点arbir[root@arbiter ~]# df -hFilesystem 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 stopStopping High-Availability services: Done.
[root@mymongo1 ~]#[root@mymongo1 ~]# df -hFilesystem 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 mysqlroot 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quitBye[root@arbiter ~]#
--测试heartbeat-drbd-mysql配合下mysql的数据同步[root@arbiter ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.36-log Source distributionCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 zhuleiDatabase changedmysql> 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> quitBye[root@arbiter ~]#--在mymongo1启动heartbeat[root@mymongo1 ~]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.[root@mymongo1 ~]#--查看mymongo1的资源状态[root@mymongo1 ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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.122inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2[root@mymongo1 ~]# ss -antup|grep 3306tcp 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 mysqlroot 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.pidmysql 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=3306root 28672 5393 0 01:34 pts/3 00:00:00 grep mysql[root@mymongo1 ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.
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 changedmysql> 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> quitBye[root@mymongo1 ~]#
--节点arbiter的资源释放情况[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 mysqlroot 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 stopStopping High-Availability services: Done.[root@arbiter ~]#[root@arbiter ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 mysqlroot 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/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 stopStopping High-Availability services: Done.[root@mymongo1 ~]#[root@mymongo1 ~]# cat /proc/drbdversion: 8.4.9-1 (api:1/proto:86-101)GIT-hash: 9976da086367a2476503ef7f6b13d4567327a280 build by mockbuild@Build64R6, 2016-12-13 18:38:150: 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 -hFilesystem 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 3306tcp 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 stopStopping all DRBD resources: .[root@mymongo1 ~]#
[root@arbiter ~]# /etc/init.d/drbd stopStopping all DRBD resources: .[root@arbiter ~]#