当前位置: 首页> 教育> 大学 > 中山网官网_全球疫情最新数据表_网络整合营销公司_谷歌google官方下载

中山网官网_全球疫情最新数据表_网络整合营销公司_谷歌google官方下载

时间:2025/8/22 2:57:51来源:https://blog.csdn.net/Forget_8/article/details/146923666 浏览次数:0次
中山网官网_全球疫情最新数据表_网络整合营销公司_谷歌google官方下载

一、设置时间

-ctl #有子命令

[root@RHCE ~]# date #查看时间

[root@RHCE ~]# date "+%Y-%m-%d %H:%M:%S"

[root@RHCE ~]# timedatectl #查看详细时间

[root@RHCE ~]# timedatectl set-time "2011-11-11 11:11:11" #设置时间为2011年11月11日11时11分11秒

[root@RHCE ~]# timedatectl set-ntp 0/1 #关闭或开启时间服务器(ntp)

[root@RHCE ~]# timedatectl set-local-rtc 0/1 #关闭或开启硬件时间(rtc)

 

二、chrony服务

配置文件保存在etc

命令保存在bin

超级命令保存在sbin

服务保存在server

[root@RHCE ~]# rpm -ql chrony # -ql查看哪些软件(如chrony)产生那些文件

[root@RHCE ~]# rpm -qf chrony # -qf查看哪些文件是由哪些软件产生的(如chrony)

[root@RHCE ~]# systemctl status chronyd #查看chrony服务状态

[root@RHCE ~]# systemctl stop chronyd.server # 关闭chrony服务

[root@RHCE ~]# systemctl start chronyd.server #开启chrony服务

chronyd.server 用来控制时间同步服务

 

[root@RHCE ~]# vim /etc/chrony.conf #查看chrony的配置文件

        # Please consider joining the pool (https://www.pool.ntp.org/join.html).
        #pool(池子) 2.rhel.pool.ntp.org(ip/网址) iburst(立刻同步)

        #server(从池子中获取一台服务器) 2.rhel.pool.ntp.org(ip/网址)iburst(立刻同步)

                pool表示时间服务集群

                server表示从集群中挑选一台时间同步服务器

                iburst表示如果重启会立即同步时间

        ······

[root@RHCE ~]# systemctl restart chronyd #重启chrony服务   

服务都会在命令后加个d,如要重启chrony命令要写成chronyd即chronyd.server

 

三、实验

创建两台虚拟机,一台作为时间服务器(服务端),一台作为服务器获取时间(客户端)

1.创建服务端

[root@RH ~]# hostnamectl hostname timeserver #永久修改名称为timeserver(时间服务器)

[root@RH ~]# reboot #重启虚拟机(想要看到刚修改的名称需要重启虚拟机)

        修改ip要围绕4个点修改:IP地址、子网掩码、dns、网关(手动配置IP地址要注意关闭自动获取IP地址)

[root@timeserver ~]# nmcli connection modify ens160 ipv4.addresses 192.168.153.100/24 #修改IP地址和掩码(要注意自己的虚拟机的网络位,如192.168.153.xxx/24)

[root@timeserver ~]# nmcli connection modify ens160 ipv4.dns 8.8.8.8 #修改dns

[root@timeserver ~]# nmcli connection modify ens160 ipv4.gateway 192.168.153.2 #修改网关(要注意自己虚拟机的网关,默认的网关是多少,就配置多少) 

[root@timeserver ~]# nmcli connection modify ens160 ipv4.method manual #将自动获取IP地址改为手动配置IP地址

[root@timeserver ~]# nmcli connection up ens160 #激活

 

2.创建客户端

[root@RH ~]# hostnamectl hostname timeclient #永久修改名称为timeclient

[root@RH ~]# reboot #重启虚拟机(想要看到刚修改的名称需要重启虚拟机)

[root@timeclient ~]# nmcli connection modify ens160 ipv4.method ipv4.addresses 192.168.153.200/24 ipv4.gateway 192.168.153.2  ipv4.dns 8.8.8.8 #同时将自动改手动,修改IP地址、子网掩码、网关和dns

[root@timeclient ~]# nmcli connection up ens160 #激活

 

3.配置时间服务器

[root@timeserver ~]# vim /etc/chrony.conf

        2 # Please consider joining the pool (https://www.pool.ntp.org/join.html).
        3 #pool 2.rhel.pool.ntp.org iburst #配置服务器,不用与官方匹配就屏蔽掉

        ······

        25 # Allow NTP client access from local network.
        26 allow 0.0.0.0/0 #允许所有人获取时间(允许谁获取时间就把时间写到这)

        ······

        28 # Serve time even if not synchronized to a time source.
        29 local stratum 10 #第10层时间服务器

[root@timeserver ~]# timedatectl set-ntp 0 #关闭时间服务器

[root@timeserver ~]# timedatectl set-time "2011-11-11 11:11:11" #设置时间

[root@timeserver ~]# systemctl stop firewalld.sever #临时(stop)关闭网络防火墙

[root@timeserver ~]# setenforce 0 #关闭内核防火墙

[root@timeserver ~]# systemctl restart chronyd #重启chrony服务

[root@timeserver ~]# watch -n 1 timedatectl #每一秒监控详细时间

 

4.配置客户端同步时间源

[root@timeclient ~]# vim /etc/chrony.conf

        2 # Please consider joining the pool (https://www.pool.ntp.org/join.html).
        3 pool 192.168.153.100 iburst #从timeserver获取时间就把ip改成timeserverIP地址

        ······

[root@timeclient ~]# systemctl restart chronyd #重启chrony服务

[root@timeclient ~]# watch -n 1 timedatectl #每一秒监控详细时间

 

 

关键字:中山网官网_全球疫情最新数据表_网络整合营销公司_谷歌google官方下载

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: