linux集群时间同步以及时区问题

说明:由于大数据中,集群对时间要求很高,所以集群内主机要经常同步时间(包括时区的同步)。

常用的手动进行时间的同步
date -s “2017-03-03 03:03:03”
或者网络同步:
yum install ntpdate
ntpdate cn.pool.ntp.org

还可以进行如下的设置:

1、yum install ntp

2、vi /etc/ntp.conf

修改如下部分:
server 58.220.207.226 iburst
server 47.92.108.218 iburst
server 202.112.29.82 iburst
server 202.108.6.95 iburst

其中ip为全球可用的ntp时间服务器,免费提供授时服务。

3、配置之后,保存设置,重启服务

service ntpd stop

service ntpd start

4、甚至可以设置crontab来定时与互联网服务器进行同步

          • /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1

时区转换为上海东八区:步骤
tzselect命令
选择 5(Asia)亚洲
选择9 中国
选择 1
选择 1
一、修改时区:

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

修改为中国的东八区

vi /etc/sysconfig/clock

ZONE=“Asia/Shanghai”
UTC=false
ARC=false

如果时间还是相差八个小时

在 /etc/profile文件中增加一行
TZ=‘Asia/Shanghai’ ; export TZ=‘CST-8’
使文件立即生效

source /etc/profile 或者 . /etc/profile

猜你喜欢

转载自blog.csdn.net/weixin_44654375/article/details/87648793
今日推荐