最近发现博客有点小问题,那就是时间对不上。。

众所周知,我的博客是运行在树莓派上且采用CentOS系统,默认的时间服务器当然是在国外,既然是在国外,就有可能被墙,所以我决定开始解决这个问题

首先,安装NTP服务(如果已安装则无视这步)

    yum -y install ntp

接着,在
/etc/ntp.conf
修改原先的NTP服务器的地址


    vi /etc/ntp.conf


找到以下内容


# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
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

然后按Insert键或者i键切换到编辑模式,删掉原有的地址,并且修改成你想要的NTP服务器


ntp.aliyun.com(阿里云)
cn.ntp.org.cn(深圳儒科公司)
ntp.ntsc.ac.cn(国家授时中心)

然后按Esc键,输入:wq保存退出

重启NTP服务

    systemctl restart ntpd

输入命令,查看NTP服务是否正常运行

    systemctl status ntpd

将NTP服务设置为开机自启

systemctl enable ntpd

输入以下命令,可以获取更详细信息

    ntpq -p