搭建时间服务器(linux) |
您所在的位置:网站首页 › 和欧盟类似的组织是什么 › 搭建时间服务器(linux) |
我们搭建集群环境的时候,时间必须是要统一的,才能保证集群数据的一致性。 一般操作是直接使用NTP,跟默认的时间服务器同步,但是最好还是让所有节点跟集群中的某台作为时间服务器的节点同步。 步骤:(节点有NameNode1,NameNode2,DataNode1,DataNode2,DataNode3) 选择一台服务器作为时间服务器。(DataNode1做为时间服务器) 使用root用户,查看服务器是否安装ntp服务 rpm -qa|grep ntp没有安装的话使用yum install进行安装。 修改文件 /etc/ntp.conf,一共修改三处内容: ①将#去掉。并且将网段修改正确。 restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap ②将以下4个server进行#注释掉 #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 127.127.1.0 #local clock fudge 127.127.1.0 stratum 10 编辑etc/sysconfig/ntpd文件 # Drop root to id 'ntp:ntp' by default. SYNC_HWCLOCK=yes OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"启动ntpd服务,并且设置开机启动 systemctl start ntpd.service systemctl enable ntpd.service每个需要同步的子节点进行确认有没有ntp。如果没有的话就安装下。 root账户下在每个需要同步的子节点编写crontab任务(crontab -e)。这个任务的意义就是每10分钟和master01同步下服务器时间。 0-59/10 * * * * /usr/sbin/ntpdate master01.timer.cn
附: 1.作为时间服务器的节点的时间校准可以是人工指定(不与其他集群协作的情况下),也可以是跟其他组织的时间服务器同步 这里只说第二种情况。首先要确认当前服务器的时区 将时区设为上海 rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime然后通过定时任务,与阿里云的时间服务器 ntp1.aliyun.com 同步(方法同上面第10步,ntp1~ntp7)
2.不同操作系统之间也是可以做时间同步的。linux与windows之间同步是没问题的。 |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |