zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    代码抄袭检测系统的设计和实现(1)--需求分析和基础架构
    Protobuf C/C++实战笔记(1)
    自动构建Makefile(1)--C/C++编译流程&Makefile规则简介
    初识storm
    Ubuntu 16.04LTS安装Nginx
    redis内存监控与回收
    RabbitMQ交换机规则实例
    git合并分支上指定的commit
    git忽略掉文件权限检查
    git修改文件权限方式
  • 原文地址:https://www.cnblogs.com/walkersss/p/12550762.html
Copyright © 2011-2022 走看看