CentOS7配置时间和CentOS6搭建局域网NTP

NTP

2015年8月20日
星期四

17:34

CentOS 7配置本地时区和TIME ZONE

#用tzselect配置时区和time zone

[[email protected] Asia]# /usr/bin/tzselect

Please identify a location so that time zone rules can be set correctly.

Please select a continent or ocean.

1) Africa

2) Americas

3) Antarctica

4) Arctic Ocean

5) Asia

6) Atlantic Ocean

7) Australia

8) Europe

9) Indian Ocean

10) Pacific Ocean

11) none - I want to specify the time zone using the Posix TZ format.

#选择时区

#? 11

Please enter the desired value of the TZ environment variable.

For example, GST-10 is a zone named GST that is 10 hours ahead (east) of UTC.

#键入CST+0中国时区

#UTC为国际时区

CST+0

awk: cmd. line:5: warning: escape sequence `\.‘ treated as plain `.‘

?

The following information has been given:

?

????TZ=‘CST+0‘

?

Therefore TZ=‘CST+0‘ will be used.

Local time is now:????Thu May 12 18:13:06 CST 2016.

Universal Time is now:????Thu May 12 18:13:06 UTC 2016.

Is the above information OK?

1) Yes

2) No

#? 1

?

You can make this change permanent for yourself by appending the line

????TZ=‘CST+0‘; export TZ

to the file ‘.profile‘ in your home directory; then log out and log in again.

?

Here is that TZ value again, this time on standard output so that you

can use the /usr/bin/tzselect command in shell scripts:

CST+0

[[email protected] Asia]# /usr/bin/tzselect

Please identify a location so that time zone rules can be set correctly.

Please select a continent or ocean.

1) Africa

2) Americas

3) Antarctica

4) Arctic Ocean

5) Asia

6) Atlantic Ocean

7) Australia

8) Europe

9) Indian Ocean

10) Pacific Ocean

11) none - I want to specify the time zone using the Posix TZ format.

#? 5

Please select a country.

1) Afghanistan???????? 18) Israel???????? 35) Palestine

2) Armenia???????? 19) Japan???????? 36) Philippines

3) Azerbaijan???????? 20) Jordan???????? 37) Qatar

4) Bahrain???????? 21) Kazakhstan???? 38) Russia

5) Bangladesh???????? 22) Korea (North)???? 39) Saudi Arabia

6) Bhutan???????? 23) Korea (South)???? 40) Singapore

7) Brunei???????? 24) Kuwait???????? 41) Sri Lanka

8) Cambodia???????? 25) Kyrgyzstan???? 42) Syria

9) China???????? 26) Laos???????? 43) Taiwan

10) Cyprus???????? 27) Lebanon???????? 44) Tajikistan

11) East Timor???????? 28) Macau???????? 45) Thailand

12) Georgia???????? 29) Malaysia???????? 46) Turkmenistan

13) Hong Kong???????? 30) Mongolia???????? 47) United Arab Emirates

14) India???????? 31) Myanmar (Burma)???? 48) Uzbekistan

15) Indonesia???????? 32) Nepal???????? 49) Vietnam

16) Iran???????? 33) Oman???????? 50) Yemen

17) Iraq???????? 34) Pakistan

#? 9

Please select one of the following time zone regions.

1) Beijing Time

2) Xinjiang Time

#? 1

?

The following information has been given:

?

????China

????Beijing Time

?

Therefore TZ=‘Asia/Shanghai‘ will be used.

Local time is now:????Fri May 13 02:13:32 CST 2016.

Universal Time is now:????Thu May 12 18:13:32 UTC 2016.

Is the above information OK?

1) Yes

2) No

#? 1

?

You can make this change permanent for yourself by appending the line

????TZ=‘Asia/Shanghai‘; export TZ

to the file ‘.profile‘ in your home directory; then log out and log in again.

?

Here is that TZ value again, this time on standard output so that you

can use the /usr/bin/tzselect command in shell scripts:

Asia/Shanghai

[[email protected] Asia]# date

Thu May 12 18:13:40 CST 2016

[[email protected] Asia]# clock

Thu 12 May 2016 06:13:44 PM CST -0.396667 seconds

[[email protected] Asia]#

#加入全局环境变量

vi /etc/profile

export TZ=‘CST+0‘

?

#硬件和系统时间同步(可选)

date -s 14:20:50

hwclock? --show 或者

clock? --show

设置硬件时间

hwclock --set --date="06/18/14 14:55" (月/日/年时:分:秒)或者# clock --set --date="06/18/14 14:55" (月/日/年时:分:秒)

硬件时钟与系统时钟同步:

# hwclock --hctosys 或者 # clock --hctosys? hc代表硬件时间,sys代表系统时间,即用硬件时钟同步系统时钟

系统时钟和硬件时钟同步:

# hwclock --systohc或者# clock --systohc? 即用系统时钟同步硬件时钟

修改配置文件来修改时区

?

?

?

CentOS 6搭建局域网NTP服务器

#########服务器:#########

一、时间服务器端配置

修改配置文件vi /etc/ntp.conf

?
?

1、客户端选择

1)允许任何客户端

restrict default nomodify

2)允许特定客户端

restrict 192.168.18.0 mask 255.255.255.0 nomodify

server 192.168.0.84

*二选一

?
?

2、指定时间服务器

