一、实验环境:
主机名 IP(Static) 系统 配置 用途
nebula 192.168.100.216 CentOS-6.4-x86_64-minimal 2CPU,1G RAM,20G DISK,1网卡 管理节点
node01 192.168.100.217 CentOS-6.4-x86_64-minimal 4CPU,32G RAM,300G DISK,2网卡 计算节点
一、管理节点配置:
1.配置hosts文件
编辑/etc/hosts文件,将管理节点和计算节点IP主机名的对应关系加入其中
[root@nebula ~]# vi /etc/hosts
nebula 192.168.100.216
node01 192.168.100.217
2.关闭selinux和iptables
[root@nebula ~]# vi /etc/selinux/config
SELINUX=disabled
[root@nebula ~]# iptables –F
[root@nebula ~]# service iptables stop
[root@nebula ~]# service ip6tables stop
[root@nebula ~]# chkconfig iptables off
[root@nebula ~]# chkconfig ip6tables off
[root@nebula ~]# reboot
3.更新源,在此使用fedora源
[root@nebula ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@nebula ~]# rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
4.安装mysql数据库
[root@nebula ~]# yum -y install mysql-devel mysql-server
[root@nebula ~]# service mysqld start
[root@nebula ~]# chkconfig mysqld on
[root@nebula ~]# mysql_secure_installation
Enter current password for root (enter for none): 回车
Set root password? [Y/n] y
New password: chensh
Re-enter new password: chensh
Password updated successfully!
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
5.创建Opennebula数据库
* MySQL的密码为chensh
[root@Master ~]# mysql -u root -p
mysql> CREATE USER 'oneadmin'@'localhost' IDENTIFIED BY 'oneadmin';
mysql> CREATE DATABASE opennebula;
mysql> GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'oneadmin';
mysql> FLUSH PRIVILEGES;
mysql> quit;
5.下载安装Opennebula4.2
[root@nebula ~]# wget http://dev.opennebula.org/packages/opennebula-4.2.0/CentOS-6/CentOS-6-opennebula-4.2.0-1.tar.gz
[root@nebula ~]# tar -zxvf CentOS-6-opennebula-4.2.0-1.tar.gz
[root@nebula ~]# cd opennebula-4.2.0-1
[root@nebula opennebula-4.2.0-1]# yum localinstall opennebula-4.2.0-1.x86_64.rpm opennebula-common-4.2.0-1.x86_64.rpm opennebula-flow-4.2.0-1.x86_64.rpm opennebula-gate-4.2.0-1.x86_64.rpm opennebula-java-4.2.0-1.x86_64.rpm opennebula-ozones-4.2.0-1.x86_64.rpm opennebula-ruby-4.2.0-1.x86_64.rpm opennebula-server-4.2.0-1.x86_64.rpm opennebula-sunstone-4.2.0-1.x86_64.rpm
[root@nebula opennebula-4.2.0-1]# cd context
[root@nebula context]# rpm -ivh opennebula-context-4.2.0-1.x86_64.rpm
[root@nebula context]# cd ../src
[root@nebula src]# useradd dsa
[root@nebula src]# rpm -ivh opennebula-4.2.0-1.src.rpm
11.设置.bash_profile环境变量
[root@nebula ~]# vi .bash_profile
添加:
export ONE_AUTH=/var/lib/one/.one/one_auth
[root@nebula ~]# source ~/.bash_profile
12.设置OpenNebula使用的数据库参数
[root@nebula ~]# vi /etc/one/oned.conf
# DB = [ backend = "sqlite" ]
# Sample configuration for MySQL
DB = [ backend = "mysql",
server = "localhost",
port = 0,
user = "oneadmin",
passwd = "oneadmin",
db_name = "opennebula" ]
13.设置SunStone使用的host参数
[root@nebula ~]# vi /etc/one/sunstone-server.conf
将原有:host: 127.0.0.1中IP字段修改为本机IP:
:host: 0.0.0.0
保存退出。
14.启动nebula和sunstone服务
[root@nebula ~]# one start
[root@nebula ~]# sunstone-server start
15.修改sunstone oneadmin用户密码
[root@nebula ~]# oneuser list
ID NAME GROUP AUTH VMS MEMORY CPU
0 oneadmin oneadmin core - - -
1 serveradmin oneadmin server_c - - -
[root@nebula ~]# oneuser passwd 0 password
[root@nebula ~]# echo “oneadmin:password” > /var/lib/one/.one/one_auth
二、计算节点配置:
一、管理节点配置:
1.配置hosts文件
编辑/etc/hosts文件,将管理节点和计算节点IP主机名的对应关系加入其中
[root@node01 ~]# vi /etc/hosts
nebula 192.168.100.216
node01 192.168.100.217
2.关闭selinux和iptables
[root@node01 ~]# vi /etc/selinux/config
SELINUX=disabled
[root@node01 ~]# iptables –F
[root@node01 ~]# service iptables stop
[root@node01 ~]# service ip6tables stop
[root@node01 ~]# chkconfig iptables off
[root@node01 ~]# chkconfig ip6tables off
[root@node01 ~]# reboot
3.设置桥接网络
(1).编辑/etc/sysconfig/network内容如下:
[root@node01 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node01
GATEWAY=br0
(2).编辑/etc/sysconfig/network-scripts/ifcfg-eth0内容如下,HWADDR可注释掉:
[root@node01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
ONBOOT=yes
BRIDGE=br0
(3).创建ifcfg-br0文件,内容如下:
[root@node01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
BOOTPROTO=static
ONBOOT=yes
TYPE=Bridge
IPADDR=192.168.100.217
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
BROADCAST=192.168.100.255
DELAY=0
(4).重启网络服务:
[root@node01 ~]# service network restart
(5).查看网桥接口:
[root@node01 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29ed3d46 no eth0
virbr0 8000.525400eeaa17 yes virbr0-nic
(6).查看br0接口IP:
[root@node01 ~]# ip addr show br0
7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
link/ether 00:0c:29:ed:3d:46 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.217/24 brd 192.168.100.255 scope global br0
inet6 fe80::20c:29ff:feed:3d46/64 scope link
valid_lft forever preferred_lft forever
(7).查看路由是否正确:
[root@node01 ~]# ip route
192.168.100.0/24 dev br0 proto kernel scope link src 192.168.100.217
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
169.254.0.0/16 dev br0 scope link metric 1007
default via 192.168.100.254 dev br0
(8).ping外网地址测试连通性:
[root@node01 ~]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=128 time=62.2 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=128 time=46.2 ms
4.创建cloud组和oneadmin用户
[root@node01 ~]# groupadd -g 1000 cloud
[root@node01 ~]# useradd -u 1000 -g cloud -m oneadmin -s /bin/bash
[root@node01 ~]# usermod -d /var/lib/one oneadmin
[root@node01 ~]# passwd oneadmin
[root@node01 ~]# chown oneadmin:cloud /var/lib/one
5.下载软件包
[root@node01 ~]# yum -y install sudo vconfig qemu-kvm qemu-kvm-tools libvirt wget
[root@node01 ~]# wget http://dev.opennebula.org/packages/opennebula-4.2.0/CentOS-6/CentOS-6-opennebula-4.2.0-1.tar.gz
6.更新源,在此使用fedora源
[root@node01 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@node01 ~]# rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
7.安装opennebula-node-kvm
[root@node01 ~]# tar -zxvf CentOS-6-opennebula-4.2.0-1.tar.gz
[root@node01 opennebula-4.2.0-1]# yum localinstall opennebula-node-kvm-4.2.0-1.x86_64.rpm opennebula-common-4.2.0-1.x86_64.rpm
8.配置libvirtd
编辑/etc/libvirt/libvirtd.conf配置libvirt,将操作权限授予给cloud组,并将listen_tcp = 1、unix_sock_rw_perms、auth_unix_ro、auth_unix_rw的“#”注释去掉。
[root@node01 ~]# vi /etc/libvirt/libvirtd.conf
listen_tcp = 1
unix_sock_group = "cloud"
unix_sock_rw_perms = "0770"
auth_unix_ro = "none"
auth_unix_rw = "none"
编辑/etc/libvirt/qemu.conf,设置VNC:
[root@node01 ~]# vi /etc/libvirt/qemu.conf
vnc_listen = “0.0.0.0″
user = "oneadmin" /*oneadmin用户管理虚拟机*/
group = "cloud"
dynamic_ownership = 0 /*禁止虚拟镜像动态调整所有权限*/
问题:
问题1:
[root@nebula .one]# oneuser list
/usr/lib/one/ruby/opennebula/client.rb:76:in `initialize': ONE_AUTH file not present (RuntimeError)
from /usr/lib/one/ruby/cli/one_helper.rb:245:in `new'
from /usr/lib/one/ruby/cli/one_helper.rb:245:in `get_client'
from /usr/lib/one/ruby/cli/one_helper.rb:289:in `set_client'
from /usr/bin/oneuser:43
from /usr/lib/one/ruby/cli/command_parser.rb:445:in `call'
from /usr/lib/one/ruby/cli/command_parser.rb:445:in `run'
from /usr/lib/one/ruby/cli/command_parser.rb:76:in `initialize'
from /usr/bin/oneuser:36:in `new'
from /usr/bin/oneuser:36
[root@nebula .one]#
解决办法:
[root@nebula ~]# vi .bash_profile
export ONE_AUTH=/var/lib/one/.one/one_auth
**************************************************************************************
问题2:
[root@nebula ~]# oneflow-server start
Stale .lock detected. Erasing it.
Error executing oneflow-server.
Check /var/log/one/oneflow.error and /var/log/one/oneflow.log for more information
more /var/log/one/oneflow.error
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- treetop (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/one/oneflow/lib/models/role.rb:17
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/one/oneflow/lib/models.rb:26
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/one/oneflow/oneflow-server.rb:49
解决办法:
[root@nebula ~]# gem install treetop polyglot parse-cron
**************************************************************************************
问题:3:
nebula创建qcow2磁盘和注册脚本: