实在很头疼,按照《OpenStack Cloud Computing Cookbook》操作流程,在虚拟机virtualbox安装openstack,创建成功的实例无法ping通,也无法ssh。环境配置及操作步骤如下:
1. 虚拟机配置
virtualbox在全局设置里,增加了两张hostonly网卡,名称分别为Adapter和Adapter 2#
Adapter的配置: ip 172.16.0.254 255.255.0.0 禁止dhcp
Adapter 2#的配置: ip 10.0.0.254 255.0.0.0 禁止dhcp
2. virtualbox虚拟机A运行的操作系统:ubuntu 12.04,虚拟机主机名controllor
virturalbox虚拟机B运行的操作系统:ubuntu 12.04,虚拟机名 nova-client,用于配置controllor
3. controllor的网卡配置: 3网卡,eth0对应真实的以太网网卡,采用NAT,访问互联网;eth1对应Host-Only网卡Adapter,静态分配ip,用作VM实例的public_interface;eth2对应于Host-Only网卡Adapter 2#,用作VM实例的internal_interface;配置文件的/etc/network/interfaces的内容如下:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 172.16.0.1
netmask 255.255.0.0
network 172.16.0.0
broadcast 172.16.255.255
auto eth2
iface eth2 inet manual
up ifconfig $IFACE 0.0.0.0 up
up ifconfig $IFACE promisc
4. 安装openstack
4.1)
sudo apt-get update
sudo apt-get -y install rabbitmq-server nova-api nova-objectstore nova-scheduler nova-network nova-compute nova-cert glance qemu unzip
4.2)
sudo apt-get -y install ntp
修改/etc/ntp.conf内容如下:
# Replace ntp.ubuntu.com with an NTP server on your network
server ntp.ubuntu.com
server 127.127.1.0
fudge 127.127.1.0 stratum 10
4.3)安装配置mysql
sudo apt-get -y install mysql-server
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
sudo service mysql restart
MYSQL_PASS=openstack
mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON nova.* TO
'nova'@'%'"
mysql -uroot -p$MYSQL_PASS -e "SET PASSWORD FOR 'nova'@'%' =
PASSWORD('$MYSQL_PASS');"
5.配置nova
/etc/nova/nova.conf的内容如下:
--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
--iscsi_helper=tgtadm
--libvirt_use_virtio_for_bridges
--connection_type=libvirt
--root_helper=sudo nova-rootwrap
--ec2_private_dns_show_ip
--sql_connection=mysql://nova:[email protected]/nova
--use_deprecated_auth
--s3_host=172.16.0.1
--rabbit_host=172.16.0.1
--ec2_host=172.16.0.1
--ec2_dmz_host=172.16.0.1
--public_interface=eth1
--image_service=nova.image.glance.GlanceImageService
--glance_api_servers=172.16.0.1:9292
--auto_assign_floating_ip=true
--scheduler_default_filters=AllHostsFilter
修改/etc/nova/nova-compute.conf文件,其修改后内容为:
--libvirt_type=qemu
6. 同步nova数据库
6.1) sudo nova-manage db sync
6.2)创建内网/外网ip
sudo nova-manage network create vmnet --fixed_range_v4=10.0.0.0/8 --network_size=64 --bridge_interface=eth2
sudo nova-manage floating create --ip_range=172.16.1.0/24
7. 重新启动controllor
sudo shutdown -r now
8. 创建nova管理帐号/角色/工程/keypair
sudo nova-manage user admin openstack
sudo nova-manage role add openstack cloudadmin
sudo nova-manage project create cookbook openstack
sudo nova-manage project zipfile cookbook openstack
上述最后一条命令执行后,会在当前目录下生成一个nova.zip文件,我的当前目录是/home/luo/,生成的文件名/home/luo/nova.zip
9. 创建ping和ssh实例的规则:
euca-authorize default -P tcp -p 22 -s 0.0.0.0/0
euca-authorize default -P icmp -t -1:-1
/* * * * * 以下是在虚拟主机ubuntu-client上的操作 *******/
1. 网卡配置为双网卡,其中eth0是hostonly adapter 0号网卡,跟controllor的eth1使用的是同一网卡,配置的ip地址是172.16.0.2,该主机可以直接ping 通controllor的172.16.0.1
2. 安装nova的配置管理客户端
sudo apt-get install euca2ools python-novaclient unzip
3. 配置远程管理controllor主机上的nova环境
cd
mkdir openstack
cd openstack
scp [email protected]:nova.zip .
unzip nova.zip
. novarc
euca-add-keypair openstack > openstack.pem
chmod 0600 *.pem
4. 上传镜像
wget http://uec-images.ubuntu.com/releases/precise/release/ubuntu-12.04-server-cloudimg-i386.tar.gz
sudo apt-get -y install cloud-utils
cloud-publish-tarball ubuntu-12.04-server-cloudimg-i386.tar.gz images i386
查看上传结果如下:nova image-list
luo@bogon:~/openstack$ nova image-list
+--------------------------------------+-----------------------------------------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+-----------------------------------------------------+--------+--------+
| 24c174b6-c235-47cd-9fa4-75ea209167df | images/precise-server-cloudimg-i386.img | ACTIVE | |
| 37711177-12bb-4783-8301-02ccb5498b42 | images/precise-server-cloudimg-i386-vmlinuz-virtual | ACTIVE | |
+--------------------------------------+-----------------------------------------------------+--------+--------+
5. 创建实例
euca-run-instances ami-00000002 -t m1.tiny -k openstack -g default
创建结果如下:
nova list
luo@bogon:~/openstack$ nova list
+--------------------------------------+----------+---------+----------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+----------+---------+----------------------------+
556d0355-8a8c-4754-b1af-bac3d40bdfbf | Server 2 | ACTIVE | vmnet=10.0.0.4, 172.16.1.1
+--------------------------------------+----------+---------+----------------------------+
luo@bogon:~/openstack$ nova show 556d0355-8a8c-4754-b1af-bac3d40bdfbf
+-------------------------------------+----------------------------------------------------------+
| Property | Value |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-SRV-ATTR:host | bogon |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | instance-00000002 |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2013-06-15T16:14:55Z |
| flavor | m1.tiny |
| hostId | a82a0309a34ef34778e26e1ece09187257a2fca69d46fda4e08c7a3f |
| id | 556d0355-8a8c-4754-b1af-bac3d40bdfbf |
| image | images/precise-server-cloudimg-i386.img |
| key_name | openstack |
| metadata | {} |
| name | Server 2 |
| progress | 0 |
| status | ACTIVE |
| tenant_id | cookbook |
| updated | 2013-06-15T17:02:46Z |
| user_id | openstack |
| vmnet network | 10.0.0.4, 172.16.1.1 |
+-------------------------------------+----------------------------------------------------------+
luo@bogon:~/openstack$
上述创建实例成功,分配的内网ip 是10.0.0.4, 外网ip是172.16.1.1
现在,在主机Controllor 172.16.0.1和Client 172.16.0.2上,都无法ping通172.16.1.1实例,在172.16.0.1上,也无法ping通10.0.0.4
luo@bogon:~/openstack$ ping 172.16.1.1
PING 172.16.1.1 (172.16.1.1) 56(84) bytes of data.
From 172.16.1.1 icmp_seq=1 Destination Host Unreachable
From 172.16.1.1 icmp_seq=2 Destination Host Unreachable
From 172.16.1.1 icmp_seq=3 Destination Host Unreachable
From 172.16.1.1 icmp_seq=4 Destination Host Unreachable
From 172.16.1.1 icmp_seq=5 Destination Host Unreachable
求解!!!!!