1. 实验环境的框架: (1) 管理节点(opennebula节点)
OS: ubuntu 12.04-amd64 IP: 192.168.0.11
(2)计算节点(VM部署节点)
OS: ubuntu 12.04-amd64 IP: 192.168.0.12
(3) 本文档也给出了当前节点即做为管理节点,又作为计算节点的情况,建议采用!2. ssh无密码登录 参考:
《openssh 无密码访问配置》实现管理节点和计算节点之间ssh相互无密码登录
http://blog.chinaunix.net/uid-20940095-id-3218637.html
3. 计算节点的配置和安装(如果采用本机,在本机安装这些软件即可)
(1) 虚拟化相关软件的安装
- sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ruby
- unix_sock_group = "oneadmin"
重启libvirtd进程
- sudo service libvirt-bin restart
修改
/var/run/libvirt/libvirt-sock文件的属组- sudo chown :oneadmin /var/run/libvirt/libvirt-sock
- sudo apt-get install bridge-utils
修改interface文件,内容如下:
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- auto eth0
- iface eth0 inet manual
- auto br0
- iface br0 inet static
- address 192.168.0.11
- netmask 255.255.255.0
- broadcast 192.168.0.254
- gateway 192.168.0.1
- bridge_ports eth0
- bridge_fd 9
- bridge_hello 2
- bridge_maxage 12
- bridge_stp off
重启网卡:
- sudo /etc/init.d/networking restart
(2)opennebula安装配置
- sudo mkdir -p /var/lib/ /*创建opennebula安装目录*/
- sudo groupadd -g 10000 oneadmin /*创建oneadmin组*/
创建oneadmin用户,-d:指明这个用户的家目录, -s:指明这个用户登录后使用的shell,-g:指明这个用户所在的组
- sudo useradd -u 10000 -m oneadmin -d /var/lib/one -s /bin/bash -g oneadmin
给oneadmin用户设定密码
设置oneadmin用户家目录的属组和用户
- sudo chown -R oneadmin:oneadmin /var/lib/one
测试下oneadmin用户是否能够正确登录
如果成功,输入exit命令退出!
安装NFS server , 即可以用来制定img文件的传输方式是通过nfs传输
- sudo apt-get install nfs-kernel-server
修改/etc/ioports文件,添加如下内容(意思是:192
.168
.0
.0
/24范围内的主机可以按照括号内的规定访问/var/lib/one目录,也可用*,表示此网段内的所有ip):
- /var/lib/one 192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash,anonuid=10000,anongid=10000)
重启NFS服务
- sudo /etc/init.d/nfs-kernel-server start
切换到oneadmin用户,安装必须的软件
- su -l oneadmin
- sudo apt-get install libsqlite3-dev libxmlrpc-c3-dev g++ ruby libopenssl-ruby libssl-dev ruby-dev
- sudo apt-get install libxml2-dev libmysqlclient-dev libmysql++-dev libsqlite3-ruby libexpat1-dev
- sudo apt-get install rake rubygems libxml-parser-ruby1.8 libxslt1-dev genisoimage scons
- sudo gem install nokogiri rake xmlparser
- sudo apt-get install mysql-server
配置mysql数据库,并执行如下命令:
- mysql -u root -p
- CREATE USER 'oneadmin'@'localhost' IDENTIFIED BY 'oneadmin';
- CREATE DATABASE opennebula;
- GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'oneadmin';
- quit;
解压opennebula,并进行编译:
- cd ~/opennebula-3.1.4
- scons sqlite=no mysql=yes
安装opennebula:
- ./install.sh -u oneadmin -g oneadmin -d /var/lib/one
设置opennebula相关的环境变量:
- vim ~/.bash_profile
- export ONE_LOCATION=/var/lib/one
- export ONE_AUTH=$ONE_LOCATION/.one/one_auth
- export ONE_XMLRPC=http://192.168.0.12:2633/RPC2
- export PATH=$ONE_LOCATION/bin:/usr/local/bin:/var/lib/gems/1.8/bin/:/var/lib/gems/1.8/:$PATH
注意:如果你的环境是本机即做管理节点又做计算节点,将192.168.0.12改成localhost. 创建opennebula用户授权文件:
- mkdir ~/.one
- echo "oneadmin:" > ~/.one/one_auth
修改opennebula配置文件:
- /*将58行注释*/
- #DB = [ backend = "sqlite" ]
- /*修改61-66行如下*/
- DB = [ backend = "mysql",
- server = "192.168.0.12", /*如果本机即做为计算节点又作为管理节点,改为:localhost*/
- port = 0,
- user = "oneadmin",
- passwd = "oneadmin",
- db_name = "opennebula" ]
启动opennebula,并测试是否安装成功:
如果能够显示如下内容,说明安装成功:
- ID USER GROUP NAME STAT CPU MEM HOSTNAME TIME
阅读(4012) | 评论(0) | 转发(0) |