linux 构建ntp 服务器

linux 构建ntp 服务器

  1. 安装ntp程序后服务器即使ntp服务器端又是ntp客户端,启用了ntp服务,同时在本机执行ntpdate 同步时间会出现问题"the NTP socket is in use, exiting",解决办法是停止本机的ntp服务程序。
    NTP (server,client) 向上同步时间信息,向下提供时间同步信息
    NTP Client ( windwos、linux)向上同步时间信息

Windows Linux 客户端同步时间方法

  1. ntp服务器监听udp端口 123

  2. 安装程序
    yum install ntp ntpdate -y

  3. 修改配置文件
    修改ntp.conf配置文件
    [root@localhost ntp]# cp /etc/ntp.conf /etc/ntp.conf.bak
    [root@localhost ntp]# vi /etc/ntp.conf
    [root@localhost ntp]# systemctl enable ntpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
    [root@localhost ntp]# systemctl restart ntpd

  4. 在客户端加入计划任务
    crontab -e
    10 06 * * * /usr/sbin/ntpdate ntp-server ip >> /usr/local/logs/crontab/ntpdate.log

  5. 服务常用命令
    service ntp status # 查看服务状态
    service ntpd start #启动服务
    chkconfig ntpd on # 开机自启动
    chkconfig --list ntpd # 检查设置

你可能感兴趣的:(操作系统,linux)