Linux 時刻同期サービス-chronyd

Linux時刻同期サービス -chronyd

インストール

パッケージ インストール ツールを使用して、chrony以下をインストールしますntp

  • Arch Linuxシリーズ:

    sudo pacman -S ntp chrony
    
  • Debianシリーズ:

    sudo apt install ntp chrony
    
  • Red Hatシリーズ:

    sudo yum install ntp chrony
    

    または

    sudo dnf install ntp chrony
    

構成

chrony設定ファイルで、元のタイミングNTPサーバーをコメントし、Alibaba または Tencent タイミング サーバーの URL を入力しますNTP。例は次のとおりです。

### SPECIFY YOUR NTP SERVERS
# Most computers using chrony will send measurement requests to one or
# more 'NTP servers'.  You will probably find that your Internet Service
# Provider or company have one or more NTP servers that you can specify.
# Failing that, there are a lot of public NTP servers.  There is a list
# you can access at http://support.ntp.org/bin/view/Servers/WebHome or
# you can use servers from the pool.ntp.org project.

#! server 0.arch.pool.ntp.org iburst
#! server 1.arch.pool.ntp.org iburst
#! server 3.arch.pool.ntp.org iburst

#pool 2.arch.pool.ntp.org iburst

# The URL of Tencent NTP network time server is as follows:
! server ntp.tencent.com iburst
! server ntp2.tencent.com iburst
! server ntp3.tencent.com iburst
! server ntp4.tencent.com iburst
! server ntp5.tencent.com iburst

# The URL of Ali NTP network time server is as follows:
! server ntp.aliyun.com iburst
! server ntp1.aliyun.com iburst
! server ntp2.aliyun.com iburst
! server ntp3.aliyun.com iburst
! server ntp4.aliyun.com iburst
! server ntp5.aliyun.com iburst
! server ntp6.aliyun.com iburst
! server ntp7.aliyun.com iburst

pool ntp1.tencent.com

知らせ:

そのうち 3 つまたは 4 つを選択してください。

② 次のコマンドを入力して、ファイアウォールがchronydサービスを通過できるようにし、chronydサービスがスムーズに実行できるようにします。

  • Firewalld設定:

    $ firewall-cmd --add-service=ntp --permanent
    $ firewall-cmd --reload
    
  • Ufw設定:

    $ sudo ufw allow ntp
    $ sudo ufw allow out ntp
    

管理

systemctlコマンドを使用してchronyd、起動時にサービスが自動的に開始できるようにしたり、chronydサービスの開始を有効にしたり、chronydサービスの実行ステータスを表示したりできます。具体的なコマンドは次のとおりです。

# systemctl start chronyd.service    #启动
# systemctl status chronyd.service     #查看
# systemctl enable chronyd.service    #设置开机启动

次のコマンドを使用して、時刻同期ソースを表示します。

$ chronyc sources -v

次のコマンドを使用して、時刻同期ソースのステータスを確認します。

$ chronyc sourcestats -v

次のコマンドを使用して、NTP 時刻同期を有効にします。

$ timedatectl set-ntp yes

次のコマンドを使用してタイム サーバーを調整します。

$ chronyc tracking

知らせ:

構成/etc/chrony.confが完了、chronyサービスを再起動する必要があります。そうしないと、サービスが有効にならない可能性があります。

おすすめ

転載: blog.csdn.net/GaaraZ/article/details/127424633