一、.实验环境
ubuntu版本为11.10,单网卡(eth0),虚拟使用dhcp获取ip地址
二、基本安装过程
1.升级系统
$sudo apt-get install -y bridge-utils
$sudo apt-get vim
$sudo reboot
2.安装ntp服务
$sudo apt-getinstall ntp
$sudo vi/etc/ntp.conf
#将所有server开头的注释掉,并添加如下两行
server 127.127.1.0
fudge 127.127.1.0 stratum 10
$sudo /etc/init.d/ntprestart3.安装mysql
$sudo apt-getinstall -y mysql-server
$sudo sed -i's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
#行内全面用127.0.0.1代替0.0.0.0
$sudo servicemysql restart
$sudo mysql -uroot-ppwd -e 'CREATE DATABASE nova;'
$sudo mysql-uroot -ppwd -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANTOPTION;"
$sudo mysql-uroot -ppwd -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('root');"
#此处pwd应替换成自己的mysql数据库的密码4.安装glance镜像服务
$sudo apt-get install glance
5.安装openstack nova
$sudo apt-getinstall rabbitmq-server nova-common nova-doc python-nova nova-api nova-networknova-volume nova-objectstore nova-scheduler nova-compute nova-ajax-console-proxy
$sudo apt-getinstall -y euca2ools
$sudo apt-get install -yunzip$sudo vi/etc/nova/nova.conf
#添加内容如下,其中192.168.6.148为计算节点ip--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/var/lock/nova
--force_dhcp_release=True
--use_deprecated_auth
--iscsi_helper=tgtadm
--verbose
--libvirt_use_virtio_for_bridge=false
--connection_type=libvirt
#--root_helper=sudo nova-rootwrap
--ec2_private_dns_show_ip=false
--sql_connection=mysql://root:[email protected]/nova
--rabbit_host=192.168.6.148
--ec2_host=192.168.6.148
--ec2_url=http://192.168.6.148:8773/services/Cloud
--image_service=nova.image.glance.GlanceImageService
--glance_api_servers=127.0.0.1:9292
--glance_host=127.0.0.1
--glance_port=9292
--network_manager=nova.network.manager.FlatDHCPManager
--public_interface=eth0
--flat_interface=eth0
--flat_network_bridge=virbr0
--fixed_range=10.0.0.0/12
$sudo vim /etc/glance/glance-registry.conf
#修改sql_connetion如下
sql_connection=mysql://root:[email protected]/nova
$sudo restart libvirt-bin; sudo restart nova-network; sudo restart nova-compute; sudorestart nova-api; sudo restart nova-objectstore; sudo restart nova-scheduler;sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry
#初始化nova数据库
$sudonova-manage db sync
#建立实例网段
$sudo nova-manage network create public 10.0.0.0/24 1 255 --bridge_interface=virbr0
#建立外网ip段
$sudo nova-manage floating create --ip_range=10.10.10.2/27
$sudonova-manage user admin vpsee
$sudo nova-manage projectcreate mycloud vpsee$sudo su
$mkdir -p /home/vpsee/creds
$addgroup vpsee
$chown root:vpsee /home/vpsee/creds/
$nova-manageproject zipfile mycloud vpsee /home/vpsee/creds/novacreds.zip
$cd /home/vpsee/creds
$ unzip novacreds.zip
$source /home/vpsee/creds/novarc
$cat /home/vpsee/creds/novarc >> /home/vpsee/.bashrc
$source /home/vpsee/.bashrc$sudo restart libvirt-bin; sudo restart nova-network; sudo restart nova-compute; sudorestart nova-api; sudo restart nova-objectstore; sudo restart nova-scheduler;sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry
#查看euca环境是否建立成功
$euca-describe-availability-zonesverbose若成功则显示如下
AVAILABILITYZONEnovaavailable
AVAILABILITYZONE|- ubuntu
AVAILABILITYZONE| |- nova-schedulerenabled :-) 2013-01-24 08:49:02
AVAILABILITYZONE| |- nova-networkenabled :-) 2013-01-24 08:49:02
AVAILABILITYZONE| |- nova-computeenabled :-) 2013-01-24 08:49:03
#授权ping和ssh命令给VMS
$euca-authorize-P icmp -t -1:-1 default
$euca-authorize -P tcp -p22 default6.安装后测试
1)查看mysql中services表数据
$mysql -u$root -p$passwdnova -e 'select * from services;'
注意:root是用户名,password是密码,用你自己设定的mysql用户名和密码即可。2)获取image并发布
(emi="ami-00000003";eri="ari-00000002"; eki="aki-00000001";)
$image="ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz"
$wget http://smoser.brickies.net/ubuntu/ttylinux-uec/$image
$cp *.pem ..
$uec-publish-tarball $imagemybucket (buketName)3)为ssh创建安全认证
$euca-add-keypair mykey > mykey.priv
( euca-describe-keypairs查看keypair, euca-delete-keypairs keypairname删除指定keypair)
$chmod 0600 mykey.priv4)查看镜像
$euca-describe-images
5)创建并使用instance
$euca-run-instances$emi -k mykey -t m1.tiny
#注意:$emi用实际的代替,如:ami-00000003
$euca-reboot-instances i-00000001
$euca-describe-instances
#查看instance的ip
$nova list
如: +----+----------+--------+-----------------+
| ID | Name | Status | Networks |
+----+----------+--------+-----------------+
| 1 | Server 1 | BUILD | public=10.0.0.2 |
+----+----------+--------+-----------------+
$ssh -i mykey.priv [email protected]
$euca-terminate-instances i-00000001