CentOS項目執行個體之八--NTP時鐘伺服器配置

來源:互聯網
上載者:User

標籤:伺服器   項目   

1. ZZSRV1上的NTP配置1.1. 安裝NTP

# yum list | grep ntp

ntpdate.x86_64                             4.2.6p5-18.el7.centos       @anaconda

fontpackages-devel.noarch                  1.44-8.el7                  base

fontpackages-filesystem.noarch             1.44-8.el7                  base

fontpackages-tools.noarch                  1.44-8.el7                  base

ntp.x86_64                                 4.2.6p5-18.el7.centos       base

ntp-doc.noarch                             4.2.6p5-18.el7.centos       base

ntp-perl.noarch                            4.2.6p5-18.el7.centos       base

sntp.x86_64                                4.2.6p5-18.el7.centos       base


# rpm -qa | grep ntp

ntpdate-4.2.6p5-18.el7.centos.x86_64


手工校對一下時間, 現有生產環境中有一個時鐘伺服器192.168.1.11


# ntpdate 192.168.1.11

11 Aug 20:01:57 ntpdate[2450]: adjust time server 192.168.1.11 offset -0.082365 sec


# hwclock --systohc


# yum -y install ntp

autogen-libopts-5.18-5.el7.x86_64.rpm

ntp-4.2.6p5-18.el7.centos.x86_64.rpm


1.2. 配置

# rpm -qc ntp

/etc/ntp.conf

/etc/ntp/crypto/pw

/etc/sysconfig/ntpd


# cd /etc/

# cp ntp.conf ntp.conf.origin


# vi ntp.conf

刪除所有內容,僅保留上遊伺服器

server 0.centos.pool.ntp.org

server 1.centos.pool.ntp.org

server 2.centos.pool.ntp.org

server 3.centos.pool.ntp.org


# service ntpd start

Redirecting to /bin/systemctl start  ntpd.service


查看日誌

systemd: Starting Network Time Service...

ntpd[2622]: ntpd [email protected] Wed Jun 18 21:20:36 UTC 2014 (1)

ntpd[2623]: proto: precision = 0.203 usec

ntpd[2623]: 0.0.0.0 c01d 0d kern kernel time sync enabled

ntpd[2623]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123

ntpd[2623]: Listen and drop on 1 v6wildcard :: UDP 123

ntpd[2623]: Listen normally on 2 lo 127.0.0.1 UDP 123

ntpd[2623]: Listen normally on 3 eno16777728 192.168.188.11 UDP 123

ntpd[2623]: Listen normally on 4 lo ::1 UDP 123

ntpd[2623]: Listen normally on 5 eno16777728 fe80::20c:29ff:fea4:2e39 UDP 123

ntpd[2623]: Listening on routing socket on fd #22 for interface updates

systemd: Started Network Time Service.

ntpd[2623]: 0.0.0.0 c016 06 restart

ntpd[2623]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM

ntpd[2623]: 0.0.0.0 c011 01 freq_not_set

ntpd[2623]: 0.0.0.0 c614 04 freq_mode


# systemctl enable ntpd

ln -s ‘/usr/lib/systemd/system/ntpd.service‘ ‘/etc/systemd/system/multi-user.target.wants/ntpd.service‘


# netstat -an | grep 123

udp   0 0 192.168.188.11:123      0.0.0.0:*

udp   0 0 127.0.0.1:123           0.0.0.0:*

udp   0 0 0.0.0.0:123             0.0.0.0:*

udp6  0 0 fe80::20c:29ff:fea4:123 :::*

udp6  0 0 ::1:123                 :::*

udp6  0 0 :::123                  :::*

unix  3 [ ]         STREAM     CONNECTED     12323

unix  3 [ ]         STREAM     CONNECTED     16123

unix  3 [ ]         STREAM     CONNECTED     12324    /run/systemd/journal/stdout


1.3. 測試

在另外一台Linux上進行校時

# ntpdate 192.168.188.11

11 Aug 20:18:15 ntpdate[12840]: adjust time server 192.168.188.11 offset 0.004473 sec


在Windows上進行校時,成功


設定自動校時

# rpm -qc crontabs

/etc/crontab

/etc/sysconfig/run-parts


撰寫每天進行校時指令碼

# cd /etc/cron.daily/

# ll

total 16

-rwxr-xr-x. 1 root root 332 Jun 27 19:07 0yum-daily.cron

-rwx------. 1 root root 180 Jul 31  2013 logrotate

-rwxr-xr-x. 1 root root 618 Mar 18 00:19 man-db.cron

-rwxr-x---. 1 root root 192 Jan 27  2014 mlocate



# vi checktime.sh

ntpdate 192.168.188.11

hwclock --systohc


# chmod +x checktime.sh


測評一下指令碼

# ./checktime.sh

11 Aug 20:25:49 ntpdate[12897]: adjust time server 192.168.188.11 offset 0.003041 sec


# ll

total 20

-rwxr-xr-x. 1 root root 332 Jun 27 19:07 0yum-daily.cron

-rwxr-xr-x  1 root root  41 Aug 11 20:25 checktime.sh

-rwx------. 1 root root 180 Jul 31  2013 logrotate

-rwxr-xr-x. 1 root root 618 Mar 18 00:19 man-db.cron

-rwxr-x---. 1 root root 192 Jan 27  2014 mlocate



本文出自 “劉瓊@天道酬勤” 部落格,請務必保留此出處http://lqiong.blog.51cto.com/8170814/1559078

CentOS項目執行個體之八--NTP時鐘伺服器配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.