请教如何安装openNebula
发布网友
发布时间:2023-07-05 14:01
我来回答
共1个回答
热心网友
时间:2024-11-19 13:26
增加 CentOS Karan 源:
# cd /etc/yum.repos.d
# wget
# yum update
安装 OpenNebula 需要的软件包以及编译 OpenNebula 源代码所需的工具:
# yum install gcc gcc-c++ make openssl-devel flex bison
# yum install ruby ruby-devel ruby-docs ruby-ri ruby-irb ruby-rdoc
# yum install rubygems
# gem install nokogiri rake xmlparser
# yum install scons
# yum install xmlrpc-c xmlrpc-c-devel
CentOS 自带的 sqlite 版本不行,需要下载和编译 sqlite 3.6.17 版本:
# wget
# tar xvzf sqlite-amalgamation-3.6.17.tar.gz
# cd sqlite-3.6.17/
# ./configure; make; make install
下载和编译 opennebula 2.0.1 源码包后,解压、编译和安装:
# tar zxvf opennebula-2.0.1.tar.gz
# cd opennebula-2.0.1
# scons
# ./install.sh -d /srv/cloud/one
# ls /srv/cloud/one/
bin etc include lib share var
启动 OpenNebula 前需要配置 ONE_AUTH 环境变量,这个环境变量从 $HOME/.one/one_auth 这个文件读取,所以要先创建 one_auth 这个文件后再启动 one(OpenNebula 服务程序):
# cd /root/
# mkdir .one
# cd .one/
# echo "oneadmin:password" > one_auth
# one start
OpenNebula 支持 KVM, Xen 和 VMware 三种虚拟技术,我们还需要告诉 OpenNebula 我们想用哪种,并重启 one 以便配置生效:
# vi /etc/one/oned.conf
...
IM_MAD = [
name = "im_xen",
executable = "one_im_ssh",
arguments = "xen" ]
VM_MAD = [
name = "vmm_xen",
executable = "one_vmm_ssh",
arguments = "xen",
default = "vmm_ssh/vmm_ssh_xen.conf",
type = "xen" ]
...
# one stop
# one start
安装和配置节点(Compute Node)
需要在每个 node 上都安装 Xen 或 KVM 的虚拟环境,具体请参考:在 CentOS 上安装和配置 Xen 和 在 CentOS 上安装和配置 KVM,还需要 ruby 运行环境:
# yum install ruby
交换 SSH Key
因为 OpenNebula Front 和 Nodes 之间是通过 SSH 通讯的,所以 front 和 nodes 之间要设置成 SSH 无密码登录避免 front 运行 node 上脚本或克隆镜像的时候输入密码,首先在 front 和 nodes 上配置 sshd:
# vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
# /etc/init.d/sshd restart
在 front (node00) 上创建 key 后拷贝到 node (node01):
# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node01
在1个 node (node01) 上创建 key 后拷贝到 front (node00):
# 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