ntp时间同步
首先查看是否安装了ntp
rpm -q ntp
如果安装会显示ntpdate-4.2.6p5-1.el6.x86_64
未安装则安装ntp
yum -y install ntp
或者
rpm -ivh --nodeps ntpdate-4.2.6p5-25.e17.centos.2.x86_64.rpm autogen-libopts-5.18-5.e17.x86_64.rpm ntp-4.2.6p5-25.e17.centos.2.x86_64.rpm
安装完成执行vi /etc/ntp.conf
配置文件格式如下,注释掉四行server,并在下面添加一行server。
# grep ^[^#] /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
#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 114.2.131.26 IP为ntp服务器ip地址
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
重启
systemctl restart ntpd.service
第一次手动更新时间
ntpdate -u 114.2.131.26(ntp服务器ip)
配置开机自启动
chkconfig ntpd on
查看ntp主节点是否正确
watch ntpq -p
第一列即为ntp服务器的ip。