每个服务器系统,时钟的同步时非常重要的。经常使用windows的人知道,windows的时间特别好设置,都是界面化的。但是,linux则看着比较复杂,本文就以centos为例,教会您时钟同步的安装、配置及使用。一、搭建时间同步服务器1、rpm包的安装: rpm -Uvh ntp***.rpm 2、yum安装 # yum install ntpdate -y 二、配置文件:1、配置文件位置: /etc/ntp.conf 2、配置简例: vi /etc/ntp.conf (1)、允许任何IP的客户机都可以进行时间同步 将“restrict default nomodify notrap noquery”这行修改成:restrict default nomodify notrap (2)、只允许某网段的客户机进行时间同步 在restrict default nomodify notrap noquery之后增加:restrict *.*.*.* mask 255.255.255.0 nomodify notrap 三、启动服务service ntpd start chkconfig ntpd on 四、设置ntp服务的server地址五、注意事项检查iptables是否屏蔽了upd 123端口,或者使用如下命令关闭软件防火墙看看是否有效果。 #service iptables stop 最后提及一点,ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件。在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样,就可以让硬件时间与系统时间一起同步。 |
|