linux cluster time synchronization (not networked)

Step 1: Determine whether to install the ntpd service

rpm -qa | grep ntpd  

Here Insert Picture Description
If not
using the yum -y install ntpdinstalled ntpd service

Step Two: Determine whether to open service ntpd

service ntpd status

Here Insert Picture Description
If you do not start
using the service ntpd startstart, and not set to boot from Kaichkconfig ntpd on

The third step: turn off the firewall iptables

关闭防火墙
service iptables stop
设置为开机不自启
chkconfig iptables off

Step four: Turn off selinux

//打开selinux配置文件
vi /etc/selinux/config

The selinux attributes to disabled
careful not to changeselinuxtype
Here Insert Picture Description

Step Five: Modify the ntp configuration file

Network time synchronization directly ntpdate ntp4.aliyun.comwith Ali cloud server time synchronization on the line

vi /etc/ntp.conf

Notes the following
Here Insert Picture Description
to add the following

restrict 192.168.100.0  mask  255.255.255.0 nomodify  notrap 	

​server	127.127.1.0  #  localclock

fudge	127.127.1.0  stratum  10

Here Insert Picture Description
这些内容也可以直接添加在配置文件最下面

Step Six: Modify the second profile

//打开配置文件
vi /etc/sysconfig/ntpd

Add the following

SYNC_HWLOCK=yes

Here Insert Picture Description

Step seven: Restart ntpd service

service ntpd restart

Step eight: Initial sync on another virtual machine

ntpdate 主机ip
如:
ntpdate 192.168.100.123
或者 
ntpdate  node01 (此项需要进行配置 对主机ip进行命名)
//配置方法可以看我的另一篇博客地址如下(从第三步开始):
https://blog.csdn.net/hongchenshijie/article/details/102669331

Step 9: automatically setting the timing synchronization tasks

打开定时任务文本
crontab -e

Set hourly synchronizations (customize)

* */1 * * * /user/sbin/ntpdate 主机ip
* */1 * * * /user/sbin/ntpdate 192.168.100.201
* */1 * * * /user/sbin/ntpdate node01

Here Insert Picture Description

Step 10: After modifying the view scheduled tasks completed

crontab -l

See the following instructions to modify succeeded
Here Insert Picture Description
Comment:
5 * represent the regular tasks of
sub-hour day week month
grammar

分  小时   天  月  星期   要执行的代码

At last:

如果有不对的地方欢迎给本人留言,本人会及时改正
Published 88 original articles · won praise 114 · Views 2989

Guess you like

Origin blog.csdn.net/hongchenshijie/article/details/102775603