亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux-ha heartbeat高可用的安裝配置(http服務高可用)

發布時間:2020-08-09 10:21:48 來源:ITPUB博客 閱讀:214 作者:清風艾艾 欄目:建站服務器
    heartbeat工作原理:本次實驗,使用廣播地址225.0.0.11 694作為heartbeat的網絡心跳地址,heartbeat通過網絡心跳監測對端服務是否正常,
通過/etc/ha.d/ha.cf 文件的deadtime參數判斷對端服務中斷,通過參數auto_failback參數控制資源失敗自動接管,從而完成httpd服務的雙機互備。
兩臺主機(一臺是rhel6.4 arbiter,一臺是centos6.8 mymongo1)
一、兩臺主機的基本信息,重點是hosts文件的IP地址主機名解析
[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 ~]# hostname
mymongo1
[root@mymongo1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.144.111 arbiter
192.168.144.132 mymongo1
[root@mymongo1 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:40:94:8E
inet addr:192.168.199.131 Bcast:192.168.199.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe40:948e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4219 (4.1 KiB) TX bytes:3299 (3.2 KiB)
eth2 Link encap:Ethernet HWaddr 00:0C:29:40:94:98
inet addr:192.168.144.132 Bcast:192.168.144.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe40:9498/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1890 errors:0 dropped:0 overruns:0 frame:0
TX packets:1800 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:253127 (247.1 KiB) TX bytes:252326 (246.4 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:576 (576.0 b) TX bytes:576 (576.0 b)
[root@mymongo1 ~]#

[root@arbiter ~]# hostname
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 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.144.111 arbiter
192.168.144.132 mymongo1
[root@arbiter ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:50:56:3E:FE:CF
inet addr:192.168.199.128 Bcast:192.168.199.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe3e:fecf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:85 errors:0 dropped:0 overruns:0 frame:0
TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9437 (9.2 KiB) TX bytes:2719 (2.6 KiB)
eth2 Link encap:Ethernet HWaddr 00:50:56:21:CF:3E
inet addr:192.168.144.111 Bcast:192.168.144.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe21:cf3e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2992 errors:0 dropped:0 overruns:0 frame:0
TX packets:3054 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:348131 (339.9 KiB) TX bytes:423727 (413.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
[root@arbiter ~]#

二、heartbeat的安裝,rhel和centos安裝不一樣,先安裝centos機器的heartbeat
注意:最少保證2臺主機中的centos主機能夠上網,centos安裝Heartbeats,通過yum方式網絡安裝
1、首先下載epel-release-6-8.noarch.rpm
wget http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@mymongo1 ~]# ls
amoeba Documents install.log mysql-5.6.36.tar.gz Pictures Videos
anaconda-ks.cfg Downloads install.log.syslog mysql-proxy-0.8.2 Public
arbiter epel-release-6-8.noarch.rpm lua-5.1.4 mysql-proxy-0.8.2.tar.gz Templates
cmake-2.8.10.2.tar.gz glib-2.22.5 lua-5.1.4.tar.gz mysql-proxy-0.8.5 test1.sh
Desktop glib-2.22.5.tar Music mysql-proxy-0.8.5.tar.gz test.sh
[root@mymongo1 ~]#
--安裝epel,其實是安裝yum源
rpm -ivh epel-release-6-8.noarch.rpm
[root@mymongo1 yum.repos.d]# pwd
/etc/yum.repos.d
[root@mymongo1 yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo epel.repo epel-testing.repo
[root@mymongo1 yum.repos.d]#
[root@mymongo1 yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
[root@mymongo1 yum.repos.d]#
[root@mymongo1 yum.repos.d]# cat epel-testing.repo
[epel-testing]
name=Extra Packages for Enterprise Linux 6 - Testing - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/testing/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-testing-debuginfo]
name=Extra Packages for Enterprise Linux 6 - Testing - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/testing/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-testing-source]
name=Extra Packages for Enterprise Linux 6 - Testing - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/testing/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
[root@mymongo1 yum.repos.d]#
--調整yum的配置文件,緩存本次heartbeat安裝需要的依賴包
[root@mymongo1 etc]# cat yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
[root@mymongo1 etc]#
--使用yum工具安裝heartbeat
yum -y install heartbeat
安裝完成后heartbeat的緩存目錄
[root@mymongo1 ~]# find / -name heartbeat*.rpm
/var/cache/yum/x86_64/6/epel/packages/heartbeat-3.0.4-2.el6.x86_64.rpm
/var/cache/yum/x86_64/6/epel/packages/heartbeat-libs-3.0.4-2.el6.x86_64.rpm
[root@mymongo1 ~]#
[root@mymongo1 ~]# cd /var/cache/yum/x86_64/6/base/packages/
[root@mymongo1 packages]# ll
total 2060
-rw-r--r--. 1 root root 66344 Jul 24 2015 cifs-utils-4.8.1-20.el6.x86_64.rpm
-rw-r--r--. 1 root root 72744 Jun 24 2012 cluster-glue-1.0.5-6.el6.x86_64.rpm
-rw-r--r--. 1 root root 119096 Jun 24 2012 cluster-glue-libs-1.0.5-6.el6.x86_64.rpm
-rw-r--r--. 1 root root 40152 Oct 17 2014 keyutils-1.4-5.el6.x86_64.rpm
-rw-r--r--. 1 root root 23488 Sep 25 2011 libgssglue-0.1-11.el6.x86_64.rpm
-rw-r--r--. 1 root root 343900 Mar 23 08:00 nfs-utils-1.2.3-75.el6.x86_64.rpm
-rw-r--r--. 1 root root 72268 Mar 23 08:02 nfs-utils-lib-1.1.5-13.el6.x86_64.rpm
-rw-r--r--. 1 root root 38264 Oct 17 2014 perl-TimeDate-1.16-13.el6.noarch.rpm
-rw-r--r--. 1 root root 913840 Jul 2 2011 PyXML-0.8.4-19.el6.x86_64.rpm
-rw-r--r--. 1 root root 398016 Mar 24 06:25 resource-agents-3.9.5-46.el6.x86_64.rpm
[root@mymongo1 packages]#

2、在rhel機器上arbiter安裝heartbeat,方法是將centos機器mymongo1上的heartbeat包及其依賴包scp到arbiter機器上,
使用rpm -ivh方式安裝,安裝過程(安裝過程中需要其他依賴的rpm包,可以掛載centos cd1鏡像到arbiter上找到安裝即可):
[root@arbiter heartbeat]# ls
cifs-utils-4.8.1-20.el6.x86_64.rpm keyutils-libs-1.4-5.el6.x86_64.rpm perl-TimeDate-1.16-13.el6.noarch.rpm
cluster-glue-1.0.5-6.el6.x86_64.rpm libevent-1.4.13-4.el6.x86_64.rpm python-argparse-1.2.1-2.1.el6.noarch.rpm
cluster-glue-libs-1.0.5-6.el6.x86_64.rpm libgssglue-0.1-11.el6.x86_64.rpm PyXML-0.8.4-19.el6.x86_64.rpm
heartbeat-3.0.4-2.el6.x86_64.rpm libtirpc-0.2.1-11.el6.x86_64.rpm resource-agents-3.9.5-46.el6.x86_64.rpm
heartbeat-libs-3.0.4-2.el6.x86_64.rpm nfs-utils-1.2.3-75.el6.x86_64.rpm rpcbind-0.2.0-12.el6.x86_64.rpm
keyutils-1.4-5.el6.x86_64.rpm nfs-utils-lib-1.1.5-13.el6.x86_64.rpm
[root@arbiter heartbeat]# rpm -ivh PyXML-0.8.4-19.el6.x86_64.rpm
warning: PyXML-0.8.4-19.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:PyXML ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh perl-TimeDate-1.16-13.el6.noarch.rpm
warning: perl-TimeDate-1.16-13.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:perl-TimeDate ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh cifs-utils-4.8.1-20.el6.x86_64.rpm keyutils-1.4-5.el6.x86_64.rpm keyutils-libs-1.4-5.el6.x86_64.rpm
warning: cifs-utils-4.8.1-20.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
file /lib64/libkeyutils.so.1.3 from install of keyutils-libs-1.4-5.el6.x86_64 conflicts with file from package keyutils-libs-1.4-4.el6.x86_64
[root@arbiter heartbeat]# rpm -qa|grep keyutils-libs
keyutils-libs-1.4-4.el6.x86_64
[root@arbiter heartbeat]# rpm -e keyutils-libs
error: Failed dependencies:
libkeyutils.so.1()(64bit) is needed by (installed) krb5-libs-1.10.3-10.el6.x86_64
libkeyutils.so.1(KEYUTILS_0.3)(64bit) is needed by (installed) krb5-libs-1.10.3-10.el6.x86_64
[root@arbiter heartbeat]# rpm -e --nodeps keyutils-libs
[root@arbiter heartbeat]# rpm -qa|grep keyutils-libs
[root@arbiter heartbeat]# rpm -ivh cifs-utils-4.8.1-20.el6.x86_64.rpm keyutils-1.4-5.el6.x86_64.rpm keyutils-libs-1.4-5.el6.x86_64.rpm
warning: cifs-utils-4.8.1-20.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:keyutils-libs ########################################### [ 33%]
2:keyutils ########################################### [ 67%]
3:cifs-utils ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh cluster-glue-*
warning: cluster-glue-1.0.5-6.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cluster-glue-libs ########################################### [ 50%]
2:cluster-glue ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh libgssglue-0.1-11.el6.x86_64.rpm
warning: libgssglue-0.1-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:libgssglue ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh libgssglue-0.1-11.el6.x86_64.rpm
warning: libgssglue-0.1-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
package libgssglue-0.1-11.el6.x86_64 is already installed
[root@arbiter heartbeat]# rpm -ivh libevent-1.4.13-4.el6.x86_64.rpm
warning: libevent-1.4.13-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:libevent ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh python-argparse-1.2.1-2.1.el6.noarch.rpm
warning: python-argparse-1.2.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:python-argparse ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh libtirpc-0.2.1-11.el6.x86_64.rpm
warning: libtirpc-0.2.1-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:libtirpc ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh rpcbind-0.2.0-12.el6.x86_64.rpm
warning: rpcbind-0.2.0-12.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:rpcbind ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh nfs-utils-*
warning: nfs-utils-1.2.3-75.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:nfs-utils-lib ########################################### [ 50%]
2:nfs-utils ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh heartbeat-*
warning: heartbeat-3.0.4-2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
error: Failed dependencies:
resource-agents is needed by heartbeat-3.0.4-2.el6.x86_64
[root@arbiter heartbeat]# rpm -ivh resource-agents-3.9.5-46.el6.x86_64.rpm
warning: resource-agents-3.9.5-46.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:resource-agents ########################################### [100%]
[root@arbiter heartbeat]# rpm -ivh heartbeat-*
warning: heartbeat-3.0.4-2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:heartbeat-libs ########################################### [ 50%]
2:heartbeat ########################################### [100%]
[root@arbiter heartbeat]#
3、heartbeat安裝完成后,配置以下三個配置文件
[root@mymongo1 ~]# ll /etc/ha.d/
total 32
-rw-------. 1 root root 37 Aug 16 23:53 authkeys
-rw-r--r--. 1 root root 239 Aug 17 00:01 ha.cf
-rwxr-xr-x. 1 root root 745 Dec 2 2013 harc
-rw-r--r--. 1 root root 206 Aug 17 01:01 haresources
drwxr-xr-x. 2 root root 4096 Aug 16 22:42 rc.d
-rw-r--r--. 1 root root 692 Dec 2 2013 README.config
drwxr-xr-x. 2 root root 4096 Aug 16 22:42 resource.d
-rw-r--r--. 1 root root 2082 Mar 24 06:01 shellfuncs
[root@mymongo1 ~]#
heartbeat三個配置文件的所在目錄
[root@mymongo1 ~]# rpm -q heartbeat -d
/usr/share/doc/heartbeat-3.0.4/AUTHORS
/usr/share/doc/heartbeat-3.0.4/COPYING
/usr/share/doc/heartbeat-3.0.4/COPYING.LGPL
/usr/share/doc/heartbeat-3.0.4/ChangeLog
/usr/share/doc/heartbeat-3.0.4/README
/usr/share/doc/heartbeat-3.0.4/apphbd.cf
/usr/share/doc/heartbeat-3.0.4/authkeys
/usr/share/doc/heartbeat-3.0.4/ha.cf
/usr/share/doc/heartbeat-3.0.4/haresources
/usr/share/man/man1/cl_status.1.gz
/usr/share/man/man1/hb_addnode.1.gz
/usr/share/man/man1/hb_delnode.1.gz
/usr/share/man/man1/hb_standby.1.gz
/usr/share/man/man1/hb_takeover.1.gz
/usr/share/man/man5/authkeys.5.gz
/usr/share/man/man5/ha.cf.5.gz
/usr/share/man/man8/apphbd.8.gz
/usr/share/man/man8/heartbeat.8.gz
[root@mymongo1 ~]#
heartbeat的ha.cf配置
[root@mymongo1 ~]# cat /etc/ha.d/ha.cf
#heartbeat controlfile
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local1
keepalive 2
deadtime 30
warntime 10
initdead 60

#bcast eth2,使用廣播方式做Heartbeat的心跳
mcast eth2 225.0.0.11 694 1 0

auto_failback on
node arbiter
node mymongo1

crm no
[root@mymongo1 ~]#
heartbeat的authkeys配置
sha1加密字符串隨意,但是要求權限是600
[root@mymongo1 ~]# cat /etc/ha.d/authkeys
auth 1
1 sha1 adf220fnasdfinvs02adsf
[root@mymongo1 ~]#
heartbeart的haresources配置
這里注意:配置的資源是浮動vip的地址,vip綁定的網絡端口要保持一致,用eth2都用eth2,用eth0都用eth0
并且eht1和eth0要用不同的IP網段,網口后的服務httpd代表資源啟動時會連帶啟動httpd,沒有則不啟動
[root@mymongo1 ~]# cat /etc/ha.d/haresources
arbiter IPaddr::192.168.144.121/24/eth2 httpd

mymongo1 IPaddr::192.168.144.122/24/eth2

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

#mysql salve
#mymongo1 IPaddr::192.168.144.12/24/eth2
[root@mymongo1 ~]#
三、本次實驗使用http做測試
2臺主機分別編輯index.html
[root@mymongo1 ~]# cat /var/www/html/index.html
this is mymongo1,its ip is 192.168.144.132
[root@mymongo1 ~]#
[root@arbiter ~]# cat /var/www/html/index.html
this is arbiter ,its ip is 192.168.144.111!
[root@arbiter ~]#
2臺主機均啟動http服務
[root@arbiter ~]# service httpd status
httpd (pid 4574) is running...
[root@arbiter ~]#
[root@mymongo1 ~]# service httpd status
httpd (pid 5714) is running...
[root@mymongo1 ~]#

2臺主機均啟動heartbeat
[root@mymongo1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@mymongo1 ~]#
稍等1分鐘左右觀察浮動IP會啟動
[root@mymongo1 ~]# ip add|grep 192.168.144
inet 192.168.144.132/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2
[root@mymongo1 ~]#
[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
inet 192.168.144.111/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.121/24 brd 192.168.144.255 scope global secondary eth2
[root@arbiter ~]#
網頁查看
linux-ha heartbeat高可用的安裝配置(http服務高可用)

linux-ha heartbeat高可用的安裝配置(http服務高可用)
浮動IP切換測試,停止mymongo1的heartbeart
[root@mymongo1 ~]# service httpd status
httpd (pid 5714) is running...
[root@mymongo1 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.
[root@mymongo1 ~]#
查看浮動IP資源192.168.144.122被arbiter接管
[root@arbiter ~]# ip add|grep 192.168.144
inet 192.168.144.111/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.121/24 brd 192.168.144.255 scope global secondary eth2
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2
[root@arbiter ~]#
相關的資源切換日志
[root@arbiter ~]# cat /var/log/ha-log
Aug 17 02:00:03 arbiter heartbeat: [4271]: info: Received shutdown notice from 'mymongo1'.
Aug 17 02:00:03 arbiter heartbeat: [4271]: info: Resources being acquired from mymongo1.
Aug 17 02:00:03 arbiter heartbeat: [5610]: info: acquire local HA resources (standby).
ResourceManager(default)[5637]: 2017/08/17_02:00:03 info: Acquiring resource group: arbiter IPaddr::192.168.144.121/24/eth2 httpd
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.121)[5683]: 2017/08/17_02:00:03 INFO: Running OK
Aug 17 02:00:03 arbiter heartbeat: [5611]: info: Local Resource acquisition completed.
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.121)[5692]: 2017/08/17_02:00:03 INFO: Running OK
Aug 17 02:00:03 arbiter heartbeat: [5610]: info: local HA resource acquisition completed (standby).
Aug 17 02:00:03 arbiter heartbeat: [4271]: info: Standby resource acquisition done [foreign].
harc(default)[5856]: 2017/08/17_02:00:03 info: Running /etc/ha.d//rc.d/status status
mach_down(default)[5873]: 2017/08/17_02:00:03 info: Taking over resource group IPaddr::192.168.144.122/24/eth2
ResourceManager(default)[5900]: 2017/08/17_02:00:03 info: Acquiring resource group: mymongo1 IPaddr::192.168.144.122/24/eth2
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[5928]: 2017/08/17_02:00:03 INFO: Resource is stopped
ResourceManager(default)[5900]: 2017/08/17_02:00:03 info: Running /etc/ha.d/resource.d/IPaddr 192.168.144.122/24/eth2 start
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: Adding inet address 192.168.144.122/24 with broadcast address 192.168.144.255 to device eth2
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: Bringing device eth2 up
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p /var/run/resource-agents/send_arp-192.168.144.122 eth2 192.168.144.122 auto not_used not_used
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6027]: 2017/08/17_02:00:03 INFO: Success
mach_down(default)[5873]: 2017/08/17_02:00:03 info: /usr/share/heartbeat/mach_down: nice_failback: foreign resources acquired
mach_down(default)[5873]: 2017/08/17_02:00:03 info: mach_down takeover complete for node mymongo1.
Aug 17 02:00:03 arbiter heartbeat: [4271]: info: mach_down takeover complete.
Aug 17 02:00:34 arbiter heartbeat: [4271]: WARN: node mymongo1: is dead
Aug 17 02:00:34 arbiter heartbeat: [4271]: info: Dead node mymongo1 gave up resources.
Aug 17 02:00:34 arbiter heartbeat: [4271]: info: Link mymongo1:eth2 dead.
[root@arbiter ~]# tail -f /var/log/ha-log
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: Adding inet address 192.168.144.122/24 with broadcast address 192.168.144.255 to device eth2
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: Bringing device eth2 up
IPaddr(IPaddr_192.168.144.122)[6053]: 2017/08/17_02:00:03 INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p /var/run/resource-agents/send_arp-192.168.144.122 eth2 192.168.144.122 auto not_used not_used
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6027]: 2017/08/17_02:00:03 INFO: Success
mach_down(default)[5873]: 2017/08/17_02:00:03 info: /usr/share/heartbeat/mach_down: nice_failback: foreign resources acquired
mach_down(default)[5873]: 2017/08/17_02:00:03 info: mach_down takeover complete for node mymongo1.
Aug 17 02:00:03 arbiter heartbeat: [4271]: info: mach_down takeover complete.
Aug 17 02:00:34 arbiter heartbeat: [4271]: WARN: node mymongo1: is dead
Aug 17 02:00:34 arbiter heartbeat: [4271]: info: Dead node mymongo1 gave up resources.
Aug 17 02:00:34 arbiter heartbeat: [4271]: info: Link mymongo1:eth2 dead.
查看web頁面
linux-ha heartbeat高可用的安裝配置(http服務高可用)

啟動mymongo1的heartbeat
[root@mymongo1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
INFO: Resource is stopped
Done.
[root@mymongo1 ~]#
查看arbiter接管的mymongo1的浮動ip資源192.168.144.121被arbiter釋放
[root@arbiter ~]# ip add|grep 192.168.144
inet 192.168.144.111/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.121/24 brd 192.168.144.255 scope global secondary eth2
[root@arbiter ~]#
arbiter釋放資源的日志
Aug 17 02:07:42 arbiter heartbeat: [4271]: info: Heartbeat restart on node mymongo1
Aug 17 02:07:42 arbiter heartbeat: [4271]: info: Link mymongo1:eth2 up.
Aug 17 02:07:42 arbiter heartbeat: [4271]: info: Status update for node mymongo1: status init
Aug 17 02:07:42 arbiter heartbeat: [4271]: info: Status update for node mymongo1: status up
harc(default)[6199]: 2017/08/17_02:07:42 info: Running /etc/ha.d//rc.d/status status
harc(default)[6216]: 2017/08/17_02:07:42 info: Running /etc/ha.d//rc.d/status status
Aug 17 02:07:43 arbiter heartbeat: [4271]: info: Status update for node mymongo1: status active
harc(default)[6233]: 2017/08/17_02:07:43 info: Running /etc/ha.d//rc.d/status status
Aug 17 02:07:44 arbiter heartbeat: [4271]: info: remote resource transition completed.
Aug 17 02:07:44 arbiter heartbeat: [4271]: info: arbiter wants to go standby [foreign]
Aug 17 02:07:44 arbiter heartbeat: [4271]: info: standby: mymongo1 can take our foreign resources
Aug 17 02:07:44 arbiter heartbeat: [6250]: info: give up foreign HA resources (standby).
ResourceManager(default)[6263]: 2017/08/17_02:07:44 info: Releasing resource group: mymongo1 IPaddr::192.168.144.122/24/eth2
ResourceManager(default)[6263]: 2017/08/17_02:07:44 info: Running /etc/ha.d/resource.d/IPaddr 192.168.144.122/24/eth2 stop
IPaddr(IPaddr_192.168.144.122)[6326]: 2017/08/17_02:07:44 INFO: IP status = ok, IP_CIP=
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6300]: 2017/08/17_02:07:44 INFO: Success
Aug 17 02:07:44 arbiter heartbeat: [6250]: info: foreign HA resource release completed (standby).
Aug 17 02:07:44 arbiter heartbeat: [4271]: info: Local standby process completed [foreign].
Aug 17 02:07:45 arbiter heartbeat: [4271]: WARN: 1 lost packet(s) for [mymongo1] [10:12]
Aug 17 02:07:45 arbiter heartbeat: [4271]: info: remote resource transition completed.
Aug 17 02:07:45 arbiter heartbeat: [4271]: info: No pkts missing from mymongo1!
Aug 17 02:07:45 arbiter heartbeat: [4271]: info: Other node completed standby takeover of foreign resources.
mymongo1查看被接管的浮動ip資源192.168.144.121重新獲取到
[root@mymongo1 ~]# ip add|grep 192.168.144
inet 192.168.144.132/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2
[root@mymongo1 ~]#
注意由于haresources配置,mymongo1的http服務并不會啟動(但是原先是啟動了的)
[root@mymongo1 ~]# service httpd status
httpd is stopped
[root@mymongo1 ~]#
arbiter關閉heartbeat
[root@arbiter ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.

[root@arbiter ~]# ip add|grep 192.168.144
inet 192.168.144.111/24 brd 192.168.144.255 scope global eth2
[root@arbiter ~]#
mymonog1觀察資源接管情況
[root@mymongo1 ~]# tail -70 /var/log/ha-log
Aug 17 02:07:44 mymongo1 heartbeat: [6356]: info: arbiter wants to go standby [foreign]
Aug 17 02:07:44 mymongo1 heartbeat: [6356]: info: standby: acquire [foreign] resources from arbiter
Aug 17 02:07:44 mymongo1 heartbeat: [6384]: info: acquire local HA resources (standby).
ResourceManager(default)[6397]: 2017/08/17_02:07:44 info: Acquiring resource group: mymongo1 IPaddr::192.168.144.122/24/eth2
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6425]: 2017/08/17_02:07:44 INFO: Resource is stopped
ResourceManager(default)[6397]: 2017/08/17_02:07:44 info: Running /etc/ha.d/resource.d/IPaddr 192.168.144.122/24/eth2 start
IPaddr(IPaddr_192.168.144.122)[6550]: 2017/08/17_02:07:44 INFO: Adding inet address 192.168.144.122/24 with broadcast address 192.168.144.255 to device eth2
IPaddr(IPaddr_192.168.144.122)[6550]: 2017/08/17_02:07:44 INFO: Bringing device eth2 up
IPaddr(IPaddr_192.168.144.122)[6550]: 2017/08/17_02:07:44 INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p /var/run/resource-agents/send_arp-192.168.144.122 eth2 192.168.144.122 auto not_used not_used
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6524]: 2017/08/17_02:07:44 INFO: Success
Aug 17 02:07:44 mymongo1 heartbeat: [6384]: info: local HA resource acquisition completed (standby).
Aug 17 02:07:45 mymongo1 heartbeat: [6356]: info: Standby resource acquisition done [foreign].
Aug 17 02:07:45 mymongo1 heartbeat: [6356]: info: Initial resource acquisition complete (auto_failback)
Aug 17 02:07:45 mymongo1 heartbeat: [6356]: info: remote resource transition completed.
Aug 17 02:17:42 mymongo1 heartbeat: [6356]: info: Received shutdown notice from 'arbiter'.
Aug 17 02:17:42 mymongo1 heartbeat: [6356]: info: Resources being acquired from arbiter.
Aug 17 02:17:42 mymongo1 heartbeat: [6706]: info: acquire local HA resources (standby).
ResourceManager(default)[6736]: 2017/08/17_02:17:42 info: Acquiring resource group: mymongo1 IPaddr::192.168.144.122/24/eth2
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6777]: 2017/08/17_02:17:42 INFO: Running OK
Aug 17 02:17:42 mymongo1 heartbeat: [6707]: info: Local Resource acquisition completed.
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.122)[6789]: 2017/08/17_02:17:42 INFO: Running OK
Aug 17 02:17:42 mymongo1 heartbeat: [6706]: info: local HA resource acquisition completed (standby).
Aug 17 02:17:42 mymongo1 heartbeat: [6356]: info: Standby resource acquisition done [foreign].
harc(default)[6943]: 2017/08/17_02:17:42 info: Running /etc/ha.d//rc.d/status status
mach_down(default)[6960]: 2017/08/17_02:17:42 info: Taking over resource group IPaddr::192.168.144.121/24/eth2
ResourceManager(default)[6987]: 2017/08/17_02:17:42 info: Acquiring resource group: arbiter IPaddr::192.168.144.121/24/eth2 httpd
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.121)[7015]: 2017/08/17_02:17:42 INFO: Resource is stopped
ResourceManager(default)[6987]: 2017/08/17_02:17:42 info: Running /etc/ha.d/resource.d/IPaddr 192.168.144.121/24/eth2 start
IPaddr(IPaddr_192.168.144.121)[7140]: 2017/08/17_02:17:42 INFO: Adding inet address 192.168.144.121/24 with broadcast address 192.168.144.255 to device eth2
IPaddr(IPaddr_192.168.144.121)[7140]: 2017/08/17_02:17:42 INFO: Bringing device eth2 up
IPaddr(IPaddr_192.168.144.121)[7140]: 2017/08/17_02:17:42 INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p /var/run/resource-agents/send_arp-192.168.144.121 eth2 192.168.144.121 auto not_used not_used
/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.144.121)[7114]: 2017/08/17_02:17:42 INFO: Success
ResourceManager(default)[6987]: 2017/08/17_02:17:42 info: Running /etc/init.d/httpd start
mach_down(default)[6960]: 2017/08/17_02:17:42 info: /usr/share/heartbeat/mach_down: nice_failback: foreign resources acquired
mach_down(default)[6960]: 2017/08/17_02:17:42 info: mach_down takeover complete for node arbiter.
Aug 17 02:17:42 mymongo1 heartbeat: [6356]: info: mach_down takeover complete.
Aug 17 02:18:13 mymongo1 heartbeat: [6356]: WARN: node arbiter: is dead
Aug 17 02:18:13 mymongo1 heartbeat: [6356]: info: Dead node arbiter gave up resources.
Aug 17 02:18:13 mymongo1 heartbeat: [6356]: info: Link arbiter:eth2 dead.
[root@mymongo1 ~]#
[root@mymongo1 ~]# ip add|grep 192.168.144
inet 192.168.144.132/24 brd 192.168.144.255 scope global eth2
inet 192.168.144.122/24 brd 192.168.144.255 scope global secondary eth2
inet 192.168.144.121/24 brd 192.168.144.255 scope global secondary eth2
[root@mymongo1 ~]# service httpd status
httpd (pid 7255) is running...
[root@mymongo1 ~]#
web頁面查看
linux-ha heartbeat高可用的安裝配置(http服務高可用)

到此實驗結束!
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宜丰县| 巴林右旗| 丰宁| 台中县| 敦化市| 南雄市| 于都县| 建始县| 明水县| 新巴尔虎左旗| 通化县| 永嘉县| 中超| 黄山市| 织金县| 宁安市| 彝良县| 全南县| 宁津县| 博湖县| 德清县| 汉源县| 清苑县| 蒙城县| 明光市| 平江县| 长葛市| 苍梧县| 宁乡县| 余江县| 天气| 九寨沟县| 娱乐| 马山县| 通海县| 云梦县| 库伦旗| 类乌齐县| 海丰县| 苏州市| 鹿泉市|