- 有外网
1.有外网的情况下直接通过命令安装
#查询是否安装了ntp
rpm -qa | grep ntp
#没有则安装
yum install -y ntp
2.配置同步目标server
## 注释原有server开头的服务配置,指定server为当前节点
vi /etc/ntp.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool ().
#注释掉原来的
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 10.0.0.1 ## 添加行,目标IP
3.启动ntpd 服务并设置开机自动启动
#查看npt状态
systemctl status ntpd
#启动ntpd
systemctl start ntpd
#重启ntpd-看情况执行
systemctl restart ntpd
#设置开机启动
systemctl enable ntpd.service
- 没外网
配置yum源,利用局域网内部yum源进行镜像安装
#切到yum源目录下
cd /etc/yum.repos.d/
#创建备份
mkdir bak/
mv *.repo bak/
#把yum源复制一份到yum下
cp bak/CentOS-Media.repo .
#编辑配置文件,指定到yum源路径
vim CentOS-Media.repo
#修改baseurl和enabled如下:
baseurl=http://10.80.6.180:8888/centos7
enabled=1
#清空缓存并重新建立缓存:
yum clean all
yum makecache
#查看yum列表
yum list
#yum安装ntp
yum -y install ntp
#后续的步骤同有外网步骤了