一、配置网络
1、安装ifupdown2
- apt install ifupdown2
2、配置网桥
#清空原配置,勿点击应用配置
#点击创建—Linux Bridge,按需配置后应用配置
二、内存优化
1、禁用非必要的服务
- systemctl stop pve-ha-lrm.service
- systemctl disable pve-ha-lrm.service
- systemctl stop pve-ha-crm.service
- systemctl disable pve-ha-crm.service
- systemctl stop pve-firewall.service
- systemctl disable pve-firewall.service
- systemctl stop pvescheduler.service
- systemctl disable pvescheduler.service
- systemctl stop spiceproxy.service
- systemctl disable spiceproxy.service
- systemctl disable postfix.service
2、减少worker数量
修改目录/usr/share/perl5/PVE/Service下三个文件,将max_workers后面3改为1
pvedaemon.pm、 pveproxy.pm、spiceproxy.pm
三、LXC安装OpenWrt
1、下载适合的CT模板
例1:https://github.com/breakings/OpenWrt/releases/download/ARMv8Docker/openwrt-armvirt-64-default-rootfs.tar.gz(暴躁老哥模板)
例2:https://downloads.openwrt.org/releases/23.05.0/targets/armsr/armv8/openwrt-23.05.0-armsr-armv8-rootfs.tar.gz(官方最新模板)
例3:https://github.com/Zane-E/ROOTFS-N1/releases/download/ROOTFS.bak/N1-rootfs-wifi-new.tar.gz(自用精简模板——开启wifi见PS)
例4:https://github.com/Zane-E/ROOTFS-N1/releases/download/ROOTFS.bak/openwrt-s905d-n1-R23.09.29-flippy-rootfs.tar.gz(基于F大N1固件转换模板——开启wifi见PS)
2、上传模板
3、创建OpenWrt
- pct create 117 \ #序号不能与现有重复
- local:vztmpl/openwrt-armvirt-64-generic-rootfs.tar.gz \ #对应上图1及文件名
- –rootfs local:0.5 \ #分配硬盘空间 单位G
- –ostype unmanaged \
- –hostname OpenWrt \ #名称
- –arch arm64 \ #架构
- –cores 4 \ #核心数
- –memory 256 \ #分配内存 单位M
- –swap 0 \
- -net0 bridge=vmbr0,name=eth0
4、勾选嵌套并启动OpenWrt
5、修改IP
- lxc-attach 117 #在步骤3 shell 输入
- vi /etc/config/network
- /etc/init.d/network restart
浏览器输入IP进入OpenWrt(默认账户root密码password)。之后和设置旁路网关(旁路由)一样步骤,不赘述。
PS:
1、编辑配置文件
- nano /etc/pve/lxc/117.conf #117换成创建例3的CT ID
2、末尾添加后重启
- lxc.net.1.type: phys
- lxc.net.1.link: wlan0
- lxc.net.1.flags: up
- lxc.net.1.name: wlan0
四、LXC安装AdGuardHome(Alpine)
1、下载并上传模板
https://us.lxd.images.canonical.com/images/alpine/3.18/arm64/default
https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/alpine/3.18/arm64/default/
https://mirrors.bfsu.edu.cn/lxc-images/images/alpine/3.18/arm64/default/
ps:alpine比较节省硬盘空间,亦可通过Debian等创建
2、创建CT
3、安装AdGuardHome
换源#非必须
- sed -i ‘s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g’ /etc/apk/repositories
- apk update
- apk add curl
- curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s — -v
- vi /etc/init.d/AdguardHome
- #!/sbin/openrc-run
#
# openrc service-script for AdGuardHome
#
# place in /etc/init.d/
# start on boot: “rc-update add adguardhome”
# control service: “service adguardhome “
# - description=“AdGuard Home: Network-level blocker”
- pidfile=“/run/$RC_SVCNAME.pid”
command=“/opt/AdGuardHome/AdGuardHome”
command_args=“-s run”
command_background=true - extra_commands=“checkconfig”
- depend() {
need net
provide dns
after firewall
} - checkconfig() {
“$command“ –check-config || return 1
} - stop() {
if [ “${RC_CMD}” = “restart” ] ; then
checkconfig || return 1
fi - ebegin “Stopping $RC_SVCNAME“
start-stop-daemon –stop –exec “$command“ \
–pidfile “$pidfile“ –quiet
eend $?
}
- chmod +x /etc/init.d/AdguardHome
- rc-update add AdguardHome
- rc-service AdguardHome start
按引导进行设置
五、LXC安装Docker(Alpine)
部署lxc Alpine(安装AdGuardHome步骤的1、2)
- nano /etc/pve/lxc/118.conf #118换成创建例CT ID
末尾处添加后重启CT
- lxc.apparmor.profile: unconfined
- lxc.cgroup.devices.allow: a
- lxc.cap.drop:
lxc.apparmor.profile: unconfined
:该配置指定了 AppArmor(应用程序安全性配置框架)的配置文件名称,这里设置为 “unconfined”,用于允许容器内的进程具有更高的系统权限。
lxc.cgroup.devices.allow: a
: 允许容器内的进程访问所有的 cgroup 设备。
lxc.cap.drop
: 此配置项为空,容器内的进程将继承主机系统的默认能力设置。
换源#非必须
- sed -i ‘s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g’ /etc/apk/repositories
- apk update
- apk add docker
- rc-update add docker boot
- service docker start