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
サービスを再起動する必要があります。そうしないと、サービスが有効にならない可能性があります。