build a devstack in a VM

本文旨在在单网卡eth0的ubuntu 14.04的VM里搭建devstack,VM的网卡使用NAT的方式

  1. 安装一个ubuntu server版的os,过程中选中ssh server和dns server以及virtual host组件安装进操作系统,装好后配置允许root ssh登陆,并安装git组件
apt-get install git
  1. 配置本地源(使用root用户)
(1)配置apt源:
vim /etc/apt/sources.list #注释掉所有行,添加如下源
deb http://10.89.155.100/ubuntu/ trusty main multiverse restricted universe
deb http://10.89.155.100/ubuntu/ trusty-updates main multiverse restricted universe
deb http://10.89.155.100/ubuntu/ trusty-security main multiverse restricted universe
(2)安装pip:
apt-get install python-pip
(3)配置pip源:
mkdir ~/pip
vim ~/.pip/pip.conf #添加如下源:
#[global]
#index-url = https://pypi.mirrors.ustc.edu.cn/simple/
[global]
index-url = http://10.89.155.98/simple/
[install]
trusted-host=10.89.155.98
(4)升级pip
pip install --upgrade pip
注: pip大版本必须保持7以上,否则之后安装会失败,此时最新版应为8,通过pip --version查看pip版本,期间如果遇到无法找到/usr/bin/pip的错误,采用建立软链接的方式解决:#ln -s  /usr/local/bin/pip /usr/bin/pip即可
  1. 添加stack用户
# adduser stack
# apt-get install sudo -y
# echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# sudo su - stack
  1. 下载devstack源码,此后所有操作均在stack用户下
(stack)$ git clone https://git.openstack.org/openstack-dev/devstack --branch=stable/kilo
(stack)$ cd devstack
  1. 添加local.conf文件,保存在devstack目录
[[local|localrc]]
DATABASE_PASSWORD=12345
RABBIT_PASSWORD=12345
SERVICE_TOKEN=12345
SERVICE_PASSWORD=12345
ADMIN_PASSWORD=12345

RECLONE=false
#OFFLINE=true

GIT_BASE=https://github.com
disable_service n-net
ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch
ENABLED_SERVICES+=,horizon
ENABLED_SERVICES+=,g-api,g-reg
ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron
ENABLED_SERVICES+=,q-lbaas,q-vpn,q-fwaas
ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch
ENABLED_SERVICES+=,ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api,ceilometer-anotification
ENABLED_SERVICES+=,ceilometer-alarm-notify,ceilometer-alarm-eval

HOST_IP=192.168.122.233
SERVICE_HOST=192.168.122.233
MYSQL_HOST=192.168.122.233
RABBIT_HOST=192.168.122.233
GLANCE_HOSTPORT=192.168.122.233:9292

## Neutron options
Q_USE_SECGROUP=True
FLOATING_RANGE="192.168.122.0/16"
FIXED_RANGE="10.0.0.0/24"
Q_FLOATING_ALLOCATION_POOL=start=192.168.122.60,end=192.168.122.70
PUBLIC_NETWORK_GATEWAY="192.168.122.254"
Q_L3_ENABLED=True
PUBLIC_INTERFACE=eth0
Q_USE_PROVIDERNET_FOR_PUBLIC=True
OVS_PHYSICAL_BRIDGE=br-ex
PUBLIC_BRIDGE=br-ex
OVS_BRIDGE_MAPPINGS=public:br-ex

# Logging
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/opt/stack/logs
注:其中所有192.168.122.233的IP替换成自己本机的IP,Neutron options里的各项RANGE做相应的改动,FIXED_RANGE不必改

  1. 修改stack.sh脚本,原因是git clone时国内下载速度奇慢,使用台湾代理会快很多
(stack)$ vim stack.sh +682 # 添加如下环境变量,保存
export http_proxy= http://172.16.100.191:8080
export https_proxy= http://172.16.100.191:8080
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com,10.89.155.100,10.89.155.98"
  1. 等待安装完成,此次安装会将所有需要的包和源码都安装,但是由于有代理的存在,最后配置openstack服务的时候会报错(503)并退出,此时需要将第6步中添加的代理注释掉,再次安装
(stack)$ vim stack.sh +682 #注释三行export,保存退出
(stack)$ ./unstack.sh
(stack)$ ./stack.sh
  1. 此时如果一切正常,你会在console上看到如下输出
This is your host ip: 192.168.122.233
Horizon is now available at http://192.168.122.233/
Keystone is serving at http://192.168.122.233:5000/
The default users are: admin and demo
The password: 12345
恭喜你,安装成功了
  1. 使用devstack
(stack)$ . openrc
(stack)$ nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
  1. 若由于关机或其他需求,需要重新启动devstack的各项服务只需
(stack)$ ./unstack.sh
(stack)$ ./rejoin-stack.sh[[local|localrc]]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值