introduce
用于建構cdm所需要的ntp伺服器鏡像,實作主控端和ntpserver同步,ntpserver于ntpclient的同步
項目位址
項目githubimage build
docker image build -t docker.finogeeks.club/linzhihuang/fino-cdm-ntp:v2.0
run
docker run --rm -it docker.finogeeks.club/linzhihuang/fino-cdm-ntp:v2.0
run cluster
docker compose up
config
我們通過下面的幾步來完成ntp服務端和用戶端的搭建
- 在server的服務機器上我們通過
讓docker和伺服器的時間保持一緻volumes: - /etc/localtime:/etc/localtime:ro
- 在server的服務上還需要配置/etc/ntp.conf,方式如下shell
rm /etc/ntp.conf cat >> /etc/ntp.conf <<EOF # 中國這邊最活躍的時間伺服器 : http://www.pool.ntp.org/zone/cn server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org # allow update time by the upper server restrict 0.cn.pool.ntp.org nomodify notrap noquery restrict 0.asia.pool.ntp.org nomodify notrap noquery restrict 3.asia.pool.ntp.org nomodify notrap noquery # Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. # 外部時間伺服器不可用時,以本地時間作為時間服務 server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 EOF
- 在client的服務上對/etc/ntp/。方式如下shell
echo "server ${NTP_SERVER_HOSTNAME} prefer" >> /etc/ntp.conf echo "restrict ${NTP_SERVER_HOSTNAME} " >> /etc/ntp.conf