centos7.1-离线-ntpd服务器搭建

一、服务器节点:

1.如果需要更改防火墙请参考如下步骤,不需要请忽略:

将firewall改为iptables

1、关闭firewall防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、将iptables的rpm包放到服务器上,安装

yum -y install iptables*.rpm

3.设置 iptables service

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

-A INPUT -m tcp -p tcp --dport 8080 -m mark --mark 0x64 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22000 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22100 -j ACCEPT

#-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT

 

2. 停止chrony的服务和开机启动

systemctl stop chronyd.service

systemctl disable chronyd.service

3. ntp相关rpm包获取地址:https://pan.baidu.com/s/1ZWn5JOeQsCGvqjQDimpDdg

安装顺序:

rpm -Uvh autogen-libopts-5.18-5.el7.x86_64.rpm

rpm -Uvh ntpdate-4.2.6p5-25.el7.centos.x86_64.rpm

rpm -ivh ntp-4.2.6p5-25.el7.centos.x86_64.rpm 

4.修改配置文件ntp.conf  :    vi /etc/ntp.conf,注释server *.centos.pool.ntp.org,

并取消 server 127.127.1.0的注释,保存

指令:systemctl restart ntpd.service

5.设置ntpd开机启动

systemctl start ntpd

systemctl status  ntpd   至此ntpd应该是running了。

systemclt enable ntpd.service  设置开机启动

常见问题:

即使 123端口看起来没有listen,也可以用客户端ntpdate试一试,一般可以连接。

二、客户端节点:

which ntpdate  查看ntpdate 的位置的方法

常见问题:查看123端口数是否被占用

客户端节点如果开了ntpd服务器节点,需要kill然后ntpdate

猜你喜欢

转载自blog.csdn.net/jpmsdn/article/details/81126340