From b0ede429fc03703446c5da7fecd7577b9f95e786 Mon Sep 17 00:00:00 2001 From: CallMeR <9463297+callmer@user.noreply.gitee.com> Date: Tue, 12 Aug 2025 02:40:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=20trixie=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03.PVE系统调整.md | 38 +++++++++++++++++------- 05.PVE制作虚拟机模板.md | 46 +++++++++++++++++++++-------- 06.PVE制作DNS服务器.md | 10 +++---- 07.PVE制作TS服务器.md | 64 +++++++++++++++++++++++++++-------------- 4 files changed, 110 insertions(+), 48 deletions(-) diff --git a/03.PVE系统调整.md b/03.PVE系统调整.md index a3f16a4..d018b21 100644 --- a/03.PVE系统调整.md +++ b/03.PVE系统调整.md @@ -4,7 +4,25 @@ 在 PVE 系统调整之前,请确认必要的软件包已经安装完成,本文后续命令均在 SSH 终端下执行。 -关于 [Neovim](https://neovim.io/) 的基础使用方法,请参阅:[Neovim 基础教程](https://cn.bing.com/search?q=Neovim+%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B) 。 +Debian 系统默认编辑器为 `nano` ,推荐将默认编辑器更换为 `neovim` ,关于 [Neovim](https://neovim.io/) 的基础使用方法,请参阅:[Neovim 基础教程](https://cn.bing.com/search?q=Neovim+%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B) 。 + +```bash +## 修改系统默认编辑器(选择 nvim 所在条目,即可将 neovim 设为默认编辑器) +$ update-alternatives --config editor + +#### 系统默认编辑器示例输出 +There are 3 choices for the alternative editor (providing /usr/bin/editor). + + Selection Path Priority Status +------------------------------------------------------------ +* 0 /bin/nano 40 auto mode + 1 /bin/nano 40 manual mode + 2 /usr/bin/nvim 30 manual mode + 3 /usr/bin/vim.tiny 15 manual mode + +Press to keep the current choice[*], or type selection number: 2 +update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode +``` ## 1.系统时区 @@ -29,7 +47,7 @@ Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统 ```bash ## 编辑 chrony 配置文件 -$ nvim /etc/chrony/chrony.conf +$ editor /etc/chrony/chrony.conf ``` 在编辑器对话框中,将 `pool 2.debian.pool.ntp.org iburst` “注释” 掉,并添加国内的 NTP 服务器。 @@ -150,11 +168,11 @@ performance powersave - CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器。 -本文使用 `powersave` 调度器为演示,使用 `neovim` 编辑器创建 `cpupower` 的配置文件。 +本文使用 `powersave` 调度器创建 `cpupower` 的配置文件。 ```bash ## 创建 cpupower 默认配置文件 -$ nvim /etc/default/cpupower +$ editor /etc/default/cpupower ``` 在配置文件中修改以下配置项,并保存。 @@ -172,7 +190,7 @@ CPUPOWER_STOP_OPTS="frequency-set -g performance" ```bash ## 创建 cpupower.service 配置文件 -$ nvim /etc/systemd/system/cpupower.service +$ editor /etc/systemd/system/cpupower.service ``` 在服务配置文件中修改以下配置项,并保存。 @@ -290,7 +308,7 @@ $ dpkg-reconfigure -plow unattended-upgrades $ cd /etc/apt/apt.conf.d ## 编辑 20auto-upgrades 配置文件 -$ nvim /etc/apt/apt.conf.d/20auto-upgrades +$ editor /etc/apt/apt.conf.d/20auto-upgrades ``` 删除里面全部内容,添加以下配置项,并保存。 @@ -311,7 +329,7 @@ APT::Periodic::CleanInterval "1"; ```bash ## 编辑 50unattended-upgrades 配置文件 -$ nvim /etc/apt/apt.conf.d/50unattended-upgrades +$ editor /etc/apt/apt.conf.d/50unattended-upgrades ``` 配置文件中,被修改的参数解释如下: @@ -421,7 +439,7 @@ Jan 20 18:43:03 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt u ```bash ## 编辑 Grub 配置文件 -$ nvim /etc/default/grub +$ editor /etc/default/grub ``` 在编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。 @@ -455,7 +473,7 @@ $ update-grub ```bash ## 编辑系统配置文件 -$ nvim /etc/modules +$ editor /etc/modules ``` 在配置文件中添加以下配置项,并保存。 @@ -581,7 +599,7 @@ $ swapon /swap/swapfile ```bash ## 编辑 fstab 配置文件 -$ nvim /etc/fstab +$ editor /etc/fstab ``` `fstab` 为系统关键配置文件,直接影响系统启动,修改此文件时,请注意以下几点: diff --git a/05.PVE制作虚拟机模板.md b/05.PVE制作虚拟机模板.md index 2b07043..53e5de4 100644 --- a/05.PVE制作虚拟机模板.md +++ b/05.PVE制作虚拟机模板.md @@ -56,7 +56,7 @@ $ sudo systemctl restart ssh.service ```bash ## 配置 Debian 系统默认软件源脚本 -$ sudo cat > /etc/apt/sources.list.d/debian.sources < /etc/apt/sources.list.d/debian.sources < to keep the current choice[*], or type selection number: 2 +update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode +``` + +### 1.6.调整内核参数 由于该 Debian 虚拟机模板将用于克隆内网 DNS 服务器,因此需要调整内核参数来简单优化性能。 -使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。 +编辑 **内核参数** 配置文件,执行以下命令。 ```bash ## 编辑 内核参数 配置文件 -$ sudo nvim /etc/sysctl.d/99-sysctl.conf +$ sudo editor /etc/sysctl.d/99-sysctl.conf ``` 在配置文件中添加以下配置项,注意配置中间的空格。 @@ -197,7 +219,7 @@ net.ipv6.conf.default.use_tempaddr = 0 $ sudo sysctl --system ``` -### 1.6.调整系统时间 +### 1.7.调整系统时间 默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。 @@ -221,7 +243,7 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需 $ sudo mkdir -p /etc/systemd/timesyncd.conf.d ## 创建 NTP 配置文件 -$ sudo nvim /etc/systemd/timesyncd.conf.d/10-server-ntp.conf +$ sudo editor /etc/systemd/timesyncd.conf.d/10-server-ntp.conf ``` 在配置文件中添加以下配置项,并保存。 @@ -267,7 +289,7 @@ Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Contacted time server 203.107.6.8 Oct 07 18:06:29 DNS01 systemd-timesyncd[1706]: Initial clock synchronization to Mon 2024-10-07 18:06:29.499548 CST. ``` -### 1.7.配置自动更新 +### 1.8.配置自动更新 配置 Debian 云镜像的系统自动更新,与配置 PVE 系统自动更新方法基本一致,参阅 [03.PVE系统调整](./03.PVE系统调整.md) 。 @@ -292,7 +314,7 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades ```bash ## 编辑 20auto-upgrades 配置文件 -$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades +$ sudo editor /etc/apt/apt.conf.d/20auto-upgrades ``` 删除里面全部内容,添加以下配置项,并保存。 @@ -313,7 +335,7 @@ APT::Periodic::CleanInterval "1"; ```bash ## 编辑 50unattended-upgrades 配置文件 -$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades +$ sudo editor /etc/apt/apt.conf.d/50unattended-upgrades ``` 根据 “注释” 中相关说明,调整配置文件。 @@ -372,7 +394,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer $ sudo systemctl status apt-daily-upgrade.timer ``` -### 1.8.配置定时任务 +### 1.9.配置定时任务 本步骤为可选操作,主要设置系统定时重启。 @@ -393,7 +415,7 @@ $ sudo crontab -e ``` -### 1.9.清理系统 +### 1.10.清理系统 Debian 模板虚拟机已经配置完成,在将其转换为模板前需要对系统进行清理。 diff --git a/06.PVE制作DNS服务器.md b/06.PVE制作DNS服务器.md index a74c656..5520919 100644 --- a/06.PVE制作DNS服务器.md +++ b/06.PVE制作DNS服务器.md @@ -94,7 +94,7 @@ systemd-r 1797 systemd-resolve 21u IPv4 23027 0t0 TCP 127.0.0.54:domai $ sudo mkdir -p /etc/systemd/resolved.conf.d ## 创建 systemd-resolved 配置文件 -$ sudo nvim /etc/systemd/resolved.conf.d/10-server-dns.conf +$ sudo editor /etc/systemd/resolved.conf.d/10-server-dns.conf ``` 在配置文件中添加以下配置项,并保存。 @@ -324,11 +324,11 @@ $ sudo rm -rvf /var/run/smartdns.pid /run/smartdns.pid $ sudo mv /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak ``` -使用 `neovim` 编辑器创建 `SmartDNS` 主配置文件,执行以下命令。 +创建 `SmartDNS` 主配置文件,执行以下命令。 ```bash ## 创建 SmartDNS 主配置文件 -$ sudo nvim /etc/smartdns/smartdns.conf +$ sudo editor /etc/smartdns/smartdns.conf ``` 在编辑器对话框中输入以下内容,并保存。 @@ -399,11 +399,11 @@ server-https https://dns.alidns.com/dns-query $ sudo mkdir -p /etc/dnsmasq.d ``` -使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。 +创建 `Dnsmasq` 主配置文件,执行以下命令。 ```bash ## 创建 Dnsmasq 主配置文件 -$ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf +$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf ``` 在编辑器对话框中输入以下内容,并保存。 diff --git a/07.PVE制作TS服务器.md b/07.PVE制作TS服务器.md index 8c6a672..4562885 100644 --- a/07.PVE制作TS服务器.md +++ b/07.PVE制作TS服务器.md @@ -63,7 +63,7 @@ $ sudo systemctl restart ssh.service ```bash ## 配置 Debian 系统默认软件源脚本 -$ sudo cat > /etc/apt/sources.list.d/debian.sources < /etc/apt/sources.list.d/debian.sources < to keep the current choice[*], or type selection number: 2 +update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in manual mode +``` + +### 1.6.调整内核模块 + +编辑 **内核模块** 配置文件,执行以下命令。 ```bash ## 创建 内核模块 配置文件 -$ sudo nvim /etc/modules-load.d/10-server-modules.conf +$ sudo editor /etc/modules-load.d/10-server-modules.conf ``` 在配置文件中添加以下配置项,并保存。 @@ -182,13 +204,13 @@ nf_conntrack ``` -### 1.6.调整内核参数 +### 1.7.调整内核参数 -使用 `neovim` 编辑器编辑 **内核参数** 配置文件,执行以下命令。 +编辑 **内核参数** 配置文件,执行以下命令。 ```bash ## 编辑 内核参数 配置文件 -$ sudo nvim /etc/sysctl.d/99-sysctl.conf +$ sudo editor /etc/sysctl.d/99-sysctl.conf ``` 在配置文件中添加以下配置项,注意配置中间的空格。 @@ -273,7 +295,7 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 7440 $ sudo sysctl --system ``` -### 1.7.调整系统时间 +### 1.8.调整系统时间 默认情况下 Debian 云镜像的系统时间需要调整,执行以下命令将系统时区设置为中国时区。 @@ -294,7 +316,7 @@ Debian 云镜像默认使用 `systemd-timesyncd.service` 同步时间,且需 $ sudo mkdir -p /etc/systemd/timesyncd.conf.d ## 创建 NTP 配置文件 -$ sudo nvim /etc/systemd/timesyncd.conf.d/10-server-ntp.conf +$ sudo editor /etc/systemd/timesyncd.conf.d/10-server-ntp.conf ``` 在配置文件中添加以下配置项,并保存。 @@ -318,7 +340,7 @@ $ sudo systemctl restart systemd-timesyncd.service $ sudo systemctl status systemd-timesyncd.service ``` -### 1.8.配置自动更新 +### 1.9.配置自动更新 配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。 @@ -334,7 +356,7 @@ $ sudo dpkg-reconfigure -plow unattended-upgrades ```bash ## 编辑 20auto-upgrades 配置文件 -$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades +$ sudo editor /etc/apt/apt.conf.d/20auto-upgrades ``` 删除里面全部内容,添加以下配置项,并保存。 @@ -355,7 +377,7 @@ APT::Periodic::CleanInterval "1"; ```bash ## 编辑 50unattended-upgrades 配置文件 -$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades +$ sudo editor /etc/apt/apt.conf.d/50unattended-upgrades ``` 根据 “注释” 中相关说明,调整配置文件。 @@ -418,7 +440,7 @@ $ sudo systemctl restart apt-daily-upgrade.timer $ sudo systemctl status apt-daily-upgrade.timer ``` -### 1.9.配置防火墙 +### 1.10.配置防火墙 修改防火墙配置之前,需检查 `nftables.service` 服务状态,确保该服务开机自启。 @@ -430,14 +452,14 @@ $ sudo systemctl status nftables.service $ sudo systemctl enable nftables.service ``` -使用 `neovim` 编辑器修改 `nftables` 配置文件,执行以下命令。 +修改 `nftables` 配置文件,执行以下命令。 ```bash ## 备份 nftables 配置文件 $ sudo mv /etc/nftables.conf /etc/nftables.conf.bak ## 创建新的 nftables 配置文件 -$ sudo nvim /etc/nftables.conf +$ sudo editor /etc/nftables.conf ``` 由于防火墙配置文件很长,因此请查阅文件 [debian_ts_nftables.conf](./src/debian/debian_ts_nftables.conf) 进行复制。 @@ -449,7 +471,7 @@ $ sudo nvim /etc/nftables.conf $ sudo systemctl restart nftables.service ``` -### 1.10.调整系统端口 +### 1.11.调整系统端口 为了正常使用 `53` 端口,需要对 `systemd-resolved.service` 进行配置,执行以下命令。 @@ -458,7 +480,7 @@ $ sudo systemctl restart nftables.service $ sudo mkdir -p /etc/systemd/resolved.conf.d ## 创建 systemd-resolved 配置文件 -$ sudo nvim /etc/systemd/resolved.conf.d/10-server-dns.conf +$ sudo editor /etc/systemd/resolved.conf.d/10-server-dns.conf ``` 在配置文件中添加以下配置项,并保存。 @@ -488,7 +510,7 @@ $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf $ sudo systemctl restart systemd-resolved.service ``` -### 1.11.配置 Dnsmasq +### 1.12.配置 Dnsmasq 检查 `dnsmasq.service` 服务状态,确保该服务开机自启。 @@ -507,11 +529,11 @@ $ sudo systemctl enable dnsmasq.service $ sudo mkdir -p /etc/dnsmasq.d ``` -使用 `neovim` 编辑器创建 `Dnsmasq` 主配置文件,执行以下命令。 +创建 `Dnsmasq` 主配置文件,执行以下命令。 ```bash ## 创建 Dnsmasq 主配置文件 -$ sudo nvim /etc/dnsmasq.d/10-server-dnsmasq.conf +$ sudo editor /etc/dnsmasq.d/10-server-dnsmasq.conf ``` 在编辑器对话框中输入以下内容,并保存。