标签:
本篇主要阐述通过DeveStack 去部署Openstack(mitaka),对大多数来说安装部署Openstack 来说是个痛苦的过程,尤其是 OpenStack和它依赖的一些组件在快速发展中,经常出现这个版本组件对不上那个版本 dashboard等情况。如果只是看看或者初期玩玩 OpenStack的话,使用DevStack也是个不错的办法。DevStack采用了自动化源码部署的方式,适用于开发环境的部署和Openstack开发者,单节点,小环境;这里采用的操作系统为Ubuntu14.04。
Devstack目前是支持Ubuntu14.04和CentOS 7,不过全球的OpenStack开发者,大部分都在用Ubuntu 14.04。所以为了减少麻烦,还是建议你使用Ubuntu 14.04。建议下载官网mininalCD。选择Ubuntu 14.04 LTS “Trusty Tahr”版本。
https://help.ubuntu.com/community/Installation/MinimalCD
操作系统安装详见:
建议用vmware安装ubuntu mini,nat网络模式,安装过程中,多做快照备份。
安装devstack痛苦的其中一个原因,是OpenStack代码,都需要从github下载,这样由于网络的原因,经常导致各种错误,简直让人崩溃,各种错误,也根本无法通过google来解决。
目前国内已经提供了完整的OpenStack的github的mirror。http://git.trystack.cn
这样Devstack成功概率会大大提高。另外devstack还会下载image,下载的过程也是非常缓慢。trystack也提供大家常用的image下载。http://images.trystack.cn
对于ubuntu的系统,默认安全会从国外的源安装,导致速度比较慢,可以修改/etc/apt/source.list文件。建议备份原有的。
备份默认源
mv /etc/apt/source.list /etc/apt/source.list.bak
vi /etc/apt/source.list
设置新源
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
更新apt
apt-get update
http://www.pool.ntp.org是NTP的官方网站,在http://www.pool.ntp.org/zone/cn我们可以找到我们国家的NTP服务器。
ntpdate cn.pool.ntp.org
下载devstack,并指定稳定版本。
默认无论是Devstack和OpenStack,都是采用Master的代码进行安装,这样经常会出现,今天安装成功,明天失败,代码时刻在变化。所以我们不仅仅要指定OpenStack的版本,还需要指定Devstack的版本,才能提供安装成功的概率。
apt-get install git
git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/mitaka
或者
$git clone https://github.com/openstack-dev/devstack.git #克隆devstack的Git代码仓库
cd devstack/;git branch -a #显示本地分支
git checkout -b mitaka origin/stable/mitaka #切换到指定mitaka分支或标签
目前Devstack脚本已经不支持直接使用root身份运行,你需要创建stack用户运行。
./home/devstack/tools/create-stack-user.sh
修改devstack目录权限,让stack用户可以运行。
chown -R stack:stack /home/devstack
chmod 777 /dev/pts/0
保证该用户下sudo可以免密码运行,否则脚本执行过程中会出现权限问题。
可以修改/etc/sudoers, 在行 root ALL=(ALL:ALL) ALL 后添加 stack ALL=(ALL) ALL 然后保存文件,如下:
sudo echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
root切换到 stack 用户
su stack
建议创建最小化配置文件localrc,即使用非交互模式安装,内容如下:
[[local|localrc]]
# use TryStack git mirror
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git
# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter
# values for them by ``stack.sh``and they will be added to ``local.conf``.
ADMIN_PASSWORD=admin
DATABASE_PASSWORD=admin
RABBIT_PASSWORD=admin
SERVICE_PASSWORD=$ADMIN_PASSWORD
# Neither is set by default.
HOST_IP=192.168.108.128
#HOST_IPV6=2001:db8::7
# path of the destination log file. A timestamp will be appended to the given name.
LOGFILE=$DEST/logs/stack.sh.log
# Old log files are automatically removed after 7 days to keep things neat. Change
# the number of days by setting ``LOGDAYS``.
LOGDAYS=2
# Using stable/mitaka branches
# ---------------------------------
# Uncomment these to grab the stable/mitaka branches from the
# repos:
CINDER_BRANCH=stable/mitaka
GLANCE_BRANCH=stable/mitaka
HORIZON_BRANCH=stable/mitaka
KEYSTONE_BRANCH=stable/mitaka
KEYSTONECLIENT_BRANCH=stable/mitaka
NOVA_BRANCH=stable/mitaka
NOVACLIENT_BRANCH=stable/mitaka
NEUTRON_BRANCH=stable/mitaka
SWIFT_BRANCH=stable/mitaka
# Swift is now used as the back-end for the S3-like object store. Setting the
# hash value is required and you will be prompted for it if Swift is enabled
# so just set it to something already:
SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
# For development purposes the default of 3 replicas is usually not required.
# Set this to 1 to save some resources:
SWIFT_REPLICAS=1
# The data for Swift is stored by default in (``$DEST/data/swift``),
# or (``$DATA_DIR/swift``) if ``DATA_DIR`` has been set, and can be
# moved by setting ``SWIFT_DATA_DIR``. The directory will be created
# if it does not exist.
SWIFT_DATA_DIR=$DEST/data
其中:
FLOATING_RANGE:
表示的OpenStack云实例使用的FloatingIP的范围,这个范围应该和虚拟机的IP在同一个网段,但是是当前虚拟机没有使用的IP的范围。例如:我的IP是211.87.226.157,则我将FLOATING_RANGE设置为211.87.226.224/27,表示FloatingIP的范围是211.87.226.225~254。
FIXED_RANGE:
表示的在OpenStack上创建云实例后,该云实例内部使用的IP,可以不用修改。
FIXED_NETWORK_SIZE和FLAT_INTERFACE都不用修改,然后设置一下用户的密码,其中的ADMIN_PASSWORD待会登陆DashBoard是会用到,不要忘了自己设置的密码。
或者
直接使用devstack/sample/local.conf进行配置。bug需要进一步解决。
cp /home/devstack/samples/local.conf /home/devstack/local.conf
记得手动修改HOST_IP为你的虚拟机ip。
此外:
修改pip源可以加快安装速度,国内可以使用豆瓣源。在/root主目录下创建.pip文件夹
mkdir ~/.pip
vi ~/.pip/pip.conf
然后在该目录下创建pip.conf文件编写如下内容:
[global]
trusted-host = pypi.douban.com
index-url = http://pypi.douban.com/simple
保存并退出
运行
./stack.sh
Devstack 执行过程:
(1)下载并安装Openstack运行所需要的系统软件,大概包括一些python的组件、mysql、rabbitmq-server等
(2)下载openstack组件,包括nova 、keystone、glance、noVNC、horizon等
(3)下载并安装openstack源码所依赖的python库和框架
(4)安装openstack各组件
(5)启动各项服务
泡杯茶,等着就可以啦!
由于网速愿意,博主装了两个小时,最后还是哦啦。
安装成功结果如下:
2016-07-21 16:14:58.134 | ++lib/lvm:set_lvm_filter:173 sed ‘s/\/dev\///g‘
2016-07-21 16:14:58.142 | ++lib/lvm:set_lvm_filter:173 echo -e /dev/loop1
2016-07-21 16:14:58.165 | +lib/lvm:set_lvm_filter:173 pv=loop1
2016-07-21 16:14:58.182 | +lib/lvm:set_lvm_filter:174 new=‘"a|loop1|", ‘
2016-07-21 16:14:58.196 | +lib/lvm:set_lvm_filter:175 filter_string=‘global_filter = [ "a|loop0|", "a|loop1|", ‘
2016-07-21 16:14:58.212 | +lib/lvm:set_lvm_filter:177 filter_string=‘global_filter = [ "a|loop0|", "a|loop1|", "r|.*|" ] # from devstack‘
2016-07-21 16:14:58.221 | +lib/lvm:set_lvm_filter:179 clean_lvm_filter
2016-07-21 16:14:58.229 | +lib/lvm:clean_lvm_filter:154 sudo sed -i ‘s/^.*# from devstack$//‘ /etc/lvm/lvm.conf
2016-07-21 16:14:58.335 | +lib/lvm:set_lvm_filter:180 sudo sed -i ‘/# global_filter = \[*\]/a\ global_filter = [ "a|loop0|", "a|loop1|", "r|.*|" ] # from devstack‘ /etc/lvm/lvm.conf
2016-07-21 16:14:58.368 | +lib/lvm:set_lvm_filter:181 echo_summary ‘set lvm.conf device global_filter to: global_filter = [ "a|loop0|", "a|loop1|", "r|.*|" ] # from devstack‘
2016-07-21 16:14:58.381 | +./stack.sh:echo_summary:379 [[ -t 3 ]]
2016-07-21 16:14:58.389 | +./stack.sh:echo_summary:379 [[ True != \T\r\u\e ]]
2016-07-21 16:14:58.431 | +./stack.sh:echo_summary:385 echo -e set lvm.conf device global_filter to: global_filter = ‘[‘ ‘"a|loop0|",‘ ‘"a|loop1|",‘ ‘"r|.*|"‘ ‘]‘ ‘#‘ from devstack
========================
DevStack Components Timed
========================
run_process - 51 secs
apt-get-update - 11 secs
pip_install - 3357 secs
restart_apache_server - 17 secs
wait_for_service - 30 secs
git_timed - 5615 secs
apt-get - 353 secs
This is your host IP address: 192.168.108.128
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.108.128/dashboard
Keystone is serving at http://192.168.108.128:5000/
The default users are: admin and demo
The password: admin
stack@ubuntu:/home/ubuntu/devstack$
打开chrome输入: http://192.168.108.128/dashboard
久违的dashboard:
Cloning into ‘/opt/stack/requirements‘...
fatal: unable to access ‘https://git.openstack.org/openstack/requirements.git/‘: Could not resolve host: git.openstack.org; Unknown error
+functions-common:git_timed:603 [[ 128 -ne 124 ]]
+functions-common:git_timed:604 die 604 ‘git call failed: [git clone‘ https://git.openstack.org/openstack/requirements.git ‘/opt/stack/requirements]‘
+functions-common:die:186 local exitcode=0
+functions-common:die:187 set +o xtrace
[Call Trace]
./stack.sh:715:git_clone
/opt/devstack/functions-common:537:git_timed
/opt/devstack/functions-common:604:die
[ERROR] /opt/devstack/functions-common:604 git call failed: [git clone https://git.openstack.org/openstack/requirements.git /opt/stack/requirements]
Error on exit
./stack.sh: line 494: generate-subunit: command not found
解决办法:
sudo apt-get install python-pip
sudo pip install --upgrade pip
sudo pip install -U os-testr
这三条命令可以解决那个问题。
若os-testr无法apt-get安装,则:
若ascii codec canot decode…,则:
参考文章:
http://www.chenshake.com/openstack-project-series-3-devstack/
http://blog.csdn.net/myslq/article/details/51837578-series-3-devstack/
http://my.oschina.net/u/2381034/blog/491610?p=1
Devstack快速部署OpenStack Mitaka用户指南 All in One(by qiqishuang csdn)
标签:
原文地址:http://blog.csdn.net/qiqishuang/article/details/51990662