本文最后更新于 1200 天前,其中的信息可能已经有所发展或是发生改变。
背景知识:
linux 时钟概述
linux 系统有两个时钟:一个是硬件时钟,即 BIOS 时间;另一个是系统时钟,是 linux 系统 Kernel(内核)时间。
在 linux 系统上程序运行时读取的时间都是系统 Kernel(内核)时间。
每次 Linux 启动时,系统 Kernel(内核)会先去读取硬件时钟的设置(但是此时的硬件时间不一定是准确的),然后系统时钟就会独立于硬件继续运作。
综上所述,所以想要永久修改 linux 时间并使得时间准确,就需要永久修改硬件时间,不然每次重新启动 linux 时,系统时间又变回之前的硬件时间。
linux 时钟相关命令
系统 Kernel(内核)时钟的相关命令是 timedatectl 或者 date;
硬件 BIOS 时钟相关命令是 hwclock 或者 clock。
输入 hwclock –show 查看硬件时间
- CentOS 下安装配置 ntp 服务的步骤如下:
| |
| |
| sudo vi /etc/sysconfig/ntpd |
| |
| |
| sudo service ntpd restart |
- Ubuntu/Debian 下安装配置 ntp 服务的步骤如下:
| hwclock --systohc --localtime (好像这个更有效) |
# 或者
| timedatectl set-local-rtc 1 |
# 或者
本文的系统要求为 Debian 9 或更高版本的 Debian Linux,其它操作系统所知不详,不知是否适合本文的方法。
注意,本文的配置参数不仅仅是启用 Google BBR,还包括一系列网络参数的优化,直接拷贝执行使用即可。
Google BBR 一键加速 VPS 服务器很简单,SSH 登录 VPS 后,分别执行以下 2 个命令即可(鼠标选中高亮后,点鼠标右键复制粘贴到 root 用户的 #后面,然后回车)。
| wget https://raw.githubusercontent.com/bannedbook/fanqiang/master/v2ss/server-cfg/sysctl.conf -O -> /etc/sysctl.con |
如果提示 wget: command not found 的错误,这是因为你的系统 wget 没有安装,所以需要安先装 wget:
apt-get install -y wget
执行成功后大致会输出:(视个人情况而言)
fs.file-max = 51200
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_rmem = 32768 436600 873200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_tw_buckets = 9000
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_mem = 94500000 91500000 92700000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_wmem = 8192 436600 873200
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.tcp_congestion_control = bbr