在Debian 10(Buster)上安装Proxmox VE 6的方法

安装后的一些问题,还在想办法解决


vm: ping domain
host:
journalctl -n xx -f
UFW BLOCK .....53......


Introduction

The installation of a supported Proxmox VE server should be done via Bare-metal_ISO_Installer. In some case it makes sense to install Proxmox VE on top of a running Debian Buster 64-bit, especially if you want a custom partition layout. For this HowTO the following Debian Buster ISO was used: [1].

Install a standard Debian Buster (amd64)

Install a standard Debian Buster, for details see Debian, and configure a static IP. It is recommended to only install the "standard" package selection, and nothing else, as Proxmox VE brings its own packages for qemu, lxc. A desktop environment is not necessary.

Add an /etc/hosts entry for your IP address

Please make sure that your machine's hostname is resolvable via /etc/hosts, i.e. you need an entry in /etc/hosts which assigns an address to its hostname.

Make sure that you have configured one of the following addresses in /etc/hosts for your hostname:

  • 1 IPv4 or
  • 1 IPv6 or
  • 1 IPv4 and 1 IPv6

Note: This also means editing or rather removing the address 127.0.1.1 that might be present as default.

For instance, if your IP address is 192.168.15.77, and your hostname prox4m1, then your /etc/hosts file could look like:

127.0.0.1       localhost.localdomain localhost
192.168.15.77   prox4m1.proxmox.com prox4m1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

You can test if your setup is ok using the hostname command:

hostname --ip-address
192.168.15.77 # should return your IP address here

Install Proxmox VE

Adapt your sources.list

Add the Proxmox VE repository:

echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list

Add the Proxmox VE repository key:

wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
chmod +r /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg  # optional, if you have a non-default umask

Update your repository and system by running:

apt update && apt full-upgrade

NOTE: If you have enabled other another arch (typically, i386 to run some older software) and apt complains about not being able to find /binary-i386: "Unable to find expected entry 'pve/binary-i386/Packages'" you need to remove other arch or use instead the row:

deb [arch=amd64] http://download.proxmox.com/debian/pve buster pve-no-subscription

this is because Proxmox repository does not have any other arch besides amd64; more info about multiarch on debian at: https://wiki.debian.org/Multiarch/HOWTO.

Install Proxmox VE packages

Install the Proxmox VE packages

apt install proxmox-ve postfix open-iscsi

Configure packages which require user input on installation according to your needs (e.g. Samba asking about WINS/DHCP support). If you have a mail server in your network, you should configure postfix as a satellite system, your existing mail server will then be the relay host which will route the emails sent by the Proxmox server to their final recipient.

If you don't know what to enter here, choose local only and leave the system name as is.

Finally, reboot your system, the new Proxmox VE kernel should be automatically selected in the GRUB menu.

Note: If you have a subscription key don't forget to switch to the enterprise repository after installation, see Package repositories.

Recommended: remove the os-prober package

The os-prober package scans all the partitions of your host, including those assigned to guests VMs, to create dual-boot GRUB entries. If you didn't install Proxmox VE as dual boot beside another Operating System, you can safely remove the os-prober package.

apt remove os-prober

Connect to the Proxmox VE web interface

