• NTP建 时间服务器



    一般操作是直接使用NTP,跟默认的时间服务器同步,但是最好还是让所有节点跟集群中的某台作为时间服务器的节点同步。

    步骤:
        选择一台服务器作为时间服务器。
        使用root用户,查看服务器是否安装ntp服务

        rpm -qa|grep ntp

         没有安装的话使用
    yum install -y ntpd

          修改文件 /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 192.168.xx.xx


    将时区设为上海

    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

    然后通过定时任务,与阿里云的时间服务器 ntp1.aliyun.com 同步


    iptables -I INPUT -p udp --dport 123 -j ACCEPT



    其他命令:


    1.  安装ntpdate工具
        # yum -y install ntp ntpdate

    2.  设置系统时间与网络时间同步
        # /usr/sbin/ntpdate ntp1.aliyun.com

    3.  将系统时间写入硬件时间
        # hwclock --systohc

    4.强制系统时间写入CMOS中防止重启失效
          hwclock -w  

          clock -w

  • 相关阅读:
    三 zookeeper集群搭建
    一 linux 基本操作
    linux x64 安装 node
    docker nginx/1.7.4
    搭建Portainer可视化界面
    Swarm搭建 Docker集群
    在 Centos7.4上安装docker
    js 处理json对象数据
    生产者消费者模式及其存在的问题
    多线程
  • 原文地址:https://www.cnblogs.com/walkersss/p/12550762.html
Copyright © 2020-2023  润新知