Centos上eucalyptus源代码安装和问题解决说明文档
此文档结合eucalyptus官方网站说明,及在安装过程出现的问题解决方案,整理出一份完整的安装文档,供大家在源代码安装eucalyptus时参考。文档说明思路如下:
先说明在cc机器上的安装
第一:在安装前的准备工作:
1、 xen安装:一般linux在安装时让用户选择安装程序中有xen相关,选择即可。
测试xen安装是否正常:
命令:xm list
结果:
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 1721 1 r----- 1
如果测试不正确的话,需要重新卸载xen后重新安装xen,这个可参考网上xen安装文档
2、 测试dhcp服务器运行状态
命令:service dhcp status
3、 yum安装,在运行命令yum install gcc等时会出现问题如下:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons error was
[Errno 4] IOError:
Error: Cannot find a valid baseurl for repo: addons
关于此问题的解决参看网站http://centos.ustc.edu.cn/上的安装说明,即可正常使用
4、 安装vblade包,官网有说明:
For persistent dynamic block storage (aka EBS) to work, the front end will need to have the following software packages installed:
a) lvm2 package (e.g., command lvm should work)
b) aoetools package. The aoe module needs to be loaded on the front end as well as all nodes (modprobe aoe). If your kernel does not have ATA-over-Ethernet support, you will have to add that.
c) vblade package
我必须先下载一个vblade的安装包,然后查看安装包中的readme文件,查看如何安装此包,安装即可。
第二步:安装eucalyptus
1、 先安装工具安装包:
yum install -y java-1.6.0-openjdk-devel ant ant-nodeps libvirt-devel curl-devel httpd httpd-devel apr-devel openssl-devel dhcp libxml2 libxml2-devel gnutls gnutls-devel xen-devel libgcrypt-devel zlib-devel perl-Convert-ASN1 perl-Crypt-OpenSSL-RSA perl-Crypt-OpenSSL-Random chkfontpath scsi-target-utils fuse-libs swig gcc
2、 参看官网安装说明安装
(1)先在root下建立一个目录来安装eucalyptus:
mkdir zyq
先定义版本的环境变量: export VERSION=2.0.2
(2)下载源代码文件,将
eucalyptus-2.0.2-src-offline.tar.gz和eucalyptus-2.0.2-src-deps.tar.gz
上传至创建的文件夹zyq,解压源文件:
cd /root/zyq
tar zvxf eucalyptus-$VERSION-src.tar.gz
(3)设定环境变量:
命令运行:
pwd
cd eucalyptus-$VERSION
export EUCALYPTUS_SRC=`pwd`
export EUCALYPTUS=/opt/eucalyptus
(4)安装依赖包
cd $EUCALYPTUS_SRC
tar zvxf ../eucalyptus-$VERSION-src-deps.tar.gz
mkdir -p $EUCALYPTUS/packages/
安装axis2
cd $EUCALYPTUS/packages
tar zxvf $EUCALYPTUS_SRC/eucalyptus-src-deps/axis2-1.4.tgz
安装Axis2/C:
l 先设定环境变量:
export APACHE_INCLUDES=/usr/include/httpd/
export APR_INCLUDES=/usr/include/apr-1/
l 安装:
export AXIS2C_HOME=$EUCALYPTUS/packages/axis2c-1.6.0
cd $EUCALYPTUS_SRC/eucalyptus-src-deps/
tar zvxf axis2c-src-1.6.0.tar.gz
cd axis2c-src-1.6.0
CFLAGS="-w" ./configure --prefix=${AXIS2C_HOME} --with-apache2=$APACHE_INCLUDES --with-apr=$APR_INCLUDES --enable-multi-thread=no
make ; make install
安装Rampart/C
export AXIS2C_HOME=$EUCALYPTUS/packages/axis2c-1.6.0
export LD_LIBRARY_PATH=${AXIS2C_HOME}/lib:$LD_LIBRARY_PATH
cd $EUCALYPTUS_SRC/eucalyptus-src-deps/
tar zvxf rampartc-src-1.3.0-0euca1.tar.gz
cd rampartc-src-1.3.0
./configure --prefix=${AXIS2C_HOME} --enable-static=no --with-axis2=${AXIS2C_HOME}/include/axis2-1.6.0
make ; make install
安装完毕后修改文件$AXIS2C_HOME/axis2.xml,
vi $AXIS2C_HOME/axis2.xml
In the 'inflow' section, change:
to
In the 'outflow' section, change:
to
(5)安装eucalyptus
先确定JAVA_HOME是否定义,
export JAVA_HOME="/usr/lib/jvm/java-openjdk/"
export JAVA="$JAVA_HOME/jre/bin/java"
安装eucalyptus:
cd $EUCALYPTUS_SRC
./configure --with-axis2=$EUCALYPTUS/packages/axis2-1.4 --with-axis2c=$EUCALYPTUS/packages/axis2c-1.6.0 --enable-debug --prefix=$EUCALYPTUS
make ; make install
(6)部署eucalyptus
官网说明如下:
rsync -a $EUCALYPTUS/ root@{node-host-1}:$EUCALYPTUS/
rsync -a $EUCALYPTUS/ root@{node-host-2}:$EUCALYPTUS/
实现的功能是将/opt/eucalyptus下的内容复制一份在nc节点上,只是单纯的复制文件,所以在nc必须安装官网在安装说明的那些包,我在这采用了将以上安装的内容在nc也安装一遍,但是如果有多个nc节点的话,这样做会大大降低效率,但是必须保证nc节点的机器符合之前的安装需求。
(7) 配置主机
a.添加用户eucalyptus
useradd eucalyptus
b.配置hypervisor,我们采用libvirt来管理xen虚拟化
测试:
virsh list
正确结果:
Id 名称 状态
----------------------------------
0 Domain-0 running
2 i-5691096D 闲置
错误结果:
错误:连接到管理程序失败
解决办法就是修改配置文件,如下说明
l xen配置文件:
vi /etc/xend/xend-config.sxp (注意有的机器文件夹是xen,而不是xend)
修改为如下:
(xend-http-server yes)
(xend-unix-server yes)
(xend-unix-path /var/lib/xend/xend-socket)
(xend-address localhost)
(network-script network-bridge)
(vif-script vif-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)
(vncpasswd '')
l Libvirt
测试libvirt:
virsh list
修改libvirt配置文件:
vi /etc/libvirt/libvirtd.conf
#unix_sock_group = "libvirt" => unix_sock_group = "libvirt"
#unix_sock_ro_perms = "0777" => unix_sock_ro_perms = "0777"
#unix_sock_rw_perms = "0770" => unix_sock_rw_perms = "0770"
修改完以后要重启xend
c.配置network
有四种网络模式,我们采用的是system模式
d.配置Eucalyptus components
在所有节点上运行如下命令:
$EUCALYPTUS/usr/sbin/euca_conf -d $EUCALYPTUS --hypervisor xen --instances /usr/local/eucalyptus --user eucalyptus --setup
功能说明:
-d specifies the root of Eucalyptus installation ($EUCALYPTUS)
--hypervisor specifies the hypervisor ('xen' or 'kvm')切记在这里必须选择自己使用的虚拟化技术
--instances specifies where, on compute nodes, instance files will be stored
--user specifies the user that you created for running Eucalyptus
--setup invokes the first-time setup tasks
e. Distribution-specific post configuration steps(centos安装在这不需要修改,针对一些特殊的linux系统需要修改)
f.配置启动脚本
如果你想要在重启系统让cc、cloud、nc自动启动的话,分别在cc和nc运行相关命令:
ln -sf $EUCALYPTUS/etc/init.d/eucalyptus-cloud /etc/init.d/eucalyptus-cloud
ln -sf $EUCALYPTUS/etc/init.d/eucalyptus-cc /etc/init.d/eucalyptus-cc
ln -sf $EUCALYPTUS/etc/init.d/eucalyptus-nc /etc/init.d/eucalyptus-nc
(8) 运行eucalyptus
Eucalyptus的安装包括五个部件:cloud controller (CLC), Walrus, cluster controller (CC), storage controller (SC), and the node controller(s) (NCs).要将CLC 、Walrus、CC、SC 安装在一个机子上,nc安装另外的机子上。
确认$EUCALYPTUS/etc/eucalyptus/eucalyptus.conf配置是否正确,确定正确后执行下面的命令:
$EUCALYPTUS/usr/sbin/euca_conf -d $EUCALYPTUS –setup
$EUCALYPTUS/usr/sbin/euca_conf -d $EUCALYPTUS --enable cloud --enable walrus --enable sc
分别在cc和nc上启动eucalyptus:
# start enabled front-end services
$EUCALYPTUS/etc/init.d/eucalyptus-cloud start
# start the cluster controller
$EUCALYPTUS/etc/init.d/eucalyptus-cc start
分别在ncs上启动:
$EUCALYPTUS/etc/init.d/eucalyptus-nc start
备注:如果要是修改了$EUCALYPTUS/etc/eucalyptus/eucalyptus.conf文件,必须重启clc和cc,而且cc必须用cleanrestart来重启。
安装过程中中出现问题及解决:
1、在执行$EUCALYPTUS/etc/init.d/eucalyptus-cloud start出现如下结果:
error:EBS is enabled and vblade is not found.
原因:是因为在安装前没有看安装要求,、
For persistent dynamic block storage (aka EBS) to work, the front end will need to have the following software packages installed:
lvm2 package (e.g., command lvm should work)
aoetools package. The aoe module needs to be loaded on the front end as well as all nodes (modprobe aoe). If your kernel does not have ATA-over-Ethernet support, you will have to add that.
vblade package
解决办法:下载一个vblade安装包,安装后再运行$EUCALYPTUS/etc/init.d/eucalyptus-cloud start即可
2、$EUCALYPTUS/etc/init.d/eucalyptus-nc start出现如下结果:
eucalyptus not configred.
原因:是因为在安装时没有使用同步,所以nc的eucalyptus.conf文件中一些地方配置不对,
解决方案:需要对比cc上的配置文件然后进行修改即可(切记修改以后一定要以clean方式重启cc和clc)
第三步:配置eucalyptus
1、First-time Setup (2.0)
(1)需要注册安装好的部件,以使他们只能能够通信:
First, you will need to register various front end components. To do this, run the following commands on the front end.
$EUCALYPTUS/usr/sbin/euca_conf --register-walrus
$EUCALYPTUS/usr/sbin/euca_conf --register-cluster
$EUCALYPTUS/usr/sbin/euca_conf --register-sc
其中
Finally, you need to register nodes with the front end. To do so, run the following command on the front end,
$EUCALYPTUS/usr/sbin/euca_conf --register-nodes " ... "
其中
(2)Initial Configuration
在浏览器中输入:
https://front-end-ip:8443
第一次登录用户名和密码都为admin,登录后可以进行一下操作:
1. change the admin password,
2. set the admin's email address, and
3. confirm the IP of the Cloud Controller host.
详细情况请参看官网说明
备注:在修改完以后我们会看到'Credentials栏,想使用命令行工具必须从这里下载证书,
'Download Credentials',将下载的文件放在一目录下,执行下面操作:
mkdir $HOME/.euca
unzip euca2-admin-x509.zip -d $HOME/.euca
source $HOME/.euca/eucarc
在每次登录机器后想使用命令行工具,必须都运行命令:source $HOME/.euca/eucarc
2、 Hypervisor Configuration
在前面已经介绍
3、 Eucalyptus Network Configuration
前面简单介绍,想了解eucalyptus网络模式的详细信息请参看官网说明
4、 EBS Configuration
目前没有涉及到
第四步:管理eucalyptus
在这之前修改先安装euca2ools,http://open.eucalyptus.com/wiki/Euca2oolsGuide进行了说明,安装时最好直接使用安装包安装
1、 Managing Eucalyptus Images (2.0)(详细说明了上传镜像的过程)
2、 Web-Based Management
3、 Command-Line-Based Management
4、 Backup of Eucalyptus (2.0)(暂时还没有用到)
第五步:Troubleshoot Eucalyptus
Cloud Controller (CLC), Walrus, and Storage Controller (SC):
cloud-debug.log
cloud-error.log
cloud-output.log
Cluster Controller (CC)
cc.log
axis2c.log
httpd-cc_error_log
Node Controller (NC)
nc.log
axis2c.log
httpd-nc_error_log
euca_test_nc.log
可以在相关log文件中查询错误信息
第六步:创建实例
1、 下载证书:将下载的证书放在.euca文件夹下,.euca可以放在root下,也可以放在root的其他文件夹下
mkdir ~/.euca
cd ~/.euca
unzip name-of-the-key-zip.zip
chmod 0700 ~/.euca
chmod 0600 ~/.euca/*
source ~/.euca/euca2-*/eucarc
2、 Creating Keypairs
euca-add-keypair mykey | tee mykey.private
chmod 0600 mykey.private
3、创建实例:
euca-run-instances -k mykey -n
4、查看实例状态:
euca-describe-instances
5、 登录虚拟机
euca-authorize -P tcp -p 22 -s 0.0.0.0/0 default
ssh -i mykey.private root@
正确显示为:
The authenticity of host ip地址(ip地址)' can't be established.
RSA key fingerprint is bc:f0:34:9d:e9:e6:96:76:84:3d:0b:ac:28:9f:65:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ip地址' (RSA) to the list of known hosts.
-bash-3.2#
在这直接输入命令即可
创建实例过程中出现问题:
1、 创建实例后无法running
原因:/usr/local/eucalyptus的权限为root,所以不能运行,将所有者修改为eucalyptus即可
2、 无法获得ip地址:
原因:dhcp的问题,需要在nc上配置dhcp,以使得生成实例能分配到ip地址
有时会出现前几个能分配到ip地址,后面生成的实例无法分配到ip,是因为ip的范围设定太少了,扩大分配的ip地址范围即可解决此问题
3、 虽然有ip地址,无法登录虚拟机,是因为一些权限问题
第一种错误情况:ssh: connect to host ip地址 port 22: Connection timed out
解决方法:
之前一定要,euca-delete-keypair mykey以及mykey.private
(1)结束当前实例
(2)重新下载证书
(3)对证书解压,
(4)一定把证书权限改对
(5)chmod 0700 /root/.euca
chmod 0600 /root/.euca/*
(6)重新生成mykey
(7)创建实例
第二种错误情况:
The authenticity of host ip地址(ip地址)' can't be established.
RSA key fingerprint is 54:69:a5:10:b8:43:5b:c5:16:50:78:6f:09:16:c6:45.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ip地址' (RSA) to the list of known hosts.
Enter passphrase for key 'mykey.private':
解决办法:同第一种解决办法重新一遍
完整命令:
service dhcpd status
1000 /opt/eucalyptus/etc/init.d/eucalyptus-cloud restart
1001 /opt/eucalyptus/etc/init.d/eucalyptus-cc cleanrestart
1002 mkdir ~/.euca
1003 deldir ~/.euca
1004 rm -rf /root/.euca/
1005 mkdir ~/.euca
1006 cp /root/euca2-admin-x509.zip /root/.euca/
1007 cd ~/.euca
1008 unzip euca2-admin-x509.zip
1009 chmod 0700 ~/.euca
1010 chmod 0600 ~/.euca/*
1011 . ~/.euca/euca2-*/eucarc
1012 . ~/.euca/eucarc
1013 /usr/bin/euca-describe-images
1014 /usr/bin/euca-describe-keypairs
1015 /usr/bin/euca-delete-keypair mykey
1016 /usr/bin/euca-delete-keypair mykey.private
1017 unzip euca2-admin-x509.zip
1018 chmod 0700 ~/.euca
1019 chmod 0600 ~/.euca/*
1020 . ~/.euca/eucarc
1021 /usr/bin/euca-describe-keypairs
1022 /usr/bin/euca-add-keypair mykey >mykey.private
1023 /usr/bin/euca-describe-keypairs
1024 chmod 0600 mykey.private
1025 pwd
1026 /usr/bin/euca-run-instances -k mykey emi-1C6915A6
1027 /usr/bin/euca-describe-instances
1028 /usr/bin/euca-describe-instances
1029 /usr/bin/euca-describe-instances
1030 /usr/bin/euca-describe-instances
1031 /usr/bin/euca-describe-instances
1032 ping ip地址
1033 euca-authorize -P tcp -p 22 -s 0.0.0.0/0 default
1034 /usr/bin/euca-authorize -P tcp -p 22 -s 0.0.0.0/0 default
1035 ssh -i mykey.private root@ip地址