mirror of
https://gitee.com/callmer/pve_toss_notes.git
synced 2026-08-31 22:12:51 +08:00
更新 PVE 系统调整
This commit is contained in:
+42
-78
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。
|
在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。
|
||||||
|
|
||||||
```shell
|
```bash
|
||||||
## 同步镜像仓库
|
## 同步镜像仓库
|
||||||
$ apt update
|
$ apt update
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ $ timedatectl set-timezone Asia/Shanghai
|
|||||||
## 检查系统时间
|
## 检查系统时间
|
||||||
$ date -R
|
$ date -R
|
||||||
|
|
||||||
## 参考输出
|
#### 系统时间示例输出
|
||||||
Sun, 25 Jun 2023 12:12:12 +0800
|
Sun, 25 Jun 2023 12:12:12 +0800
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -68,17 +68,14 @@ pool ntp.aliyun.com iburst
|
|||||||
|
|
||||||
保存该配置文件后,需重启 `chrony` 服务,并再次检查系统 NTP 服务器地址。
|
保存该配置文件后,需重启 `chrony` 服务,并再次检查系统 NTP 服务器地址。
|
||||||
|
|
||||||
```shell
|
```bash
|
||||||
## 重启 chrony 服务
|
## 重启 chrony 服务
|
||||||
$ systemctl restart chrony.service
|
$ systemctl restart chrony.service
|
||||||
|
|
||||||
## 检查系统 NTP 服务器
|
## 检查系统 NTP 服务器
|
||||||
$ chronyc sources -V
|
$ chronyc sources -V
|
||||||
```
|
|
||||||
|
|
||||||
如果输出以下类似内容,则表示系统 NTP 服务器设置正确。
|
#### 系统 NTP 服务器示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
||||||
===============================================================================
|
===============================================================================
|
||||||
^+ 106.55.184.199 2 6 17 11 +752us[ +273us] +/- 40ms
|
^+ 106.55.184.199 2 6 17 11 +752us[ +273us] +/- 40ms
|
||||||
@@ -91,11 +88,9 @@ MS Name/IP address Stratum Poll Reach LastRx Last sample
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查 CPU 当前调度器
|
## 检查 CPU 当前调度器
|
||||||
cpufreq-info
|
$ cpufreq-info
|
||||||
```
|
|
||||||
设备 CPU - J4125 参考输出。
|
|
||||||
|
|
||||||
```shell
|
#### 设备 CPU - J4125 示例输出
|
||||||
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
|
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
|
||||||
Report errors and bugs to cpufreq@vger.kernel.org, please.
|
Report errors and bugs to cpufreq@vger.kernel.org, please.
|
||||||
analyzing CPU 0:
|
analyzing CPU 0:
|
||||||
@@ -109,11 +104,8 @@ analyzing CPU 0:
|
|||||||
The governor "ondemand" may decide which speed to use
|
The governor "ondemand" may decide which speed to use
|
||||||
within this range.
|
within this range.
|
||||||
current CPU frequency is 1.84 GHz.
|
current CPU frequency is 1.84 GHz.
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - N6005 参考输出。
|
#### 设备 CPU - N6005 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
|
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
|
||||||
Report errors and bugs to cpufreq@vger.kernel.org, please.
|
Report errors and bugs to cpufreq@vger.kernel.org, please.
|
||||||
analyzing CPU 0:
|
analyzing CPU 0:
|
||||||
@@ -139,18 +131,12 @@ analyzing CPU 0:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查 CPU 当前调度器
|
## 检查 CPU 当前调度器
|
||||||
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - J4125 参考输出。
|
#### 设备 CPU - J4125 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
ondemand
|
ondemand
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - N6005 参考输出。
|
#### 设备 CPU - N6005 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
performance
|
performance
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -160,18 +146,12 @@ CPU 驱动一般不建议手动调整,而 `governor` 后面的参数表示 CPU
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查 CPU 调度器支持情况
|
## 检查 CPU 调度器支持情况
|
||||||
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
|
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - J4125 参考输出。
|
#### 设备 CPU - J4125 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
conservative ondemand userspace powersave performance schedutil
|
conservative ondemand userspace powersave performance schedutil
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - N6005 参考输出。
|
#### 设备 CPU - N6005 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
performance powersave
|
performance powersave
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -189,7 +169,7 @@ performance powersave
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 cpufrequtils 配置文件
|
## 编辑 cpufrequtils 配置文件
|
||||||
nano /etc/init.d/cpufrequtils
|
$ nano /etc/init.d/cpufrequtils
|
||||||
```
|
```
|
||||||
|
|
||||||
在配置文件中修改以下配置项,并保存。
|
在配置文件中修改以下配置项,并保存。
|
||||||
@@ -210,10 +190,10 @@ PVE 服务器重启完成后需再次查看 CPU 调度器,检验配置文件
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 查看 CPU 当前频率
|
## 查看 CPU 当前频率
|
||||||
watch cat /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_cur_freq
|
$ watch cat /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_cur_freq
|
||||||
|
|
||||||
## 查看内部温度
|
## 查看内部温度
|
||||||
watch -d sensors
|
$ watch -d sensors
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. PVE 定时重启
|
## 3. PVE 定时重启
|
||||||
@@ -224,10 +204,10 @@ watch -d sensors
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 查看系统定时任务
|
## 查看系统定时任务
|
||||||
crontab -l
|
$ crontab -l
|
||||||
|
|
||||||
## 编辑系统定时任务,编辑器选择 nano
|
## 编辑系统定时任务,编辑器选择 nano
|
||||||
crontab -e
|
$ crontab -e
|
||||||
```
|
```
|
||||||
|
|
||||||
在配置文件末尾,增加以下配置项。
|
在配置文件末尾,增加以下配置项。
|
||||||
@@ -249,12 +229,9 @@ crontab -e
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查系统定时器
|
## 检查系统定时器
|
||||||
systemctl status apt-daily-upgrade.timer
|
$ systemctl status apt-daily-upgrade.timer
|
||||||
```
|
|
||||||
|
|
||||||
系统定时器参考输出。
|
#### 系统定时器示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
|
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
|
||||||
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
||||||
Active: active (waiting) since Fri 2023-06-23 18:55:58 CST; 1 day 18h ago
|
Active: active (waiting) since Fri 2023-06-23 18:55:58 CST; 1 day 18h ago
|
||||||
@@ -273,15 +250,11 @@ Jun 23 18:55:58 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 配置自动更新策略
|
## 配置自动更新策略
|
||||||
dpkg-reconfigure -plow unattended-upgrades
|
$ dpkg-reconfigure -plow unattended-upgrades
|
||||||
|
|
||||||
## 选择 “是” (“YES”)
|
## 选择 “是” (“YES”)
|
||||||
|
|
||||||
```
|
#### 系统自动更新示例输出
|
||||||
|
|
||||||
系统自动更新参考输出。
|
|
||||||
|
|
||||||
```shell
|
|
||||||
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -289,10 +262,10 @@ Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 进入 apt 的配置目录
|
## 进入 apt 的配置目录
|
||||||
cd /etc/apt/apt.conf.d
|
$ cd /etc/apt/apt.conf.d
|
||||||
|
|
||||||
## 编辑 20auto-upgrades 配置文件
|
## 编辑 20auto-upgrades 配置文件
|
||||||
nano /etc/apt/apt.conf.d/20auto-upgrades
|
$ nano /etc/apt/apt.conf.d/20auto-upgrades
|
||||||
```
|
```
|
||||||
|
|
||||||
删除里面全部内容,添加以下配置项,并保存。
|
删除里面全部内容,添加以下配置项,并保存。
|
||||||
@@ -313,7 +286,7 @@ APT::Periodic::CleanInterval "1";
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 50unattended-upgrades 配置文件
|
## 编辑 50unattended-upgrades 配置文件
|
||||||
nano /etc/apt/apt.conf.d/50unattended-upgrades
|
$ nano /etc/apt/apt.conf.d/50unattended-upgrades
|
||||||
```
|
```
|
||||||
|
|
||||||
配置文件中,被修改的参数解释如下:
|
配置文件中,被修改的参数解释如下:
|
||||||
@@ -375,7 +348,7 @@ Unattended-Upgrade::Automatic-Reboot-Time "05:00";
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 配置系统定时器
|
## 配置系统定时器
|
||||||
systemctl edit apt-daily-upgrade.timer
|
$ systemctl edit apt-daily-upgrade.timer
|
||||||
```
|
```
|
||||||
|
|
||||||
根据配置文件中的提示,在中间空白处填入以下配置项。
|
根据配置文件中的提示,在中间空白处填入以下配置项。
|
||||||
@@ -394,15 +367,12 @@ RandomizedDelaySec=0
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 重启触发器
|
## 重启触发器
|
||||||
systemctl restart apt-daily-upgrade.timer
|
$ systemctl restart apt-daily-upgrade.timer
|
||||||
|
|
||||||
## 再次检查触发器状态
|
## 再次检查触发器状态
|
||||||
systemctl status apt-daily-upgrade.timer
|
$ systemctl status apt-daily-upgrade.timer
|
||||||
```
|
|
||||||
|
|
||||||
系统自动更新触发器参考输出。
|
#### 系统自动更新触发器示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
|
● apt-daily-upgrade.timer - Daily apt upgrade and clean activities
|
||||||
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.timer; enabled; preset: enabled)
|
||||||
Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
|
Drop-In: /etc/systemd/system/apt-daily-upgrade.timer.d
|
||||||
@@ -427,7 +397,7 @@ Jun 25 14:35:06 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑 Grub 配置文件
|
## 编辑 Grub 配置文件
|
||||||
nano /etc/default/grub
|
$ nano /etc/default/grub
|
||||||
```
|
```
|
||||||
|
|
||||||
在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。
|
在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。
|
||||||
@@ -452,7 +422,7 @@ GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 更新系统 Grub
|
## 更新系统 Grub
|
||||||
update-grub
|
$ update-grub
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.2.添加内核模块
|
### 5.2.添加内核模块
|
||||||
@@ -461,7 +431,7 @@ update-grub
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 编辑系统配置文件
|
## 编辑系统配置文件
|
||||||
nano /etc/modules
|
$ nano /etc/modules
|
||||||
```
|
```
|
||||||
|
|
||||||
在配置文件中添加以下配置项,并保存。
|
在配置文件中添加以下配置项,并保存。
|
||||||
@@ -479,7 +449,7 @@ vfio_pci
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 更新 initramfs
|
## 更新 initramfs
|
||||||
update-initramfs -u -k all
|
$ update-initramfs -u -k all
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.3.检查硬件直通
|
### 5.3.检查硬件直通
|
||||||
@@ -490,12 +460,9 @@ PVE 服务器重启完成后,再次使用 SSH 工具登录,并使用以下
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查系统硬件直通状态
|
## 检查系统硬件直通状态
|
||||||
dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
|
$ dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - N6005 参考输出。
|
#### 设备 CPU - N6005 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
[ 0.017937] ACPI: DMAR 0x00000000746C2000 000088 (v02 INTEL EDK2 00000002 01000013)
|
[ 0.017937] ACPI: DMAR 0x00000000746C2000 000088 (v02 INTEL EDK2 00000002 01000013)
|
||||||
[ 0.017965] ACPI: Reserving DMAR table memory at [mem 0x746c2000-0x746c2087]
|
[ 0.017965] ACPI: Reserving DMAR table memory at [mem 0x746c2000-0x746c2087]
|
||||||
[ 0.047812] DMAR: IOMMU enabled
|
[ 0.047812] DMAR: IOMMU enabled
|
||||||
@@ -531,12 +498,9 @@ dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 检查 IOMMU group
|
## 检查 IOMMU group
|
||||||
find /sys/kernel/iommu_groups/ -type l
|
$ find /sys/kernel/iommu_groups/ -type l
|
||||||
```
|
|
||||||
|
|
||||||
设备 CPU - N6005 参考输出。
|
#### 设备 CPU - N6005 示例输出
|
||||||
|
|
||||||
```shell
|
|
||||||
/sys/kernel/iommu_groups/7/devices/0000:00:1c.4
|
/sys/kernel/iommu_groups/7/devices/0000:00:1c.4
|
||||||
/sys/kernel/iommu_groups/15/devices/0000:04:00.0
|
/sys/kernel/iommu_groups/15/devices/0000:04:00.0
|
||||||
/sys/kernel/iommu_groups/5/devices/0000:00:17.0
|
/sys/kernel/iommu_groups/5/devices/0000:00:17.0
|
||||||
@@ -568,19 +532,19 @@ PVE 系统配置完成后,可逐条执行以下命令,对系统进行清理
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
## 清理系统软件包
|
## 清理系统软件包
|
||||||
apt clean && apt autoclean && apt autoremove --purge
|
$ apt clean && apt autoclean && apt autoremove --purge
|
||||||
|
|
||||||
## 清理系统缓存
|
## 清理系统缓存
|
||||||
rm -rvf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
|
$ rm -rvf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
|
||||||
|
|
||||||
## 清理系统日志
|
## 清理系统日志
|
||||||
find /var/log/ -type f | xargs rm -rvf
|
$ find /var/log/ -type f | xargs rm -rvf
|
||||||
|
|
||||||
## 清理命令历史记录文件
|
## 清理命令历史记录文件
|
||||||
rm -rvf ~/.bash_history
|
$ rm -rvf ~/.bash_history
|
||||||
|
|
||||||
## 清理命令历史
|
## 清理命令历史
|
||||||
history -c
|
$ history -c
|
||||||
```
|
```
|
||||||
|
|
||||||
至此 PVE 的系统调整已经完成。
|
至此 PVE 的系统调整已经完成。
|
||||||
|
|||||||
Reference in New Issue
Block a user