阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

NTP服务器配置及Heartbeat V1实现httpd高可用

153次阅读
没有评论

共计 3856 个字符,预计需要花费 10 分钟才能阅读完成。

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

把 authkeys、ha.cf 和 haresources 复制给另一台主机,放在相同位置

保证各 httpd 服务开机不会自动启动

# chkconfig httpd off

启动 heartbeat,测试结果。

Linux 实战部署系列之 NTP 服务器 http://www.linuxidc.com/Linux/2013-11/92275.htm

搭建企业级 NTP 时间服务器 http://www.linuxidc.com/Linux/2014-02/97205.htm

Linux 下快速搭建 ntp 时间同步服务器 http://www.linuxidc.com/Linux/2014-07/104371.htm

CentOS 6.3 下实现 NTP 时间服务器 http://www.linuxidc.com/Linux/2014-08/105414.htm

基于 Heartbeat V1 实现 Web 服务双机热备 http://www.linuxidc.com/Linux/2014-04/100635.htm

Heartbeat 实现 Web 服务的高可用群集 http://www.linuxidc.com/Linux/2014-04/99503.htm

Heartbeat+LVS+Ldirectord 高可用负载均衡解决方案 http://www.linuxidc.com/Linux/2014-04/99502.htm

DRBD+Heartbeat+NFS 高可用性配置笔记 http://www.linuxidc.com/Linux/2014-04/99501.htm

Heartbeat 基于 CRM 使用 NFS 对 MySQL 高可用 http://www.linuxidc.com/Linux/2014-03/98674.htm

Heartbeat 高可用 httpd 基于 Resources 简单配置 http://www.linuxidc.com/Linux/2014-03/98672.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计3856字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中