此文章是之前所发布的《利用centos-6.3源实现opennebula-3.2的快速安装部署》一文的升级版。本教程在CentOS-6.3的64位版本和64位版本上测试通过。
1. 网络拓扑
采用了两台物理机作为部署环境:
管理节点+计算节点: 192.168.35.16
计算节点:192.168.35.17
2. 管理节点
2.1 配置网易源
(1)安装完CentOS-6.3后,配置centos-6.3的网易源,在/etc/yum.repos.d/新建文件centos.repo,内容如下:
#########################################################################
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#########################################################################
(2)yum update
注意:如果是redha的ost建议选择N
2.2 管理节点配置(计算节点也执行相同操作)
(1)创建oneadmin用户和属组
# groupadd -g 600 oneadmin
#useradd -u 600 -g oneadmin oneadmin
(2)设置oneadmin用户的密码(这里设为:oneadmin)
# passwd oneadmin
(3)配置oneadmin用户,使其具有sudo权限
#vim /etc/sudoers //在原来的root用户下,增加如下一行
oneadmin ALL=(ALL) NOPASSWD: ALL
(4)配置/etc/hosts文件,添加如下两行
192.168.35.16 node1
192.168.35.17 node2
2.3 配置管理节点和计算节点之间的互信
(1)oneadmin用户无密码ssh登录设置
#su - oneamdin
# ssh-keygen -t dsa #出现提示默认回车不要输入
# cat .ssh/id_dsa.pub >> .ssh/authorized_keys
# chmod 644 ~/.ssh/authorized_keys
# chmod 755 ~/.ssh
#vi ~/.ssh/config
StrictHostKeyChecking no
#chmod 600 ~/.ssh/config
# scp –r ~/.ssh oneadmin@node1:~/
oneadmin@node1's password: #默认oneadmin用户密码
# scp –r ~/.ssh oneadmin@node2:~/
(2)验证ssh无密码登录是否配置成功
#ssh oneadmin@node1 date
#ssh oneadmin@node2 date
如果在不输入密码的情况下正确输出,即表示配置成功。
2.4 管理节点软件安装(root用户下执行如下指令)
# 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 libxslt
# yum install mysql-server mysql-devel.x86_64 sqlite-devel.x86_64
2.5 管理节点环境变量设置
#su - oneadmin
$ mkdir ~/.one
$ vi ~/.one/one_auth
oneadmin:oneadmin
#su - oneadmin
$ vim ~/.bash_profile
export ONE_LOCATION=/opt/nebula/ONE
export ONE_AUTH=$HOME/.one/one_auth
export ONE_XMLRPC=http://localhost:2633/RPC2
export PATH=$ONE_LOCATION/bin:$PATH:.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:.
2.6 opennebula 编译安装
(1)自行下载opennebula-3.8.3,解压后,执行如下命令:
$cd opennebula-3.8.3
$ scons mysql=yes
2.7 datastore的配置
在管理节点和计算节点上都执行如下操作,意思是:用sdb1作为datastore,可以根据自己实际情况而定
#mkdir /data0
#mount /dev/sdb1 /data0
#chown oneadmin:oneadmin /data0 -R
# su - oneadmin
$ vim share/etc/oned.conf // 修改数据库为mysql,并修改mysql的访问密码
#DB = [ backend = "sqlite" ]
# Sample configuration for MySQL
DB = [ backend = "mysql",
server = "localhost",
port = 0,
user = "root",
passwd = "123456",
]
修改datastores的路径:
DATASTORE_LOCATION = /data0
2.8 opennebula安装
(2)opennebula安装
$exit(退出oneadmin用户到root用户下)
#mkdir /opt/nebula/ONE -p
#chown oneadmin:oneadmin /opt/nebula -R
su - oneadmin
$ cdopennebula-3.8.3
$ ./install -d /opt/nebula/ONE
2.9安装sunstone
$ cd opennebula-3.8.3/share/install_gems/
$sudo ./install_gems sunstone
3. 计算节配置
参见管理节点的配置部分
4. 计算节点软件安装
yum install ruby kvm libvirt
5. 启动opennebula和sunstone
到管理节点,执行:
#su - oneadmin
$ one start
$sunstone-server start
6. 通过浏览器访问opennebula
192.168.35.16:9689
用户名和密码都为: oneadmin