Ubuntu16.04系统下基于Devstack(ocata)的Openstack的单节点环境搭建

一、基础准备工作

Ubuntu16.04Server 镜像 地址链接:https://pan.baidu.com/s/1N0EUnGxA2Y-jM64ZSTMwow 密码:a3hl

VMware虚拟机等其他虚拟机设备,安装前,请大家检查好自己的虚拟机资源,虚机内存和cpu分配的过小的话,容易出问题。

二、基础环境搭建

我们是从0配置开始搭建的,因此相对来说,出现问题后容易解决,如果你用真机来搭建环境,容易出现问题(我就在真机上安装python的包出现了问题),如果大家没有很强的需求或者没有太大的必要的情况下,建议大家装一台虚机搭建一下环境。

那下面就开始讲解devstack的搭建,以及碰到的部分问题(希望大家见招拆超吧,有些坑我也没踩过):

1、更换Ubuntu的安装包源:

cd /etc/apt/ 最好在修改source文件前,cp一下,做一个备份。

sudo vi source.list文件,将文件的内容全部删掉,替换为阿里的源:

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multive

3、更换pip源

扫描二维码关注公众号,回复: 5760648 查看本文章

使用国内pip源

mkdir ~/.pip

vi ~/.pip/pip.conf

然后在pip.conf 添加如下内容: 

[global]

timeout=6000

trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/

3、检查一下是否有git和python-pip

没有的话,安装:sudo apt-get install git & sudo install apt-get install python-pip

4、更新安装包

替换好之后,使用sudo apt-get upgrade 进行升级,不放心的再来一句,sudo apt-get update

至此,基本环境基本结束

三、devstack的下载与安装

1、下载devstack

我们就从github上拉下来就好,git clone https://github.com/openstack-dev/devstack.git  -b stable/ocata

2、检查devstack版本

git branch -a ※号指的那个就是版本,如果是ocata就没有问题

3、创建stack用户

以root用户进入devstack下的tools目录,执行create-stack-user.sh脚本,并编辑密码:

sudo passwd stack

4、将stack用户赋予sudo的权限:

sudo echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

5、修改文件夹权限和所有权

进入到devstack的上级目录,chown -R stack:stack /devstack

sudo chmod -R stack:stack /opt/stack

6、书写local.conf文件

附一个自己的:

# use TryStack git mir
#GIT_BASE=https://github.com
#NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
#SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git

GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/spice/spice-html5.git


#OFFLINE=True
RECLONE=True

# Define images to be automatically downloaded during the DevStack built process.
DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS+="http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img"

HOST_IP=192.168.221.142

# Credentials
DATABASE_PASSWORD=root
ADMIN_PASSWORD=xps
SERVICE_PASSWORD=xps
SERVICE_TOKEN=xps
RABBIT_PASSWORD=xps

RIZON_BRANCH=stable/ocata
KEYSTONE_BRANCH=stable/ocata
NOVA_BRANCH=stable/ocata
NEUTRON_BRANCH=stable/ocata
GLANCE_BRANCH=stable/ocata
CINDER_BRANCH=stable/ocata



#keystone
KEYSTONE_TOKEN_FORMAT=UUID
#安装时依赖报错所以不启动这个服务
#disable_service tempest
##Heat
HEAT_BRANCH=stable/ocata
enable_service h-eng h-api h-api-cfn h-api-cw



## Swift
SWIFT_BRANCH=stable/ocata
ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account
SWIFT_REPLICAS=1
SWIFT_HASH=123456


# Enabling Neutron (network) Service
disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service q-metering
enable_service neutron

## Neutron options
#注掉网络创建命令,成功率会增高。
Q_USE_SECGROUP=True
#FLOATING_RANGE="201.0.0.0/24"
#FIXED_RANGE="12.0.0.0/24"
#Q_FLOATING_ALLOCATION_POOL=start=201.0.0.30,end=201.0.0.39
#PUBLIC_NETWORK_GATEWAY="201.0.0.1"
Q_L3_ENABLED=True
PUBLIC_INTERFACE=eth1
Q_USE_PROVIDERNET_FOR_PUBLIC=True
OVS_PHYSICAL_BRIDGE=br-ex
PUBLIC_BRIDGE=br-ex
OVS_BRIDGE_MAPPINGS=public:br-ex

# #VLAN configuration.
Q_PLUGIN=ml2
ENABLE_TENANT_VLANS=True

# Logging
LOGFILE=/home/jia/stack-log/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/home/jia/stack-log/

 大家注意修改host-ip的地址和logging的日志目录文件

7、在stack用户下,运行./stack.sh,如果有问题的话,使用FORCE=Yes ./stack.sh

四、debug

上面是基本的操作,但是,往往不会一番风顺,下面记录几个比较常见的bug:

1、download of get-pip.py failed:

这个比较常见,网上的说法:

打开终端,输入

wget http://python-distribute.org/distribute_setup.py

sudo python distribute_setup.py

wget https://github.com/pypa/pip/raw/master/contrib/get-pip.py

sudo python get-pip.py

然后在devstack/tools目录下,找到install_pip.py,注释掉install_get_pip这个函数调用,再执行./stack.sh

但是基本会报404,有人说用date -s,但也没有卵用。

使用命令:wget https://bootstrap.pypa.io/get-pip.py 即可

2:、generate-subunit: command not found:

sudo apt-get install python-pip

sudo pip install --upgrade pip

sudo pip install -U os-testr

3、Currently installed pip version 1 does not meet minimum requirements:

The code in '/opt/stack/devstack/inc/python' line 142 to 148
 local pip_version
    pip_version=$(python -c "import pip; \
                        print(pip.__version__.strip('.')[0])")
    if (( pip_version<6 )); then
        die $LINENO "Currently installed pip version ${pip_version} does not" \
            "meet minimum requirements (>=6)."
    fi
When the pip version >10, the resule of 'pip.__version__.strip('.')[0]' is 1, then the error happen.
改为:
The code should be:
local pip_version
    pip_version=$(python -c "import pip; \
                        print(pip.__version__.split('.')[0])")
    if (( pip_version<6 )); then
        die $LINENO "Currently installed pip version ${pip_version} does not" \
            "meet minimum requirements (>=6)."
    fi

猜你喜欢

转载自blog.csdn.net/sullivan_jia/article/details/81670116