配置
实验环境:VirtualBox虚机安装CentOS 6.5,部署OpenStack的Havana版本
关闭selinux
setenforce 0
vim /etc/selinux/config
内容如下:
SELINUX=disable
关闭Iptables
iptables默认规则可能造成无法从Host访问Guest中的Horizon
service iptables stop
chkconfig iptables off
reboot
也可以安装或启动前清空所有规则:
iptables -F
豆瓣源
pip国外源太慢,使用国内的豆瓣源
cd ~
mkdir .pip
vim ~/.pip/pip.conf
内容如下:
[global]
index-url = http://pypi.douban.com/simple/
配置
yum install -y git
cd /home
git clone https://github.com/openstack-dev/devstack.git
cd /home/devstack
vim localrc
localrc
内容如下,使用最简化安装,只安装了Keystone,Glance,Neutron和Horizon四个组件,可以根据需要修改:
HOST_IP=192.168.1.100
# Credentials
ADMIN_PASSWORD=111111
MYSQL_PASSWORD=111111
#DATABASE_PASSWORD=111111
RABBIT_PASSWORD=111111
SERVICE_PASSWORD=111111
SERVICE_TOKEN=token
# Output
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=False
SCREEN_LOGDIR=/opt/stack/logs
# Pre-requisite
ENABLED_SERVICES=rabbit,mysql,key
# Nova
ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch,n-novnc,n-xvnc,n-cauth
# Horizon
ENABLED_SERVICES+=,horizon
# Glance
ENABLED_SERVICES+=,g-api,g-reg
IMAGE_URLS+=",https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"
# Neutron
ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron
# Cinder
#ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch
# Heat - Orchestration Service
#ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
#IMAGE_URLS+=",http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F17-x86_64-cfntools.qcow2"
# Ceilometer - Metering Service (metering + alarming)
#ENABLED_SERVICES+=,ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api
#ENABLED_SERVICES+=,ceilometer-alarm-notify,ceilometer-alarm-eval
# Branches
NOVA_BRANCH=stable/havana
CINDER_BRANCH=stable/havana
GLANCE_BRANCH=stable/havana
HORIZON_BRANCH=stable/havana
KEYSTONE_BRANCH=stable/havana
NEUTRON_BRANCH=stable/havana
SWIFT_BRANCH=stable/havana
# Neutron Stuff
OVS_VLAN_RANGES=RegionOne:1:4000
OVS_ENABLE_TUNNELING=False
# Swift stuff
#SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
#SWIFT_REPLICAS=1
必须用stack
用户执行部署脚本
cd /home/devstack/tools
./create-stack-user.sh
chown -R stack:stack /home/devstack
su stack
cd /home/devstack
./stack
访问
可以从Host机以Web形式访问HOST_IP
打开Horizon,或者在系统中用命令行访问,执行如下脚本会export一些环境变量,访问时就不需要再输入用户名、密码等参数:
cd /home/devstack
source openrc admin admin
语法:
source openrc [user] [tenant]
查看设置了哪些环境变量:
export | grep OS_
测试一下:
keystone user-list
Troubleshooting
在虚机中部署,无法从Host访问Horizon
可能是默认iptables规则引起的,可以iptables -F
清掉所有规则,然后重启所有服务或者直接重启系统
重启后怎么办?
devstack是从源码安装的,所以无法使用service
服务,重启系统后需要手动运行devstack自带的rejoin-stack
脚本重启所有服务(使用screen
)
这些服务可能默认没有启动:
service rabbitmq-server start
service mysqld start
service openvswitch start
chkconfig rabbitmq-server on
chkconfig mysqld on
chkconfig openvswitch on
清掉Iptables的默认规则:
iptables -F
如果安装了swift
,还需要增加如下代码到rejoin-stack.sh
的source
语句后面来挂载卷:
if [[ -f ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \
${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1
else
echo the swift volume is already mounted
fi
fi
重启服务:
./rejoin-stack.sh
Cannot open your terminal ‘/dev/pts/0’
need root
object “netns” is unknown
内核不支持namespace,或者没有更新iproute
ip netns list
yum install -y http://rdo.fedorapeople.org/rdo-release.rpm
yum update kernel iproute
reboot
ip netns list