Centos6、Centos7下的NTP时间同步

mac2024-02-23  46

Centos6

rpm -q ntp 查看是否安装ntp

yum install ntp 安装ntp,已安装则跳过此步骤chkconfig --list ntpd 查看

chkconfig ntpd on 设置开机自启动chkconfig --list ntpd 查看

vi /etc/ntp.conf 配置同步ntp-server时间,贴出变动内容如下,10.82.71.73为对时服务器 #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-server的机器 server 10.82.71.73 restrict 10.82.71.73 nomodify notrap noquery server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 vi /etc/sysconfig/ntpd 设置时钟同步,文件内容如下 # Drop root to id 'ntp:ntp' by default. SYNC_HWCLOCK=yes OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g" service ntpd start 启动ntp服务ntpdate -u 10.82.71.73 手动同步一次时间

Centos7

与Centos6大致相同,执行结果参考上面,如下

rpm -qa | grep ntp 查看是否安装ntpyum install ntp ntpdate -y 安装ntp,已安装则跳过此步骤systemctl status ntpd 查看ntp服务器状态vi /etc/ntp.conf 配置同步ntp-server时间,文件内容如下systemctl start ntpd 启动ntp服务systemctl enable ntpd 设置开机启动ntpdate -u 10.82.71.73手动同步一次时间
最新回复(0)