heartbeat2使用crm借助gui界面配置httpd服務
1. 服務大體資源構架:
1) 兩臺httpd服務,外加一臺nfs共享存儲服務。
2) 地址分配:
node1.playground.com(httpd)192.168.253.133 node2.playground.com(httpd)192.168.253.134 node3.playground.com(nfs服務器)192.168.253.135 node1和node2上面的vip定為192.168.253.100
2. node1和node2上面安裝httpd服務; 使用默認DocumentRoot = /var/www/html
3. 在node3上面配置nfs服務,
# yum install nfs # vim /etc/exports /var/www/share192.168.253.133/24(rw)192.168.253.134/24(rw) # echo "web from NFS" > /var/www/share/index.html
4. 在node1和node2上面安裝heartbeat2和gui-組件
# yum install perl-TimeDate net-snmp-libs libnet PyXML # rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm 安裝heartbeat-gui # yum install pygtk2-libglade # rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm
5. 修改node1上面的配置文件,并且進行同步
# vim /etc/ha.d/authkeys auth 2 #1 crc 2 sha1 8499636794b07630af98 #3 md5 Hello!
# vim /etc/ha.d/ha.cf logfile /var/log/ha-log keepalive 2 deadtime 15 warntime 10 udpport 694 mcast eth0 225.0.130.1 694 1 0 auto_failback on node node1.playground.com node node2.playground.com ping 192.168.253.2 crm on ## 開啟crm管理器,此時不再使用haresource來進行資源管理
使用次腳本進行各節點配置文件的同步,并且自動配置authkeys 600權限 # /usr/lib64/heartbeat/ha_propagate Propagating HA configuration files to node node2.playground.com. ha.cf 100% 10KB 10.4KB/s 00:00 authkeys 100% 660 0.6KB/s 00:00
6. 配置gui管理用戶,啟動heartbeat接口
# tail -1 /etc/passwd hacluster:x:495:495:heartbeat user:/var/lib/heartbeat/cores/hacluster:/sbin/nologin # passwd hacluster ## 修改hacluster密碼,用來以后通過圖形界面管理heartbeat # hb_gui & # 進入圖形界面,進入后點擊connect按鈕,輸入之前設置的管理密碼即可開始配置。
7. 配置資源組
在Resources右鍵添加資源組webservice
在webservice組上面按照順序添加如下資源
1) webip 選擇 ip addr2 type, 添加parameter如下
ip192.168.253.100 niceth0 cidr_netmask24 iflabel0
2) storage資源: 選擇FileSystem type, 添加parameter如下
device 192.168.253.135:/var/www/share directory /var/www/html fstype nfs
3) webserver: 選擇httpd即可
然后右鍵單擊資源組,運行,可以看到三個資源按順序啟動運行在node2上。 客戶端的網頁訪問也是正常的
heartbeat2使用crm借助gui界面配置mysql服務
1. 服務大體資源構架:
1) 兩臺mysqld服務,外加一臺nfs共享存儲服務。
2) 地址分配:
node1.playground.com(mysqld)192.168.253.133 node2.playground.com(mysqld)192.168.253.134 node3.playground.com(nfs服務器)192.168.253.135 node1和node2上面的vip定為192.168.253.100
2. 在node1和node2上安裝以二進制格式安裝mysql服務器。安裝方法不贅述了,之前都搞過好多遍了。主要一點,要指定組ID和用戶ID
## node1,node2,node3 都要創建相同組ID和用戶ID的mysqld的運行用戶 # groupadd -g 600 mysql # useradd -u 600 -g 600 mysql # grep mysql /etc/passwd mysql:x:600:600::/home/mysql:/bin/bash
3. 在node3上配置nfs
# yum install nfs # vim /etc/exports /var/www/share192.168.253.133/24(rw,no root squash)192.168.253.134/24(rw) # echo "web from NFS" > /var/www/share/index.html # setfacl -m u:mysql:rwx /var/www/share # su mysql # mkdir binlog mysqldata relaylog
4. 在node1上,掛載data目錄到,nfs服務器上,初始化數據庫。
# mount -t nfs 192.168.253.135:/var/www/share /data 然后使用初始化腳本,初始化數據庫 配置文件中設置了,初始化位置,所以直接運行初始化腳本即可。 log-bin=/data/binlog/master2-bin datadir=/data/mysqldata user=mysql 兩個節點分別掛載測試后沒問題,即可進行下面操作。
5. node1 和 node2上面安裝heartbeat2 和 圖形化接口
# yum install perl-TimeDate net-snmp-libs libnet PyXML # rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm 安裝heartbeat-gui # yum install pygtk2-libglade # rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm
6. 修改node1上面的配置文件,并且進行同步
# vim /etc/ha.d/authkeys auth 2 #1 crc 2 sha1 8499636794b07630af98 #3 md5 Hello! # vim /etc/ha.d/ha.cf logfile /var/log/ha-log keepalive 2 deadtime 15 warntime 10 udpport 694 mcast eth0 225.0.130.1 694 1 0 auto_failback on node node1.playground.com node node2.playground.com ping 192.168.253.2 crm on ## 開啟crm管理器,此時不再使用haresource來進行資源管理
# /usr/lib64/heartbeat/ha_propagate Propagating HA configuration files to node node2.playground.com. ha.cf 100% 10KB 10.4KB/s 00:00 authkeys
7. 啟動node1, node2 heartbeat服務
# service heartbeat start # ssh node2.playground.com 'service heartbeat start'
8. 配置hb_gui用戶運行密碼,并啟動hb_gui界面配置HA
# tail -1 /etc/passwd hacluster:x:495:495:heartbeat user:/var/lib/heartbeat/cores/hacluster:/sbin/nologin # passwd hacluster ## 修改hacluster密碼,用來以后通過圖形界面管理heartbeat # hb_gui & # 進入圖形界面,進入后點擊connect按鈕,輸入之前設置的管理密碼即可開始配置。
9. 配置資源
在Resources右鍵添加資源組mysqlservice 組里按順序添加一下資源: mysql_ip: 資源類型: ipaddr2 屬性: ip: 192.168.253.100 nic: eth0 cidr_netmask 24 iflabel0 mysql_storage: 資源類型: Filesystem 屬性: device: 192.168.253.135:/var/www/share directory: /data fstype: nfs mysql_service 資源類型: mysqld 然后可以選擇啟動資源即可。
10. 授權一個遠程可遠程登錄的用戶,遠程登錄由vip輸出的mysql服務
MariaDB [(none)]> GRANT ALL ON *.* TO 'tester'@'192.168.%.%' IDENTIFIED BY 'test'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES ; Query OK, 0 rows affected (0.00 sec) 在node3上面嘗試遠程登錄 # mysql -utester -h192.168.253.100 -ptest Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.1.9-MariaDB-log MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
heartbeat2使用crm借助gui界面配置lvs DR web服務,對director做高可用
1. 服務器地址分配:
node1.playground.com192.168.253.133 作為director1 node2.playground.com192.168.253.134作為director2 node3.playground.com192.168.253.135作為RealServer1 node4.playground.com192.168.253.136作為RealServer2 VIP192.168.253.100 此時要把前四個地址和主機名同步到各主機,并且按照分配配置主機名。
2. 先配置兩臺realserver
RS1,RS2配置一樣,如下 # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce # echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce # echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore # ifconfig lo:0 192.168.253.100 netmask 255.255.255.255 broadcast 192.168.253.100 up # route add -host 192.168.253.100 dev lo:0
3. 配置web服務和測試頁
RS1:node3 # echo "web from RS1" > /var/www/html/index.html # echo "OK" > /var/www/html/.test.html RS2:node4 # echo "web from RS2" > /var/www/html/index.html # echo "OK" > /var/www/html/.test.html .test.html頁作為,RS健康狀況監測標記。
4. 按照上面相同方法在node1,node2上面安裝圖形接口和heartbeat,配置文件配置,設定圖形接口運行用戶密碼也和以上的相同,這里不贅述
5. 還要在node1和node2上面安裝heartbeat-ldirectord用配置ipvs規則外加控制RealServer的健康狀況
# yum install heartbeat-ldirectord-2.1.4-12.el6.x86_64.rpm
6. 配置ldirectord
# cp /usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf /etc/ha.d/ # vim /etc/ha.d/ldirectord.cf # Global Directives checktimeout=3 checkinterval=1 fallback=127.0.0.1:80 autoreload=yes logfile="/var/log/ldirectord.log" quiescent=yes # Sample for an http virtual service virtual=192.168.253.100:80 real=192.168.253.135:80 gate real=192.168.253.136:80 gate fallback=127.0.0.1:80 gate service=http request=".test.html" receive="OK" scheduler=rr 這里的service = http的意思是,使用哪種方式對后端RS進行健康狀態檢測 request 是用于檢測的測試頁 receive 請求測試頁返回什么值 之前我們已經提供了檢測測試頁,返回值應該是"OK" 配置好后,需要把這個配置文件在兩臺主機上同步
7. 在兩個director上面,配置httpd服務,并且添加一個failover頁, 當后端RS全都不響應的時候,顯示"maintance on going"
8. 啟動圖形界面開始配置。
# service heartbeat start ; ssh node2.playground.com 'service heartbeat start' # hb_gui & 添加組: lvs_httpd Ordered: true Collocated: true 添加資源: ipvsvip ip: 192.168.253.100 nic: eth0 cidr_netmask:32 iflabel: 0 broadcast: 192.168.253.100 添加資源: ipvsldirector ldirectord/usr/sbin/ldirectord configfile/etc/ha.d/ldirectord.cf ## 配置完后就可以啟動資源組了
7. 一些測試。
兩臺RS都正常時候,按照算法輪換 兩臺RS都關閉時候,轉到maintanance on going!
原創文章,作者:以馬內利,如若轉載,請注明出處:http://www.www58058.com/10990
向你學習,有個問題想問一下,我運行hb_gui &報錯,是該如何解決。。安裝了Xmanager的。[root@node2 ~]# hb_gui &
[1] 2384
[root@node2 ~]# Traceback (most recent call last):
File “/usr/bin/hb_gui”, line 41, in
import gtk, gtk.glade, gobject
File “/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py”, line 64, in
_init()
File “/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py”, line 52, in _init
_gtk.init_check()
RuntimeError: could not open display