From cb205dda2f50004a89193fe04a89c636a0d78293 Mon Sep 17 00:00:00 2001 From: CallMeR <9463297+callmer@user.noreply.gitee.com> Date: Mon, 20 Jan 2025 18:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=88=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03.PVE系统调整.md | 62 ++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/03.PVE系统调整.md b/03.PVE系统调整.md index 8dd7d51..25b643b 100644 --- a/03.PVE系统调整.md +++ b/03.PVE系统调整.md @@ -4,6 +4,8 @@ 在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。 +关于 [Neovim](https://neovim.io/) 的基础使用方法,请参阅:[Neovim 基本操作](https://www.bing.com/search?q=neovim+%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C) 。 + ```bash ## 同步镜像仓库 $ apt update @@ -38,7 +40,7 @@ $ timedatectl set-timezone Asia/Shanghai $ date -R #### 系统时间示例输出 -Sun, 25 Jun 2023 12:12:12 +0800 +Mon, 20 Jan 2025 18:24:41 +0800 ``` Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。 @@ -47,7 +49,7 @@ Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统 ```bash ## 编辑 chrony 配置文件 -$ nano /etc/chrony/chrony.conf +$ nvim /etc/chrony/chrony.conf ``` 在编辑器对话框中,将 `pool 2.debian.pool.ntp.org iburst` “注释” 掉,并添加国内的 NTP 服务器。 @@ -77,12 +79,12 @@ $ chronyc sources -V #### 系统 NTP 服务器示例输出 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== -^- 203.107.6.88 2 6 7 2 +987us[+1251us] +/- 23ms -^? 106.55.184.199 2 6 11 1 -501us[ -501us] +/- 60ms -^- electrode.felixc.at 2 6 7 2 +3532us[ +663us] +/- 121ms -^* 119.28.206.193 2 6 15 1 +184us[-2686us] +/- 53ms -^- 119.28.183.184 2 6 7 2 +512us[-2358us] +/- 47ms -^+ time.cloudflare.com 3 6 13 1 -85us[-2955us] +/- 106ms +^* 203.107.6.88 2 6 17 0 -875us[-2496us] +/- 22ms +^- 106.55.184.199 2 6 17 3 -1331us[-1331us] +/- 50ms +^- time.neu.edu.cn 2 6 17 8 +935us[ +935us] +/- 23ms +^- 119.28.206.193 2 6 65 5 +33us[ +33us] +/- 65ms +^- electrode.felixc.at 2 6 17 11 -1320us[-1320us] +/- 126ms +^- dns1.synet.edu.cn 1 6 17 13 -44us[ -44us] +/- 22ms ``` ## 2. CPU 调度器 @@ -102,10 +104,10 @@ analyzing CPU 0: hardware limits: 800 MHz - 2.70 GHz available cpufreq governors: conservative ondemand userspace powersave performance schedutil current policy: frequency should be within 800 MHz and 2.70 GHz. - The governor "ondemand" may decide which speed to use + The governor "performance" may decide which speed to use within this range. current CPU frequency: Unable to call hardware - current CPU frequency: 800 MHz (asserted by call to kernel) + current CPU frequency: 2.60 GHz (asserted by call to kernel) boost state support: Supported: yes Active: yes @@ -141,7 +143,7 @@ analyzing CPU 0: $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor #### 设备 CPU - J4125 示例输出 -ondemand +performance #### 设备 CPU - N6005 示例输出 performance @@ -168,11 +170,11 @@ performance powersave - CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器。 -本文使用 `powersave` 调度器为演示,使用 `nano` 编辑器创建 `cpupower` 的配置文件。 +本文使用 `powersave` 调度器为演示,使用 `neovim` 编辑器创建 `cpupower` 的配置文件。 ```bash -## 创建 cpupower 配置文件 -$ nano /etc/default/cpupower +## 创建 cpupower 默认配置文件 +$ nvim /etc/default/cpupower ``` 在配置文件中修改以下配置项,并保存。 @@ -186,11 +188,11 @@ CPUPOWER_STOP_OPTS="frequency-set -g performance" ``` -使用 `nano` 编辑器创建 `cpupower` 服务配置文件,以满足系统自动化设置需求。 +进一步创建 `cpupower` 服务配置文件,以满足系统自动化设置需求。 ```bash -## 创建 cpupower 服务配置文件 -$ nano /etc/systemd/system/cpupower.service +## 创建 cpupower.service 配置文件 +$ nvim /etc/systemd/system/cpupower.service ``` 在服务配置文件中修改以下配置项,并保存。 @@ -280,11 +282,11 @@ $ systemctl status apt-daily-upgrade.timer #### 系统定时器示例输出 ● apt-daily-upgrade.timer - Daily apt upgrade and clean activities Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled) - Active: active (waiting) since Tue 2023-08-01 13:01:19 CST; 27min ago - Trigger: Wed 2023-08-02 06:14:50 CST; 16h left + Active: active (waiting) since Mon 2025-01-20 18:12:44 CST; 19min ago + Trigger: Tue 2025-01-21 06:52:19 CST; 12h left Triggers: ● apt-daily-upgrade.service -Aug 01 13:01:19 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. +Jan 20 18:12:44 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. ``` ### 4.2.配置更新策略 @@ -308,7 +310,7 @@ $ dpkg-reconfigure -plow unattended-upgrades $ cd /etc/apt/apt.conf.d ## 编辑 20auto-upgrades 配置文件 -$ nano /etc/apt/apt.conf.d/20auto-upgrades +$ nvim /etc/apt/apt.conf.d/20auto-upgrades ``` 删除里面全部内容,添加以下配置项,并保存。 @@ -329,7 +331,7 @@ APT::Periodic::CleanInterval "1"; ```bash ## 编辑 50unattended-upgrades 配置文件 -$ nano /etc/apt/apt.conf.d/50unattended-upgrades +$ nvim /etc/apt/apt.conf.d/50unattended-upgrades ``` 配置文件中,被修改的参数解释如下: @@ -420,13 +422,13 @@ $ systemctl status apt-daily-upgrade.timer Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled) Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d └─override.conf - Active: active (waiting) since Tue 2023-08-01 13:37:41 CST; 9s ago - Trigger: Wed 2023-08-02 01:30:00 CST; 11h left + Active: active (waiting) since Mon 2025-01-20 18:43:03 CST; 7s ago + Trigger: Tue 2025-01-21 01:30:00 CST; 6h left Triggers: ● apt-daily-upgrade.service -Aug 01 13:37:41 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities. -Aug 01 13:37:41 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities... -Aug 01 13:37:41 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. +Jan 20 18:43:03 node01 systemd[1]: Stopped apt-daily-upgrade.timer - Daily apt upgrade and clean activities. +Jan 20 18:43:03 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt upgrade and clean activities... +Jan 20 18:43:03 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. ``` ## 5.硬件直通 @@ -439,7 +441,7 @@ Aug 01 13:37:41 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u ```bash ## 编辑 Grub 配置文件 -$ nano /etc/default/grub +$ nvim /etc/default/grub ``` 在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。 @@ -473,7 +475,7 @@ $ update-grub ```bash ## 编辑系统配置文件 -$ nano /etc/modules +$ nvim /etc/modules ``` 在配置文件中添加以下配置项,并保存。 @@ -599,7 +601,7 @@ $ swapon /swap/swapfile ```bash ## 编辑 fstab 配置文件 -$ nano /etc/fstab +$ nvim /etc/fstab ``` `fstab` 为系统关键配置文件,直接影响系统启动,修改此文件时,请注意以下几点: