ntp服务搭建

1、系统环境

1.1 系统环境

    本文 测试环境为 Ubuntu 16.04 amd64

# lsb_release -a

2、ntp 服务器端

## 允许BIOS与系统时间同步
# hwclock -w

    

2.1 软件安装

# apt-get install ntp

    

2.2 防火墙设置

    若不需要,直接关闭 防火墙

# ufw disable

    

2.3 配置文件

# cat /etc/ntp.conf
# 系统时间与BIOS事件的偏差记录
driftfile /var/lib/ntp/ntp.drift

# 权限设置
restrict 127.0.0.1
restrict ::1

# 127.127.1.0 本机回环设备地址
server 127.127.1.0

    

2.4 服务

2.4.1 服务 开启/重启

# /etc/init.d/ntp [start | restart]

    

2.4.2 服务 检测

## 如果看到123端口,说明ntp服务成功启动
# netstat -tlunp | grep ntp   

## 查看 ntp服务 同步的状态
# ntpq -p

    

3、ntp 客户端

3.1 软件安装

# apt-get install ntpdate

    

3.2 时间同步

# ntpdate {ntp_server_ip}

猜你喜欢

转载自blog.51cto.com/11495268/2315671
今日推荐