被控端部署:
先要配置好yum源:
[root@master yum.repos.d]# vim opennebula.repo
[root@master yum.repos.d]# cat opennebula.repo
[opennebula]
name=opennebula
baseurl=https://downloads.opennebula.org/repo/5.6/CentOS/7/x86_64
enabled=1
gpgkey=https://downloads.opennebula.org/repo/repo.key
gpgcheck=1
安装支持opennebula的kvm包:
[root@node1 yum.repos.d]# yum install -y opennebula-node-kvm
[root@store yum.repos.d]# yum install -y opennebula-node-kvm
完成后启动libvirted:
[root@node1 ~]# systemctl start libvirtd
[root@node1 ~]# systemctl enable libvirtd
[root@node1 ~]#
[root@node1 ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-10-01 12:11:28 CST; 44s ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 16376 (libvirtd)
CGroup: /system.slice/libvirtd.service
├─16376 /usr/sbin/libvirtd
[root@store ~]# systemctl start libvirtd
[root@store ~]# systemctl enable libvirtd
[root@store ~]#
[root@store ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-10-01 12:11:48 CST; 14s ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 16362 (libvirtd)
CGroup: /system.slice/libvirtd.service
├─16362 /usr/sbin/libvirtd
├─16459 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefi...
└─16460 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefi...
启动后,我们会发现多了一个桥接网卡:
配置SSH公钥免密码登录:免密登录。
在控制端和被控端在安装opennebula包组的时候所有的主机默认都已经创建了一个用户:oneadmin。
切换到对应的用户(同样的用户)
生成公钥和私钥,
以下命令需要按3次Enter键。
[root@master etc]# su - oneadmin
Last login: Sun Oct 1 18:44:28 CST 2023 on pts/0
[oneadmin@master ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/one/.ssh/id_rsa):
/var/lib/one/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/one/.ssh/id_rsa.
Your public key has been saved in /var/lib/one/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3puWpubvvQG6R4bLceWpc+JGC34NcZAlSxBM3Xox/Ng oneadmin@master
The key's randomart image is:
+---[RSA 2048]----+
| o++o=. |
| ..+o= |
| .o * |
| o = E |
| S..* . |
| .+o*.o |
| ooO.*. |
| =.%+o. |
| o+@*+o. |
+----[SHA256]-----+
将公钥写到授权密钥文件中。
cat /var/lib/one/.ssh/id_rsa.pub >> /var/lib/one/.ssh/authorized_keys
修改生成文件的权限:权限不能太大,太大会报错。
[oneadmin@master root]$ chmod 644 /var/lib/one/.ssh/authorized_keys
[oneadmin@master root]$ chmod 755 /var/lib/one/.ssh/
用scp将授权密钥文件拷贝到对应的主机上。
scp /var/lib/one/.ssh/* root@node1:/var/lib/one/.ssh/
说明:对应主机上没有.ssh目录,我使用了mkdir .ssh创建了目录。
在oneadmin用户下,使用ssh node1或者store,不需要密码验证。
[oneadmin@master root]$ ssh node1
[oneadmin@node1 ~]$ exit
logout
Connection to node1 closed.
[oneadmin@master root]$
[oneadmin@master root]$ ssh store
[oneadmin@store ~]$
[oneadmin@store ~]$ exit
logout
Connection to store closed.