# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node00
onehost
front 和 每个 node 都能无密码 ssh 沟通后,就可以在 front 上 onehost create 命令来逐个加入 node,并用 onehost list 来查看是否创建成功:
# onehost create node01 im_xen vmm_xen tm_ssh
# onehost list
ID NAME CLUSTER RVM TCPU FCPU ACPU TMEM FMEM STAT
1 node01 default 0 400 400 400 3.8G 383M on
如果执行 onehost create 报错,查看 oned.log 日志发现 sudo: sorry, you must have a tty to run sudo 字样,原因则是 OpenNebula 需要远程 ssh/sudo 执行命令,而 CentOS 的 sudo 选项 requiretty 是默认打开的,ssh 需要一个 tty 才能执行,所以远程 sudo 就会出错,:
# onehost create node01 im_xen vmm_xen tm_ssh
# tail /var/log/one/oned.log
Tue Feb 22 11:08:58 2011 [InM][I]: Command execution fail: 'if [ -x "/var/tmp/one/im/run_probes" ]; then /var/tmp/one/im/run_probes xen 172.16.39.111; else exit 42; fi'
Tue Feb 22 11:08:58 2011 [InM][I]: STDERR follows.
Tue Feb 22 11:08:58 2011 [InM][I]: sudo: sorry, you must have a tty to run sudo
Tue Feb 22 11:08:58 2011 [InM][I]: Error executing xen.rb
...
解决办法就是关闭(注释掉) requiretty 这行:
# chmod 600 /etc/sudoers
# vi /etc/sudoers
#Defaults requiretty
因为 VPSee 的这两台服务器使用了 HTTP 代理上网,所以 OpenNebula 读取了系统的 http_proxy 环境变量,在 sched.log 日志里发现了 HTTP response 错误,这时候需要关闭 http_proxy:
# cat /var/log/one/sched.log
Tue Feb 22 14:27:39 2011 [HOST][E]: Exception raised: Unable to transport XML to server and get XML response back. HTTP response: 504
Tue Feb 22 14:27:39 2011 [POOL][E]: Could not retrieve pool info from ONE
# unset http_proxy
onevnet
创建和编辑虚拟网络配置文件,然后创建一个 OpenNebula 虚拟网络:
# vi small_network.net
NAME = "Small network"
TYPE = FIXED
BRIDGE = br0
LEASES = [ IP="192.168.0.5"]
LEASES = [ IP="192.168.0.6"]
LEASES = [ IP="192.168.0.7"]
# onevnet create small_network.net
# onevnet list
ID USER NAME TYPE BRIDGE P #LEASES
0 oneadmin Small network Fixed br0 N 0
onevm
创建和编辑虚拟机的启动配置文件,这里的 centos.5.5.x86.img 可以从 下载(收费)或者自己利用 Xen 工具创建一个:
# wget
centos.5.5.x86.img.tar.bz2
# tar jxvf centos.5.5.x86.img.tar.bz2
# mv centos.5.5.x86.img /srv/cloud/one/var/images/
# vi centos.one
NAME = centos
CPU = 1
MEMORY = 256
DISK = [
source = "/srv/cloud/one/var/images/centos.5.5.x86.img",
target = "sda1",
clone = "yes",
readonly = "no" ]
NIC = [ MAC = "00:16:3E:00:02:64", bridge = xenbr0 ]
OS = [ bootloader = "/usr/bin/pygrub" ]
用 onevm create 命令启动上面的 VM 配置文件,就会在 node01 上创建一个虚拟机,用 onevm list 查看会看到 prol 状态,表示正在创建过程中,创建完毕后状态会变成 runn:
# onevm create centos.one
# onevm list
ID USER NAME STAT CPU MEM HOSTNAME TIME
1 oneadmin centos prol 0 0K node01 00 00:09:09
# onevm list
ID USER NAME STAT CPU MEM HOSTNAME TIME
1 oneadmin centos runn 0 0K node01 00 00:22:17
就这样,我们在 node00 (front) 和 node01 (node) 这两台服务器上部署了一个最小的云,并且在 node01 上运行了一个基于 Xen 的虚拟机实例。