PVE 节点的网络配置,在 WebUI 里只能设置为静态地址,想设置DHCP的话需要使用以下方法。
$ cp /etc/network/interfaces /etc/network/interfaces.new
# /etc/network/interfaces.new
...
# IPv4
iface vmbr0 inet dhcp
# address 192.168.1.66/24
# gateway 192.168.1.1
bridge-ports enp1s0
bridge-stp off
bridge-fd 0
# IPv6
iface vmbr0 inet6 dhcp
request_prefix 1
在 PVE 的 WebUI 里 “系统 > 网络” 处,刷新后点击“应用配置”即可生效,等待几分钟后即可获取到IPv6地址。
直接修改 /etc/network/interfaces 文件也可以,修改完获取新地址。
$ systemctl restart networking
$ ip addr show vmbr0
Proxmox VE 官方提供的 Centos 7 模板是有问题的无法正常使用,现在给出解决方案。
安装完成后,容器可以启动,但无法关闭、网络无法使用、控制台无法使用,这些都是我们要解决的问题。
# 查看 CT 容器列表
$ pct list
# 进入 CT 容器
$ pct enter <VMID>
# 启动网络,从DHCP拿IP地址
$ ifup eth0
$ curl -o /etc/yum.repos.d/jsynacek-systemd-backports-for-centos-7-epel-7.repo https://copr.fedorainfracloud.org/coprs/jsynacek/systemd-backports-for-centos-7/repo/epel-7/jsynacek-systemd-backports-for-centos-7-epel-7.repo
$ yum update
# 安装 sshd
$ yum install -y openssh-server
$ systemctl start sshd.service
$ systemctl enable sshd.service
$ exit
$ pct stop <VMID>
$ uname -r
kernel 4.9 及以上已支持 tcp_bbr,看内核版本是否大于等于4.9,否则要升级内核,或者安装bbr。
bbr2 效果要好于 bbr,相当原理可查看参考文档
# 查看可用的拥塞算法
$ sysctl net.ipv4.tcp_available_congestion_control
# 查看使用的拥塞算法
$ sysctl net.ipv4.tcp_congestion_control
# 设置拥塞算法
$ sysctl -w net.core.default_qdisc=fq
$ sysctl -w net.ipv4.tcp_congestion_control=bbr
# 查看设置结果
$ lsmod | grep bbr
$ echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
$ echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
$ sysctl -p
$ nano /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
6.0+ (380行)
if (data.status !== 'Active') {
替换为
if (false) {
重启服务
$ systemctl restart pveproxy.service
使用命令行创建 VM 非常方便,而且还可以使用各发行版的云镜像,快速创建速度又快,占用空间又小,非常方便。
# 增加硬盘空间
# 建议从模板创建虚拟机后,再增加虚拟机硬盘的空间,这样可以保持模板的大小
qm disk resize <VM_ID> scsi0 +30G
# 关闭
qm stop <vmid>
# 如果关闭失败
qm list
# 找到 vm 对应的 pid
kill <pid>
# 删除
qm destroy <vmid> --destroy-unreferenced-disks 1 --purge 1 --skiplock 1
# 强制删除
rm -f /etc/pve/nodes/*/*/<vm_id>.conf
# [修復Proxmox VE:無法刪除虛擬機器](https://blog.pulipuli.info/2014/08/proxmox-ve-fix-proxmox-ve-destroy.html#postcataproxmox-ve-fix-proxmox-ve-destroy.html0_anchor2)
# 关闭
pct stop <vmid>
pct list
# 查看存储空间使用情况
pvesm status
# 查看存储内的文件
pvesm list <storage>
# 查看存储配置
cat /etc/pve/storage.cfg
# 给local存储添加存储类型
pvesm set local --content snippets,rootdir,import,images,backup,vztmpl,iso
# 注意!!!片段文件只能放在 /var/lib/vz/snippets/ 目录下,不支持子目录
# 将local-lvm(LVM-Thin)合并到local
# 移动虚拟机硬盘到local
qm disk move <vmid> <disk> <storage> --format qcow2 --delete 1
# 移动容器卷到local
pct move-volume <vmid> <volume> <storage> --delete 1
# 删除local-lvm存储
lvremove pve/data
# 空间合并到local
lvextend -l +100%FREE -r pve/root
# 在WebUI的“数据中心”-"存储"里,手动移除local-lvm
特点:
不同版本:
Alpine 有许多版本,其中 VIRTUAL 是专门针对虚拟环境优化过的,所以主要使用这个版本来安装。
https://www.alpinelinux.org/downloads/
...
# 使用启动盘启动后,直接使用 root 登录系统
localhost login: root
...
localhost:~# setup-alpine
# 选择键盘布局
# 这里两个都选 cn 或都不选
...
Select keyboard layout: [none] cn
...
Select variant (or 'abort'): cn
# 设置主机名
...
Enter system hostname (fully qualified form, e.g. 'foo.example.org') [localhost] home
# 设置网络
...
Which one do you want to initialize? (or '?' or 'done') [eth0] eth0
Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] dhcp
Do you want to do any manual network configuration? (y/n) [n] n
# or 手动输入IP地址
Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] 192.168.10.16/24
Gateway? (or 'none') [none] 192.168.10.10
Do you want to do any manual network configuration? (y/n) [n] n
DNS domain name? (e.g 'bar.com')
DNS nameserver(s)? 114.114.114.114
# 设置密码
...
New password:
...
Retype password:
# 设置时区
# PRC 代理中国,也可以输入 Asia/,再输入 Shanghai
...
Which timezone are you in? ('?' for list) [UTC] PRC
# 设备代理
...
HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none] none
# 设置更新源
# f 是自动测试并选择最快的源,建议使用
...
Enter mirror number (1-74) or URL to add (or r/f/e/done) [1] f
#
Setup a user? (enter a lower-case loginname, or 'no') [no] no
# 设置ssh服务
Which ssh server? ('openssh', 'dropbear', or 'none') [openssh] openssh
# 这里一定要输入 yes
# 许多教程都说 Alpine 默认没有远程登录,都上手动修改,其实是可以在安装时就设备好的
Allow root ssh login? ('?' for help) [prohibit-password] yes
Enter ssh key or URL for root (or 'none') [none] none
# 设置磁盘
...
Which disk(s) would you like to use? (or '?' for help or 'none') [none] sda
...
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?] sys
...
WARNING: Erase the aboue disk(s) and continue? (y/n) [n] y
...
Installation is complete. Please reboot.
# 到这里安装全部完成
# 准备应答文件
home:~# reboot
home:~# rc-service iptables stop
home:~# rc-update del iptables
Proxmox系统安装后,日志报错
rrdcached[4513]: handle_request_update: Could not read RRD file.
pmxcfs[4527]: [status] notice: RRDC update error /var/lib/rrdcached/db/pve2-vm/85235: -1
pmxcfs[4527]: [status] notice: RRD update error /var/lib/rrdcached/db/pve2-vm/85235: mmaping file '/var/lib/rrdcached/db/pve2-vm/85235': Invalid argument
修复命令
$ rm -r /var/lib/rrdcached/db
$ systemctl restart rrdcached.service
$ apt-get update
$ apt-get dist-upgrade
使用 ifupdown2 网络管理软件包,还可以实时重新加载网络配置,而无需重新启动。
$ apt install ifupdown2
使用 PVE 的 WEB 管理界面,设置物理网卡的配置。
注意:一定要分配一个静态的IP地址,否则无法正常登录 PVE
节点 > 系统 > 网络:
保存后应用配置
使用 PVE 提供管理界面进行配置。 删除 vmbr0 设备的所有配置内容。
编辑 /etc/network/interfaces
$ nano /etc/network/interfaces
加入
source /etc/network/interfaces.d/*
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto enp1s0
iface enp1s0 inet static
address 192.168.10.66/24
gateway 192.168.10.1
iface vmbr0 inet manual
bridge-ports none
bridge-stp off
brideg-fd
创建新的虚拟网卡配置