本来这篇文章是想讲puppet的,但是今天有两个同事不在,特别特别忙,在一个现在Puppet也不是特别火,做以决定以后有机会在总结吧,先总结下做puppet之前的时间同步吧
好久不用Ntp了发现自己全都忘了,知识这个东西不用就会忘,但是捡起来很容易
同步时间:
[root@linux-szge ~]# rpm -q ntp ntp-4.2.6p5-1.el6.centos.x86_64
ntpdate 192.168.1.18520 Feb 01:19:33 ntpdate[23968]: no server suitable for synchronization found(同步失败,原因是我的185服务器上默认拒绝所有IP的时间同步) 在185机器ntp.conf上添加一行 restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
[root@linux-szge ~]# ntpdate 192.168.1.185 (再次同步,成功)19 Feb 17:24:07 ntpdate[23991]: adjust time server 192.168.1.185 offset -0.000145 sec 但是发现时间好像不对啊,我擦,我185上的时间不是这个啊,于是查找原因[root@linux-szge ~]# dateSun Feb 19 17:24:15 PST 2017
尝试同步亚洲时间服务器,但是发现时间还是不对,这就断定了是我机器的配置问题了 [root@linux-szge ~]# /usr/sbin/ntpdate cn.pool.ntp.org19 Feb 17:27:24 ntpdate[23999]: adjust time server 115.28.122.198 offset 0.039672 sec
[root@linux-szge ~]# dateSun Feb 19 17:28:50 PST 2017[root@linux-szge ~]# /usr/sbin/ntpdate cn.pool.ntp.org19 Feb 17:28:56 ntpdate[24023]: adjust time server 52.187.51.163 offset -0.006311 sec[root@linux-szge ~]# date Sun Feb 19 17:29:00 PST 2017
手动修改时区 [root@linux-szge ~]# tzselect Please identify a location so that time zone rules can be set correctly.Please select a continent or ocean. 1) Africa 2) Americas 3) Antarctica 4) Arctic Ocean 5) Asia 6) Atlantic Ocean 7) Australia 8) Europe 9) Indian Ocean10) Pacific Ocean11) none - I want to specify the time zone using the Posix TZ format.#? 5Please select a country. 1) Afghanistan 18) Israel 35) Palestine 2) Armenia 19) Japan 36) Philippines 3) Azerbaijan 20) Jordan 37) Qatar 4) Bahrain 21) Kazakhstan 38) Russia 5) Bangladesh 22) Korea (North) 39) Saudi Arabia 6) Bhutan 23) Korea (South) 40) Singapore 7) Brunei 24) Kuwait 41) Sri Lanka 8) Cambodia 25) Kyrgyzstan 42) Syria 9) China 26) Laos 43) Taiwan10) Cyprus 27) Lebanon 44) Tajikistan11) East Timor 28) Macau 45) Thailand12) Georgia 29) Malaysia 46) Turkmenistan13) Hong Kong 30) Mongolia 47) United Arab Emirates14) India 31) Myanmar (Burma) 48) Uzbekistan15) Indonesia 32) Nepal 49) Vietnam16) Iran 33) Oman 50) Yemen17) Iraq 34) Pakistan#? 9Please select one of the following time zone regions.1) Beijing Time2) Xinjiang Time#? 1The following information has been given: China Beijing TimeTherefore TZ='Asia/Shanghai' will be used.Local time is now: Mon Feb 20 09:34:38 CST 2017.Universal Time is now: Mon Feb 20 01:34:38 UTC 2017.Is the above information OK?1) Yes2) No#? 1You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZto the file '.profile' in your home directory; then log out and log in again.Here is that TZ value again, this time on standard output so that youcan use the /usr/bin/tzselect command in shell scripts:Asia/Shanghai
修改完时区发现时间还不对,我就迷茫了,但是发现上面有一行提示 [root@linux-szge ~]# date Sun Feb 19 17:29:00 PST 2017You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZto the file '.profile' in your home directory; then log out and log in again.
尝试一下,输入命令,切换下,成功 [root@linux-szge ~]# TZ='Asia/Shanghai'; export TZ [root@linux-szge ~]# su[root@linux-szge ~]# date Mon Feb 20 09:29:26 CST 2017