# 第三章 配置日期和时间

### 国内外常用公共NTP网络时间服务器

#### 参考资料：

#### <https://blog.csdn.net/weixin_42588262/article/details/82501488>

#### <https://blog.csdn.net/bishuixing/article/details/102885842>

#### Internet空间服务器：

#### <https://www.ntppool.org/zh/use.html>

## 概念介绍

Chrony 是网络时间协议的通用实现

## 扮演角色：

* 保持系统时间与NTP时钟服务器同步的服务
* 作为NTP服务器对其他服务器提供时间同步服务

## 特点：

1. 任何情况下都能稳定良好运行
2. 精度高
3. 开源

## chronyc & chronyd

* chronyd&#x20;
  * 守护进程，主要用于调佣内核中运行的系统时间和时间服务器同步
* chronyc&#x20;
  * 命令行界面程序，让用户能够对 chronyd 的性能进行监控以及改变各种参数

```bash
pool.ntp.org
或
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
```

```bash
cn.pool.ntp.org
或
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
```

## 作为客户端角色：

### （1）查看时区配置文件内容

```bash
# timedatectl show
```

### （2）配置时区为亚洲/上海

```bash
# timedatectl set-timezone Asia/Shanghai
```

### （3）配置chrony.conf文件

```bash
# vim /etc/chrony.conf 
#pool 2.pool.ntp.org iburst //注释掉这行内容
server pool.ntp.org iburst  //添加此行内容
```

### （4）重启chronyd服务

```bash
# systemctl restart chronyd.service
```

### （5）检查时间

```bash
# date
```
