本文介绍在Debian 10系统上安装OpenNebula LXD Node(节点)并配置的方法,内容有:更新Debian 10(Buster)系统、设置服务器主机名和配置NTP、将OpenNebula存储库添加到Debian 10系统、在Debian 10上安装OpenNebula LXD Node、在前端配置无密码SSH、将LXD节点添加到OpenNebula。
一、更新Debian 10(Buster)系统 在安装任何LXD软件包之前,建议您更新系统: sudo apt update sudo apt -y full-upgrade 升级后,如果需要,请检查并重新启动系统: [ -f /var/run/reboot-required ] && sudo reboot -f
二、设置服务器主机名和配置NTP 登录到LXD节点服务器并配置主机名: sudo hostnamectl set-hostname onelxd01.example.com 其中onelxd01.example.com是实际的LXD服务器主机名。 考虑将服务器的IP和主机名添加到/etc/hosts: $ sudo vim /etc/hosts 192.168.100.12 onelxd01.example.com onelxd01 # Set correctly 在安装chrony之前先卸载ntp软件包: sudo apt remove ntp sudo apt install chrony -y sudo systemctl restart chrony sudo systemctl enable chrony 在服务器上设置正确的时区: sudo timedatectl set-timezone Asia/Shanghai sudo timedatectl set-ntp yes 注:请根据自身的位置设置时区,参考用timedatectl在Linux中检查当前时区及更改时区(创建符号链接来更改时区)。 使用以下命令启动时间同步: $ sudo chronyc sources
三、将OpenNebula存储库添加到Debian 10系统 添加APT存储库之前,请在Debian 10上导入GPG密钥: sudo apt update sudo apt install wget gnupg2 -y wget -q -O- https://downloads.opennebula.io/repo/repo.key | sudo apt-key add - 然后添加OpenNebula社区版存储库: echo "deb https://downloads.opennebula.io/repo/5.12/Debian/10 stable opennebula" | sudo tee /etc/apt/sources.list.d/opennebula.list 更新APT软件包索引以确认是否按预期工作: sudo apt update
四、在Debian 10上安装OpenNebula LXD Node 运行以下命令以在Debian 10上安装OpenNebula LXD Node: sudo apt update sudo apt install opennebula-node-lxd 按y键同意安装提示: Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: kpartx liblzo2-2 libvncserver1 snapd squashfs-tools xfsprogs Suggested packages: rbd-nbd zenity | kdialog xfsdump acl attr quota The following NEW packages will be installed: kpartx liblzo2-2 libvncserver1 opennebula-node-lxd snapd squashfs-tools xfsprogs 0 upgraded, 7 newly installed, 0 to remove and 23 not upgraded. Need to get 15.7 MB of archives. After this operation, 65.7 MB of additional disk space will be used. Do you want to continue? [Y/n] y
五、在前端配置无密码SSH OpenNebula前端将使用SSH连接到管理程序节点,您需要将前端节点和所有虚拟机管理程序节点配置为通过SSH相互连接,而无需进行密码验证,这消除了任何手动干预。 1、OpenNebula前端节点操作 登录到您的前端OpenNebula节点: $ ssh username@frontend_ip 切换到一个管理员用户: $ sudo su - oneadmin oneadmin@onefront:~$ 在前端安装OpenNebula服务器软件包后,将自动为oneadmin用户生成SSH密钥对,该密钥对包括: $ file /var/lib/one/.ssh/id_rsa /var/lib/one/.ssh/id_rsa: OpenSSH private key $ file /var/lib/one/.ssh/id_rsa.pub /var/lib/one/.ssh/id_rsa.pub: OpenSSH RSA public key 从前端复制/var/lib/one/.ssh/id_rsa.pub文件的内容: $ cat /var/lib/one/.ssh/id_rsa.pub 2、OpenNebula LXD节点操作 登录到要配置的OpenNebula LXD节点: $ ssh username@onelxd01 使用以下命令切换到oneadmin用户帐户: $ sudo su - oneadmin oneadmin@onelxd01:~$ 创建授权密钥文件(如果不存在): $ touch /var/lib/one/.ssh/authorized_keys 将复制的前端SSH公钥添加到文件中: $ vim /var/lib/one/.ssh/authorized_keys 3、从前端测试无密码SSH连接 我建议您在前端/etc/hosts文件中添加IP和主机名映射: $ sudo vim /etc/hosts 192.168.100.12 onelxd01.example.com onelxd01 # Set correctly 以oneadmin用户身份发起SSH请求: oneadmin@onefront:~$ ssh oneadmin@onelxd01 无需密码验证即可确认SSH连接: Warning: Permanently added 'onelxd01,192.168.100.12' (ECDSA) to the list of known hosts. Linux onelxd01.example.com 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. oneadmin@onelxd01:~$
六、将LXD节点添加到OpenNebula 下一步是在OpenNebula前端中注册LXD节点,可以在CLI或Sunstone Web界面中执行此步骤。 登录到Sunstone Web界面并导航到Infrastructure->Hosts:
单击+按钮:
选择“LXD”作为主机类型:
输入主机名/IP地址,然后单击创建(Create)按钮:
添加成功后,该节点应出现在OpenNebula虚拟主机列表中:
至此,已完成了所有在Debian 10系统上安装和配置OpenNebula LXD Node的操作。 注:由于LXD不需要虚拟化扩展,因此可以与KVM或其他HVM虚拟机管理程序在同一虚拟化节点中和平共存。如果要管理预先存在的容器,可以使用导入VM功能。
相关主题 |