GBase 8c部署准备(四):NTP同步
1. 检查NTP服务
(1) 检查服务器是否安装NTP服务,以及是否正常运行:
[gbase@localhost ~]$ sudo systemctl status ntpd.service
如果显示running,则表示NTP服务正在运行。否则考虑进行操作(2)。
(2) 如果系统可以与外网通信,可以使用如下命令与NTP服务器同步:
[gbase@localhost ~]$ sudo systemctl status ntpd.service
如果服务器所在网络无法与外网通信,需要手动配置NTP服务。确认是否已安装NTP:
[gbase@localhost ~]$ rpm -qa|grep ntp
1) 若已安装NTP,则应返回如下内容:
python-ntplib-0.3.2-1.el7.noarch
ntpdate-4.2.6p5-29.el7.centos.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
ntp-4.2.6p5-29.el7.centos.x86_64
可尝试重启NTP服务。
2) 若无以上显示,则应在删除原有ntpdate服务后,重新安装NTP:
[gbase@localhost ~]$ sudo yum -y remove ntpdate-4.2.6p5-29.el7.centos.x86_64
[gbase@localhost ~]$ sudo yum -y install ntp
安装完毕后,同样在所有节点服务器上配置NTP服务。通常,选定GTM节点作为NTP服务主节点。
2. 修改ntp.conf配置文件
按类型分为主节点配置、其他节点配置:
[gbase@localhost ~]$ sudo vi /etc/ntp.conf
(1) NTP主节点修改配置文件,在配置文件中增加以下内容:
restrict 192.168.142.210 nomodify notrap nopeer noquery //当前节点IP
restrict 192.168.142.2 mask 255.255.255.0 nomodify notrap //集群所在网段网关、子网掩码
//server部分注释掉0~n并增加如下内容:
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
修改涉及部分配置文件及修改位置如下:
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 192.168.142.210 nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
restrict 192.168.142.2 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
(2) NTP其他节点修改配置文件,在配置文件中增加:
restrict 192.168.142.211 nomodify notrap nopeer noquery //当前节点IP
restrict 192.168.142.2 mask 255.255.255.0 nomodify notrap //集群所在网段网关、子网掩码
//server部分注释掉0~n并指向主节点:
server 192.168.142.210
Fudge 192.168.142.210 stratum 10
修改涉及部分配置文件及修改位置如下:
# the administrative functions.
restrict 192.168.142.211 nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
restrict 192.168.142.2 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 192.168.142.210
Fudge 192.168.142.210 stratum 10
全部节点配置完成后,在所有节点启动NTP服务:
[gbase@localhost ~]$ sudo service ntpd start
3. 查看NTP服务是否连通
[gbase@localhost ~]$ ntpstat
主节点返回:
ynchronised to local net (127.127.1.0) at stratum 6
time correct to within 7948 ms
polling server every 64 s
其他节点返回:
synchronised to NTP server (192.168.142.210) at stratum 7
time correct to within 903 ms
polling server every 64 s
注意:NTP服务配置完毕后,需要等待5~10分钟才能完成时间同步,如果在配置后提示unsynchronised time server re-starting polling server every 8 s或unsynchronised polling server every 8 s均属正常,等待一段时间再次执行ntpstat命令查看即可。
4. 设置开机自启动
[gbase@localhost ~]$ sudo chkconfig ntpd on
注意:某些虚拟机环境下无法配置NTP开机自启动,需要每次重启后进行手工启动。NTP服务会影响分布式数据库部署及一致性操作,须提前配置生效。
热门帖子
- 12025-12-01浏览数:182764
- 22023-05-09浏览数:25062
- 42023-09-25浏览数:18526
- 52020-05-11浏览数:17529