heartbeat實現高可用集群(1)

環境
   node1 192.168.1.35
   node2 192.168.1.36
   fip 192.168.1.80
   daemon httpd
  nfs 192.168.1.15 
配置HA集群的前提
  1.節點時間必須同步,使用ntp協議實現
  2.節點間需要通過主機互相通信,必須解析主機名至IP地址
    a.建議名稱解析功能能使用hosts文件實現
     b.通信中使用的名字與節點名字必須保持一致
  3.考慮仲裁設備是否會用到
  4.建立各節點之間的root用戶能夠基于密鑰認證
    # ssh-keygen -t rsa -P ''
    # ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.36
[[ heartbeat v2 + haresources(v1)]]
node1&node2(centos 6)
# yum install 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
配置文件:/etc/ha.d目錄下
             ha.cf:主配置文件,定義各節點上的heartbeat HA集群的基本屬性
             authkeys:集群內各節點彼此傳遞消息時使用加密算法 及密鑰
             haresources:為heartbeat v1提供資源管理器配置接口;v1版本專用的配置接口
         樣例:/usr/share/doc/hearbeat-2.1.4/目錄下
node1
# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,haresources,authkeys} /etc/ha.d/
# ll
# chmod 600 authkeys
# vim authkeys(指明啟用那種算法,使用的密鑰是什么)
     auth 2
     2 sha1 gbpNZ/hvE89KxPqjyHclmn(openssl rand -base64 16)
# vim ha.cf
     logfile  /var/log/heartbeat.log (日志)
     mcast eth0 225.13.180.1 694 1 0
     auto_failback on 
     node     node1(指明節點名,必須與uname -n保持一致)
     node     node2
     ping 192.168.0.1(仲裁設備)
     compression    bz2 (指明節點間傳遞信息的壓縮算法)
     comprehensive_threshold 2 (壓縮時的起點,單位KB)
# vim haresource (定義集群資源)(對資源的管理要使用資源代理)
     node1   192.168.1.80/24/eth0/192.168.255.255 httpd
# scp -p authkeys ha.cf haresources node2:/etc/ha.d/
node1&node2
# yum install httpd -y
# echo "<h1>node1.com</h1> > /var/www/html/index.html (node1)
# echo "<h1>node2.com</h1> > /var/www/html/index.html (node2)
# service httpd stop
# curl 192.168.1.35
  <h1>node1.com</h1>
# service httpd stop
# chkconfig httpd off (開機不自啟)
# service heartbeat start
# ss -tunl
   :694
瀏覽器訪問192.168.1.80
nfs
# mkdir -pv /web/htdocs
# echo "<h1>Page on NFS server</h1>" > /web/htdoc/index.html
# vim /etc/exports(共享文件)
  /web/htdocs 192.168.0.1/24(rw,no_root_squash)
# service nfs service
# chkconfig nfs on
node1
# cd
# service heartbeat stop; ssh node2 'service heartbeat stop'
# cd /etc/ha.d/
node1&2
# mount -t nfs 192.168.1.15:/web/htdocs /var/www/html
# mount 
  192.168.1.15:/web/htdocs on /var/www/html type nfs (rw,vers=4,addr=192.168.1.15,clientaddr=192.168.1.35)
# service httpd restart
瀏覽器訪問192.168.1.35及192.168.1.36
# service httpd stop
# umount /var/www/html/
node1
# ls
# pwd
  /etc/ha.d
# ls resource.d/
  Filesystem     (文件系統的資源代理)
# vim haresources
  node1 192.168.1.80/24/eth0/192.168.255.255 Filesystem::192.168.1.15:/web/htdocs::/var/www/html::nfs httpd
  (Filesystem::192.168.1.15:/web/htdocs::/var/www/html::nfs Filesystem::要掛載的設備::掛載點::文件系統類型)
# scp -p haresources node2:/etc/ha.d
# service heartbeat start; ssh node2 'service heartbeat start'
# ss -tnl
# ifconfig
# mount 
# tail /var/log/heartbeat.log 
# /usr/lib64/heartbeat/hb_standby  讓節點變成備用模式
node2
# tail /var/log/heartbeat.log
# ss -tnl
# ifconfig
# mount 
# /usr/lib64/heartbeat/hb_standby
node1
# /usr/lib64/heartbeat/hb_takeover





原創文章,作者:nene,如若轉載,請注明出處:http://www.www58058.com/88196

(0)
nenenene
上一篇 2017-11-02 18:08
下一篇 2017-11-03

相關推薦

  • linux網絡屬性命令操作介紹(第十一天)

            linux網絡屬性常用命令有ifconfig\route\ip命令,centos7 的還是nmcli\nmtui。     網絡屬性的三大文件:修改DNS的文件/etc/resolv.conf  、修改網卡IP地址/etc/sysconfig/…

    Linux干貨 2016-06-01
  • ?Linux基礎知識之screen命令詳解

    該博文以CentOS6.8_x86_64系統為基礎,Xshell5遠程登錄CentOS6.8系統,以root身份登錄系統,以Xshell5發起screen幫助,用系統命令行界面去連接。 screen命令:         打開新的screen: screen -S [SESSION]   (打開一個名叫hel…

    Linux干貨 2016-07-29
  • 編譯安裝httt服務

    1 軟件下載地址:http://httpd.apache.org/ 2 將下載好的httpd-2.2.34.tar.bz2包解壓到 /usr/local/src/httpd-2.2.34–  # tar xvf httpd-2.2.34.tar.bz2 3 編譯安裝http,指定安裝路徑: –prefix=/app/http…

    Linux干貨 2017-08-05
  • 集中練習2

    用戶管理、文本處理、文件管理相關

    2017-09-20
  • N25第一周學習總結

    第一周學習總結 按照課程要求,本周完成2天的課時,總計8課時。 因為是剛開課,馬哥為我們介紹了上課環境,課程體系,還有一些計算機基礎理論。內容主要是:          計算機的工作機制        &nbs…

    Linux干貨 2016-12-04
  • linux 網絡管理

    1、ifconfig命令格式: ifconfig[interface] 查看IP ifconfig-a 查看全部網卡信息 ifconfigIFACE [up|down] 網卡開啟關閉 ifconfigIFACE IP/netmask [up] ifconfigIFACE IP netmask NETMASK 命令立即生效,不能永久保存  &nbsp…

    Linux干貨 2017-08-20
欧美性久久久久