1)指定特定时间服务器,注释掉默认server服务器

server time-b.nist.gov

2)开启本地时间服务器,上述外网time-b.nist.gov失效时,内网充当时间服务器。

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10

3、重启时间服务

service ntpd restart

4、根据实际需求设置防火墙端口

udp 123

#########客户端#########

一、linux客户端

1、linux客户端修改配置文件,注释掉其它时间服务器,指定内网时间服务器,重启ok。

vim /etc/ntp.conf

server x.x.x.x

2、客户端校验

ntpq -p查询上级时间服务器

ntpstat 查询状态

ntpdate

时间: 2024-08-30 03:38:58

CentOS7配置时间和CentOS6搭建局域网NTP的相关文章

centos7创建本地源并搭建局域网yum源服务器

1:关闭firewell防火墙[[email protected] ~]# systemctl stop firewelld.service #停止firewell[[email protected] ~]# systemctl disable firewalld.service #禁止firewell开机启动 2:安装并启动vsftpd 查看是否已安装 方法一 [[email protected] ~]# rpm -q vsftpdvsftpd-3.0.2-21.el7.x86_64 查看是否

配置树莓派3和局域网NTP服务器实现内网时间校准

一.配置局域网NTP服务器 1.安装ntp-4.2.8p5-win32-setup.exe 下载地址:https://www.meinbergglobal.com/english/sw/ntp.htm按默认步骤安装即可. 2.修改配置文件ntp.conf 配置文件默认路径为:C:\Program Files (x86)\NTP\etc\ntp.conf去掉 [plain] view plain copy #server 127.127.1.0 #fudge 127.127.1.0 stratum

在Centos7上搭建局域网的yum源仓库

1.#输入命令rmp -q -vsftpd,查看是否安装了该包. 2.#创建挂载点,把光盘挂载到该点 3.#使用命令用rpm-ivh 安装vsftpd安装包 4.#启动vsftpd服务,设为下次开机启动. 5.#输入ifconfig,找到自己的局域网地址,看是否连接超时,如果超时就是没关闭防火墙的原因,那么就关闭防火墙.(学习环境中关闭防火墙就行了,不支持实际工作环境中关闭). 6.#用浏览器访问自己的局域网地址 ,会出现以下页面,说明ftp服务配置成功. 7.#创建文件夹,将CentOS7安装

Linux时间服务器的搭建

今晚无聊,就学着搭建了一个Linux时间服务器,其实挺简单的,这篇文章主要是我的一个总结,大家可以借鉴一下. 需要的软件包:ntp     配置服务器端 1.先检查是否安装了ntp软件包,检查命令  rpm -qa | grep ntp 或者 yum list | grep ntp 2.确认安装了ntp包之后,要架设本地时间服务器,只需要修改 /etc/ntp.conf文件里的几个简单的配置就可以了,vi /etc/ntp.conf 这里只需要添加上谁可以向此服务器发送请求来更新时间. rest

用debian 7.5 cd/dvd 搭建局域网mirror镜像源来批量网络无人值守安装debian

1.图形化最小安装debian7.5操作系统 2.更改debian的apt源配置文件/etc/apt/sources.list [email protected]:~# cat /etc/apt/sources.list deb http://ftp.de.debian.org/debian wheezy main contrib non-free deb-src http://ftp.de.debian.org/debian wheezy main contrib non-free 3.更新a

Linux配置时间服务器

[Author]: kwu Linux配置时间服务器,大数据集群时间同步是非常关键的,误差超过500ms就会有问题,通常配置内网的时间服务器. 本文以CentOS6.6为例介绍内网时间服务器的配置: 1.开启ntpd服务 chkconfig ntpd on chkconfig --list ntpd 2.配置服务端 vi /etc/ntp.conf : server us.pool.ntp.org minpoll 4 fudge 127.127.1.0 stratum 1 restrict 12

基于HTTP搭建局域网YUM源+软件包扩展+同步外网YUM源

1         基于HTTP搭建局域网YUM源(Centos7) 1.1  YUM服务端安装HTTP服务 1)  安装HTTP yum install httpd httpd-devel –y 2)  启动httpd服务 systemctl restart httpd.service setenforce 0  #关闭SELinux systemctl stop firewalld   #临时停止防火墙 1.2  YUM服务端搭建局域网YUM源 1)挂载光盘镜像文件 mount /dev/c

Centos7 配置yum软件仓库

Centos7 配置yum软件仓库 内网yum仓库:本地yum仓库(即以光盘镜像自带软件作为yum软件仓库)局域网yum仓库(ftp服务实现)公网yum仓库(通过http实现) --------------------使用yum仓库去安装服务------------------------------- yum clean all 清除所有仓库缓存 yum makecache 重建仓库 yum repolist all 列出所有仓库 yum provides 根据特定条件搜索软件包 yum wh

Linux自动同步网络时间,并创建本地Ntp服务器。

NTP (Network Time Protocol)作用:将网络中的各个主机的时间进行同步,局域网中的误差<0.1ms架构:C/S实验环境:两台有网络的Centos,其中134为服务端,135为客户端.134同步网络时间,其他服务器同步134时间.1.查看134的系统信息.时间和时区cat /etc/redhat-release datetimedatectl | grep "Time zone"此时可以看到134时区为上海.时间和网络时间不同步2.查看135的系统信息.时间和