Linuxクラスタ:ntp時間サーバ同期&データベース時間同期
4301 ワード
[root@10-121-2-96 opt]# rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm
warning: autogen-libopts-5.18-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:autogen-libopts-5.18-5.el7 ################################# [100%]
[root@10-121-2-96 opt]# rpm -ivh ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm
warning: ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:ntpdate-4.2.6p5-18.el7.centos ################################# [100%]
[root@10-121-2-96 opt]# rpm -ivh ntp-4.2.6p5-18.el7.centos.x86_64.rpm
warning: ntp-4.2.6p5-18.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:ntp-4.2.6p5-18.el7.centos ################################# [100%]
# ntp server 10.121.2.106:
[root@10-121-2-106 opt]# vi /etc/ntp.conf
restrict 10.121.2.106 mask 255.255.255.0 nomodify notrap #
server 127.127.1.0 # ,
fudge 127.127.1.0 stratum 10
[root@10-121-2-106 opt]# service ntpd restart
Redirecting to /bin/systemctl restart ntpd.service
[root@10-121-2-106 opt]# systemctl disable chronyd.service
[root@10-121-2-106 opt]# systemctl enable ntpd.service #
[root@10-121-2-106 opt]# ntpstat
synchronised to local net at stratum 11
time correct to within 7948 ms
polling server every 64 s
[root@10-121-2-106 opt]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-07-06 09:18:49 CST; 22s ago
Process: 12428 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 12429 (ntpd)
CGroup: /system.slice/ntpd.service
└─12429 /usr/sbin/ntpd -u ntp:ntp -g
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen and drop on 1 v6wildcard :: UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 2 lo 127.0.0.1 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 3 bond0 10.121.2.106 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 4 lo ::1 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listen normally on 5 bond0 fe80::92ec:baff:fe20:e0f2 UDP 123
Jul 06 09:18:49 adrmbda106 ntpd[12429]: Listening on routing socket on fd #22 for interface updates
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c016 06 restart
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Jul 06 09:18:49 adrmbda106 ntpd[12429]: 0.0.0.0 c011 01 freq_not_set
Jul 06 09:18:50 adrmbda106 ntpd[12429]: 0.0.0.0 c514 04 freq_mode
# ntp client 96-105 : 105 :
[root@10-121-2-96 opt]# vi /etc/ntp.conf
server 10.121.2.106 #
:
1. ntp-server ip ntp-client 。
2.hwclock --systohc ( )
:crontab -e
:*/10 * * * * /usr/sbin/ntpdate -u 10.121.2.106 >/dev/null 2>&1
service crond restart
:
##
select now()
## :#time_zone mysql system ,system_time_zone system CST
show variables like "%time_zone%";
## mysql , 8
set global time_zone = '+8:00';
##
set time_zone = '+8:00';
##
flush privileges;
注:
1.Libuxで使用する data-s「2018-10-15:00」 -------------オペレーティングシステム時間の変更
2.データベース内 表示 select now() -------------操作時間と一致していますか?