在我们实施项目时,很多时候linux主机之间都需要做时间同步,这时候就用到了NTP技术
以典型的服务器端和客户端为例做讲解
一、NTP Server端
1、安装需要的软件包
# yum install -y ntp ntpdate ntp-doc
2、开机启动服务
# chkconfig ntpd on
3、编辑配置文件
# vi /etc/ntp.conf
添加
server 127.127.1.0 #local clock
把下边的内容做注释
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
二、NTP客户端
1、安装需要的软件包
# yum install -y ntp ntpdate ntp-doc
2、开机启动服务
# chkconfig ntpd on
3、编辑配置文件
# vi /etc/ntp.conf
把下边内容做注释
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::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 10.231.29.10
4、执行时间同步命令
ntpdate -u