Article Directory
- Step 1: Determine whether to install the ntpd service
- Step Two: Determine whether to open service ntpd
- The third step: turn off the firewall iptables
- Step four: Turn off selinux
- Step Five: Modify the ntp configuration file
- Step Six: Modify the second profile
- Step seven: Restart ntpd service
- Step eight: Initial sync on another virtual machine
- Step 9: automatically setting the timing synchronization tasks
- Step 10: After modifying the view scheduled tasks completed
- At last:
Step 1: Determine whether to install the ntpd service
rpm -qa | grep ntpd
If not
using the yum -y install ntpd
installed ntpd service
Step Two: Determine whether to open service ntpd
service ntpd status
If you do not start
using the service ntpd start
start, 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
Step Five: Modify the ntp configuration file
Network time synchronization directly ntpdate ntp4.aliyun.com
with Ali cloud server time synchronization on the line
vi /etc/ntp.conf
Notes the following
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
这些内容也可以直接添加在配置文件最下面
Step Six: Modify the second profile
//打开配置文件
vi /etc/sysconfig/ntpd
Add the following
SYNC_HWLOCK=yes
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
Step 10: After modifying the view scheduled tasks completed
crontab -l
See the following instructions to modify succeeded
Comment:
5 * represent the regular tasks of
sub-hour day week month
grammar
分 小时 天 月 星期 要执行的代码
At last:
如果有不对的地方欢迎给本人留言,本人会及时改正