Ubuntu16.04 安装openstack

更换为清华镜像源

vim /etc/apt/source.list

将文件替换为以下内容

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

更新

sudo apt-get update

sudo apt-get upgrade

安装pip

apt-get install python-pip

更新pip

sudo pip install --upgrade pip

更改pip源

mkdir ~/.pip

vim ~/.pip/pip.conf

[global]

index-url = http://pypi.douban.com/simple/

trusted-host = pypi.douban.com

设定时间

timedatectl set-timezone "Asia/Shanghai"

timedatectl set-timezone UTC

写入硬件

sudo hwclock -w

创建stack用户

sudo useradd -s /bin/bash -d /opt/stack -m stack

echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack

切换至stack用户:

sudo su stack

下载devstack

cd /opt/stack

git clone https://github.com/openstack-dev/devstack -b stable/queens

cd devstack

编辑local.conf文件

sudo vi local.conf

控制节点:(HOST_IP改为你的控制节点ip,# Credentials 设置密码,# Branches设置要装的openstack版本)

[[local|localrc]]
# 使用trystack来下载镜像
GIT_BASE=http://git.trystack.cn

#用于指定每次是否重新下载文件,注释掉RECLONE第二次部署时可以很快部署
#OFFLINE=True
RECLONE=True  

#用于指定本机的IP地址
HOST_IP=172.16.0.13

# Credentials
DATABASE_PASSWORD=pass
ADMIN_PASSWORD=pass
SERVICE_PASSWORD=pass
SERVICE_TOKEN=pass
RABBIT_PASSWORD=pass

#用于指定devstack下载的openstack分支,本文中直接使用master分支无需指定
#HORIZON_BRANCH=stable/mitaka
#KEYSTONE_BRANCH=stable/mitaka
#NOVA_BRANCH=stable/mitaka
#NEUTRON_BRANCH=stable/mitaka
#GLANCE_BRANCH=stable/mitaka
#CINDER_BRANCH=stable/mitaka

# 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

# Logging
#LOGFILE=/opt/stack/logs/stack.sh.log
#VERBOSE=True
#LOG_COLOR=True
#SCREEN_LOGDIR=/opt/stack/logs

在stack用户运行安装脚本(不要使用root)

/opt/stack/devstack/stack.sh

通常会报错,要求使用如下命令:

FORCE=yes /opt/stack/devstack/stack.sh

过程中需要为不同服务设置密码,建议设置成相同。

约安装一个小时左右,过程中会从镜像站、pip源、git等多处下载文件和依赖,time out多半是网速问题。git clone慢换4G。

会由于缺少各种依赖包而报错,只列举我遇到并解决的。

安装成功

出现This is your ip 等内容,即代表安装成功。

————————————————

砖治疑难杂症

运行脚本stack.sh(用stack权限运行,请勿使用root权限)

# !!!!主机名称不能加下划线

`hostname` 查看主机名

`sudo vim /etc/hostname`更改主机名

可能需要`sudo vim /etc/hosts`更改主机名

`sudo reboot`重启

# pip安装依赖过程中,有时会出现依赖冲突的问题,是由于某些库的版本大于配置要求的版本,

# 而这些库的依赖可能与配置要求中的依赖版本不一致,即使手动升级,安装脚本仍然会降级.

可以根据冲突提示,将`~/requirements/`下的依赖txt文件中的版本更改.

# 错误信息如下:

./stac.sh:191 if you wish to run this script anyway run with FORCE=yes /home/dexstack/functions-commom:232: /opt/stack/logs/error.log:No such file or directory

#解决方案:

`$FORCE=yes ./stack.sh`

# 错误信息如下

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 错误

#解决方案

`sudo apt-get build-dep python-lxml python3-dev`

#其他方法

`sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev`

#总之就是缺依赖,具体哪个也分辨不太清(脚本运行时间太长不方便逐个试),GCC通常不会缺

# 错误信息如下

# pip从9手动升级至18.1之后,执行安装脚本`./stack.sh`后会被降级

# 每次失败出现`requirements`相关信息,均是因为pip版本过低,重新升级pip之后,再次执行安装脚本

`sudo pip install --upgrade pip` 升级pip

`pip --version` 查看pip版本

`sudo vim /opt/stack/devstack/tools/install_pip.sh`将第140行附近的install_get_pip注释掉

# 注意

# ./stack.sh脚本执行过程中会从`git.openstack.org`处clone包,有时等待时间会较长,可能是由于网速问题。

可以采用github镜像或者trystack镜像,在local.conf配置文件中加入

`GIT_BASE=http://git.trystack.cn`

或`GIT_BASE=https://github.com`

# 错误信息如下

error: 'Can't connect to MySQL server on '127.0.0.1' (111)'

# 解决方案

`sudo vim /etc/mysql/my.cnf`

# 将bind_address注释

# VMware安装Centos过程中,先创建空白磁盘,选择稍后安装操作系统,否则会自动安装VMtools,卡死。

根据网速不同,pip和git的速度可能有较大的差异,pip若从官网下载太慢,

可在stack用户目录下创建`.pip`目录,然后配置pip.conf文件

# 错误提示

Didn't find service registered by hostname after 120 seconds

# 解决方案,缺少placement-api服务,在配置文件中添加即可

猜你喜欢

转载自blog.csdn.net/hehj369986957/article/details/103234908