NTP服務器配置及簡單體驗heartdeatv1高可用流程

NTP服務器配置及heartbeatV1實現httpd高可用


 NTP服務器的搭建和使用                                                                    


由於在做到高可用集羣時,對個各節點的時間要求比較嚴格。因此我們需要配置一個NTP服務器實現高可用集羣的的時間同步器。然後將其他的節點時間指向這個ntp,先來創建一個NTP服務器。

[root@localhost ~ ]# rpm -q ntp
ntp-4.2.6p5-1.el6.centos.x86_64

由於我們的服務器已經有ntp服務器,那麼我們這裏邊直接使用好了。

[root@localhost ~ ]# rpm -ql ntp
/etc/ntp.conf         //配置文件
/etc/ntp/crypto
/etc/ntp/crypto/pw
/etc/rc.d/init.d/ntpd  //腳本程序
  # vim /etc/ntp.conf
  1 # For more information about this file, see the man pages
  2 # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
  3 
  4 driftfile /var/lib/ntp/drift
  5 
  6 # Permit time synchronization with our time source, but do not
  7 # permit the source to query or modify the service on this system.
  8 restrict default kod nomodify notrap nopeer noquery
  9 restrict -6 default kod nomodify notrap nopeer noquery
 10 
 11 # Permit all access over the loopback interface.  This could
 12 # be tightened as well, but to do so would effect some of
 13 # the administrative functions.
 14 restrict 127.0.0.1
 15 restrict -6 ::1
 16 
 17 # Hosts on local network are less restricted.
 18 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap //允許其他主機同步時間
 19 
 20 # Use public servers from the pool.ntp.org project.
 21 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
 22 # server 0.centos.pool.ntp.org iburst (默認時間服務器)
 23 # server 1.centos.pool.ntp.org iburst (默認時間服務器)
 24 # server 2.centos.pool.ntp.org iburst (默認時間服務器)
 25 # server 3.centos.pool.ntp.org iburst (默認時間服務器)
 26 server 172.16.0.1                     (自己添加的)
 27 #broadcast 192.168.1.255 autokey    # broadcast server
 27 #broadcast 192.168.1.255 autokey    # broadcast server
 28 #broadcastclient            # broadcast client
 29 #broadcast 224.0.1.1 autokey        # multicast server
 30 #multicastclient 224.0.1.1      # multicast client
 31 #manycastserver 239.255.254.254     # manycast server
 32 #manycastclient 239.255.254.254 autokey # manycast client
 33 restrict172.16.0.1 nomodify notrap noquery  //允許上游時間服務器修改本地時間
 34 server127.127.1.0   #local clock     
    fudge 127.127.1.0  stratum  10
    #Enable public key cryptography.
 35 #crypto
 36 
 37 includefile /etc/ntp/crypto/pw
 38 
 39 # Key file containing the keys and key identifiers used when operating
 40 # with symmetric key cryptography. 
 41 keys /etc/ntp/keys
 42 
 43 # Specify the key identifiers which are trusted.
 44 #trustedkey 4 8 42
 45 
 46 # Specify the key identifier to use with the ntpdc utility.
 47 #requestkey 8
 48 
 49 # Specify the key identifier to use with the ntpq utility.
 50 #controlkey 8
 51 
 52 # Enable writing of statistics records.
 53 #statistics clockstats cryptostats loopstats peerstats

                                         

同樣是其他節點服務器將時間指向該NTP服務器即可:

    restrict 127.0.0.1
    restrict -6 ::1
    server  172.16.31.10 //ntp指向ntp服務器
    restrict 172.16.31.10 nomodify notrap noquery //允許矯正時間
    server  127.127.1.0      # local clock
    fudge   127.127.1.0      stratum 10

     #service ntpd start 即可:

準備各節點:

實驗環境

1.時間需要同步,建議使用NTP服務器同步時間並且創建時間同步計劃

2.root用戶基於密鑰認證的時候

3../etc/hosts文件作好IP對應的主機名的解析

解決依賴關係及包的安裝:

 #yum -y installnet-snmp-libs libnet PyXML
 #rpm -ivh heartbeat-pils-2.1.4-12.el6.x86_64.rpm
 #rpm -ivhheartbeat-stonith-2.1.4-12.el6.x86_64.rpm
 #rpm -ivhheartbeat-2.1.4-12.el6.x86_64.rpm

安裝好heartbeat之後配置以下三個文件:

一.配置主配置文件

#vim ha.cf
mcast eth0 229.155.11.24 694 1 0
auto_failback on
logfile /var/log/ha-log
#logfacility   local0
node   node2
node   node3
ping 172.16.0.1


二.配置認證文件

在最後添加

auth2 
2 sha1 17d1df5da5db

三配置資源文件

在最後添加

node2 172.16。11.13/16/eth0/172.16.255.255 httpd 

authkeysha.cfharesources複製給另一臺主機,放在相同位置


保證各httpd服務開機不會自動啓動

# chkconfig httpd off

啓動heartbeat,測試結果。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章