Connect to the admin web interface (https://youripaddress:8006). If you have a fresh install and didn't add any users yet, you should use the root account with your linux root password, and select "PAM Authentication" to log in.

Once logged in, create a Linux Bridge called vmbr0, and add your first network interface to it.

Adapt vmbr0 settings

Troubleshooting

resolv.conf gets overwritten

The PVE GUI expects to control DNS management and will no longer take its DNS settings from /etc/network/interfaces. Any package that auto-generates (overwrites) /etc/resolv.conf will cause DNS to fail, e.g. packages 'resolvconf' for IPv4 and 'rdnssd' for IPv6.

ipcc_send_rec[1] failed

If you see

ipcc_send_rec[1] failed: Connection refused

then you should review your /etc/hosts file according to the instructions above.

Optional Steps

Optional: Remove the Debian kernel

apt remove linux-image-amd64 'linux-image-4.19*'

Update and check grub2 config by running:

update-grub

我们将介绍在Debian 10(Buster)Linux系统上安装Proxmox VE 6服务器,推荐和支持的Proxmox VE服务器安装通过Bare-metal_ISO_Installer完成。

简介

Proxmox虚拟环境(VE)是一种企业级开源服务器虚拟化解决方案,基于Debian Linux发行版,具有经过修改的Ubuntu LTS内核,它允许你部署和管理虚拟机和容器。

此设置假设你正在运行Debian 10 Buster Linux服务器(参考:安装Debian 10 Buster的方法),如果你没有,请按照我们的参考文章在将用作虚拟机监控程序的专用服务器上安装Debian 10,请注意,你需要一个支持Intel 64或AMD64 CPU扩展的64位处理器。

以下是在Debian 10(Buster)上安装Proxmox VE 6的方法。

一、更新Debian OS和设置系统主机名

1、更新Debian OS

在开始之前更新apt包索引:

sudo apt -y update

sudo apt -y upgrade

sudo reboot

2、设置系统主机名

我们需要设置主机名并确保它可以通过/etc/hosts解析:

sudo hostnamectl set-hostname prox6node01.example.com --static

echo "10.1.1.10 prox6node01.example.com prox6node01" | sudo tee -a /etc/hosts

example.com应替换为有效的域名。

二、添加Proxmox VE存储库

所有Proxmox软件包都将从匹配的上游存储库中提取,该存储库是手动添加到系统的,在这里,我们将添加Proxmox VE No-Subscription Repository。

导入GPG密钥:

wget -qO - http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg | sudo apt-key add -

-------- or -------

wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg

sudo mv proxmox-ve-release-6.x.gpg /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg

chmod +r /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg

然后添加Proxmox VE存储库:

echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription" | sudo tee /etc/apt/sources.list.d/pve-install-repo.list

你现在可以通过运行以下命令更新存储库和系统:

sudo apt update && sudo apt dist-upgrade

添加Proxmox VE Ceph存储库:

这是Proxmox VE的主要Ceph存储库,并保存Ceph软件包以供生产使用,你还可以使用此存储库仅更新Ceph客户端:

echo "deb http://download.proxmox.com/debian/ceph-nautilus buster main" | sudo tee /etc/apt/sources.list.d/ceph.list

三、安装Proxmox VE软件包

这些是为安装Proxmox VE软件包而执行的命令:

sudo apt install proxmox-ve postfix open-iscsi

如果你的网络中有邮件服务器,则应将postfix配置为satellite system,并且现有的邮件服务器将是“relay host”,它将把proxmox服务器发送的电子邮件路由到最终收件人,如果你不知道在此输入什么,请选择仅限本地。

安装后重新启动Debian系统以使用Proxmox VE内核启动:

sudo reboot

四、访问Proxmox VE Web界面

连接到Proxmox VE管理Web界面(https://youripaddress:8006):

Proxmox VE控制面板如下所示:

选择“PAM Authentication”并使用服务器的root用户密码进行身份验证。

登录后,创建一个名为vmbr0的Linux Bridge:

并添加你的第一个网络接口:

至此,整个Proxmox VE 6安装完成。

ProxmoxVE迁移虚拟机到其他PVE(基于QCOW2)

直接使用PVE的备份功能,再复制镜像到新的PVE节点上也是OK的,但是通用性较差,成功率较低。使用ZSTD压缩备份,若干次都是还原失败(提示校验失败)。逐放弃,选择迁移虚拟磁盘的方式操作。

1、截图备份原虚拟机的配置

img``

2、将lvm里的raw镜像转换为qcow2镜像

SHELL登陆宿主机,执行下面命令:
【2020.11补充】重要:先执行ls /dev/mapper/查看一下具体的存储名和硬盘名,以免搞混。

img

如图,pve和VM--LVM是你WEB界面可以看到的存储名(local存储显示为你的节点名),后面跟上的vm--100--disk--0是ID为100虚拟机的虚拟磁盘。

继续执行如下命令:

qemu-img convert -O qcow2 -c /dev/mapper/pve-vm--110--disk--0 VM110.qcow2
#其中pve-vm--110--disk--0是上图硬盘的名,注意格式对应修改,VM110.qcow2是转换到当前目录的文件名。
#可以再打开一个SHELL窗口,执行下面命令查看转换进度(结果显示在上面命令的下方)
pkill -USR1 -n -x qemu-img

3、转换完成后复制QCOW2镜像到目标PVE宿主机

复制方法自由发挥,可以通过方法如下:
SCP发送、WinSCP下载上传、挂载U盘、挂载移动硬盘、挂载NFS存储等等

分享:挂载NTFS格式的U盘(移动硬盘)
mkdir /mnt/Upan/
apt install -y ntfs-3g #(CentOS:yum install -y ntfs-3g
mount -t ntfs /dev/sdc1 /mnt/Upan/ #挂载
umount /dev/sdc1 #卸载

4、目标PVE宿主机创建虚拟机

根据步骤一的截图,创建虚拟机,然后在虚拟机详情里的“硬件”分离并删除自动创建的硬盘。

5、导入QCOW2磁盘镜像文件到新创建的虚拟机

SHELL登陆目标PVE宿主机,执行下面命令:

qm importdisk <vmid> <source> <storage>
#例子:qm importdisk 101 VM110.qcow2 local-lvm
#上面101是新建虚拟机的VM ID,VM110.qcow2是复制过来的QCOW2磁盘镜像文件,local-lvm是你的存储ID。

登陆WEB界面,应用未使用的磁盘。
启动虚拟机,完成迁移。

docker swarm集群部署应用

Manager

docker swarm init

Work1

docker swarm join --token SWMTKN-1-45iawvwnc45h6c7plj6zkmj0f0zd0tr8y5rvk9o35w25mt6pev-dahwo3nak1y7qyx0dwe803zbm xxx.xxx.xxx:2377

work2

docker swarm join --token SWMTKN-1-45iawvwnc45h6c7plj6zkmj0f0zd0tr8y5rvk9o35w25mt6pev-dahwo3nak1y7qyx0dwe803zbm xxx.xxx.xxx:2377

work3

docker swarm join --token SWMTKN-1-45iawvwnc45h6c7plj6zkmj0f0zd0tr8y5rvk9o35w25mt6pev-dahwo3nak1y7qyx0dwe803zbm xxx.xxx.xxx:2377

docker node ls

部署服务

我们使用 docker service 命令来管理 Swarm 集群中的服务,该命令只能在管理节点运行。

新建服务

现在我们在上一节创建的 Swarm 集群中运行一个名为 nginx 服务。

$ docker service create --replicas 3 -p 80:80 --name nginx nginx:1.13.7-alpine

现在我们使用浏览器,输入任意节点 IP ,即可看到 nginx 默认页面。

查看服务

使用 docker service ls 来查看当前 Swarm 集群运行的服务。

$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                 PORTS
kc57xffvhul5        nginx               replicated          3/3                 nginx:1.13.7-alpine   *:80->80/tcp

使用 docker service ps 来查看某个服务的详情。

$ docker service ps nginx
ID                  NAME                IMAGE                 NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS
pjfzd39buzlt        nginx.1             nginx:1.13.7-alpine   swarm2              Running             Running about a minute ago
hy9eeivdxlaa        nginx.2             nginx:1.13.7-alpine   swarm1              Running             Running about a minute ago
36wmpiv7gmfo        nginx.3             nginx:1.13.7-alpine   swarm3              Running             Running about a minute ago

使用 docker service logs 来查看某个服务的日志。

$ docker service logs nginx
nginx.3.36wmpiv7gmfo@swarm3    | 10.255.0.4 - - [25/Nov/2017:02:10:30 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0" "-"
nginx.3.36wmpiv7gmfo@swarm3    | 10.255.0.4 - - [25/Nov/2017:02:10:30 +0000] "GET /favicon.ico HTTP/1.1" 404 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0" "-"
nginx.3.36wmpiv7gmfo@swarm3    | 2017/11/25 02:10:30 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 10.255.0.4, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.99.102"
nginx.1.pjfzd39buzlt@swarm2    | 10.255.0.2 - - [25/Nov/2017:02:10:26 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0" "-"
nginx.1.pjfzd39buzlt@swarm2    | 10.255.0.2 - - [25/Nov/2017:02:10:27 +0000] "GET /favicon.ico HTTP/1.1" 404 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0" "-"
nginx.1.pjfzd39buzlt@swarm2    | 2017/11/25 02:10:27 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 10.255.0.2, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.99.101"

服务伸缩

我们可以使用 docker service scale 对一个服务运行的容器数量进行伸缩。

当业务处于高峰期时,我们需要扩展服务运行的容器数量。

$ docker service scale nginx=5

当业务平稳时,我们需要减少服务运行的容器数量。

$ docker service scale nginx=2

删除服务

使用 docker service rm 来从 Swarm 集群移除某个服务。

$ docker service rm nginx