时间同步-ntp服务器的搭建(docker版本)
生活随笔
收集整理的這篇文章主要介紹了
时间同步-ntp服务器的搭建(docker版本)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
introduce
用于構建cdm所需要的ntp服務器鏡像,實現宿主機和ntpserver同步,ntpserver于ntpclient的同步
項目地址
項目github
image build
docker image build -t docker.finogeeks.club/linzhihuang/fino-cdm-ntp:v2.0run
docker run --rm -it docker.finogeeks.club/linzhihuang/fino-cdm-ntp:v2.0run cluster
docker compose upconfig
我們通過下面的幾步來完成ntp服務端和客戶端的搭建
在server的服務機器上我們通過
volumes:- /etc/localtime:/etc/localtime:ro讓docker和服務器的時間保持一致
在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總結
以上是生活随笔為你收集整理的时间同步-ntp服务器的搭建(docker版本)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编程之美——2.7 求最大公约数
- 下一篇: centos 6.5 关闭防火墙