Linux中的同步时间服务

第一种方式:同步到网络时间服务器

 # ntpdate time.windows.com

将硬件时间设置为当前系统时间。

#hwclock –w 

加入crontab:
30 8 * * * root /usr/sbin/ntpdate 192.168.0.1; /sbin/hwclock -w
每天的8:30将进行一次时间同步。
重启crond服务:

service crond restart

第二种方式:同步到局域网内部的一台时间同步服务器

搭建时间同步服务器
1、编译安装ntp server

rpm -qa | grep ntp

若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用

rpm -Uvh ntp***.rpm

进行安装。
2、修改ntp.conf配置文件

vi /etc/ntp.conf

①、第一种配置:允许任何IP的客户机都可以进行时间同步

将“restrict default nomodify notrap noquery”这行修改成:
restrict default nomodify notrap

配置文件示例:/etc/ntp.conf
②、第二种配置:只允许192.168.211.*网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:

restrict 192.168.211.0 mask 255.255.255.0 nomodify notrap

3、启动ntp服务

service ntpd start

开机启动服务

chkconfig ntpd on

4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

你可能感兴趣的:(大数据,Hadoop,大数据)