1. 程式人生 > >DevStack方式安裝queens版openstack

DevStack方式安裝queens版openstack

warn rac .cn 關閉防火墻 true 豆瓣 ali .html 安裝環境

最近在學習openstack,在安裝階段就遇到了很多問題,特把安裝過程記錄如下,經筆者驗證能正確安裝openstack。

說明:安裝後即為中文版。

2019/01/29:

安裝環境:

宿主: Ubuntu 16.04 xenial

Hypervisor: kvm

虛擬機: Ubuntu 16.04 xenial

DevStack Version: queens

安裝步驟:

1、在ubuntu16.04中把source.list改成阿裏雲

在更改之前備份:

$sudo cp //etc/apt/sources.list /etc/apt/sources.list.bak

備份後再修改sources.list文件中的內容:

$sudo gedit /etc/apt/sources.list

把下列內容復制到文件中:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

2、然後更新:

$sudo apt-get update

3、安裝git:

$apt-get install git

4、安裝Pip

如你的系統中裝的是 Python 2,則:

$sudo apt-get install python-pip

檢查 pip 是否安裝成功

$pip -V

如你的系統中裝的是 Python 3,則:

$sudo apt-get install python3-pip

5、創建文件 /mao/.pip/pip.conf(mao為用戶名)

如我用mao帳號登錄後,用戶主目錄為:/home/mao

在文件路徑/home/mao下創建文件夾.pip,然後在.pip中創建文件:pip.conf

即文件路徑為:/mao/.pip/pip.conf (文件夾要加“.”,表示是隱藏文件夾)

打開pip.conf文件編輯,內容如下:

[global]

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

trusted-host = pypi.douban.com

上述配置意為:把pip的源換成豆瓣源

6、創建stack用戶

因為DevStack需要運行在一個非root並且支持sudo的用戶上。以下是快速建立一個用戶並賦予sudo權限的命令:

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

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

之後需要切換到這個用戶:

$ sudo su - stack

這個命令的作用是,它與su的不同之處在於su只切換了用戶身份,而su -切換了整個用戶環境,當前工作目錄和環境變量都變了。這時,stack用戶的工作目錄/opt/stack也創建好啦。

7、之後便可以下載DevStack了:

$ git clone https://git.openstack.org/openstack-dev/devstack -b stable/queens

$ cd devstack

8、在devstack目錄下創建local.conf文件,其中內容為:

[[local|localrc]]

ADMIN_PASSWORD=secret #設為你真實設置的密碼

DATABASE_PASSWORD=$ADMIN_PASSWORD

RABBIT_PASSWORD=$ADMIN_PASSWORD

SERVICE_PASSWORD=$ADMIN_PASSWORD

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

RECLONE=True

DOWNLOAD_DEFAULT_IMAGES=False

IMAGE_URLS="http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"

9、可以運行部署腳本:

在/opt/stack/devstack目錄中執行下面腳本文件:

$ ./stack.sh

10、可能出現的問題

raise ReadTimeoutError(self._pool, None, ‘Read timed out.‘)

ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443): Read timed out.

You are using pip version 9.0.3, however version 19.0.1 is available.

You should consider upgrading via the ‘pip install --upgrade pip‘ command.

這個問題很可能是防火墻沒關閉。

下面為可能用到的命令:

開啟防火墻

$ufw enable #重啟後才會生效

關閉防火墻

$ufw disable #重啟後才會生效

查看防火墻狀態

sudo ufw status

跟新pip源

sudo -H python -m pip install --upgrade pip

改變/opt/stack/.cache目錄的所有者:chown -R stack:stack /opt/stack/.cache/pip/

在經過約3個小時的安裝後,最終的成功的顯示如下所示:

/^\[\[.+\|.*\]\]/ {

gsub("[][]", "", $1);

split($1, a, "|");

if (a[1] == matchgroup)

print a[2]

}

‘ /opt/stack/devstack/local.conf

+./stack.sh:main:1465 set +o xtrace

=========================

DevStack Component Timing

(times are in seconds)

=========================

run_process 77

test_with_retry 5

apt-get-update 17

pip_install 828

osc 257

wait_for_service 39

git_timed 219

dbsync 351

apt-get 29

-------------------------

Unaccounted time 1278

=========================

Total runtime 3100

This is your host IP address: 192.168.122.142

This is your host IPv6 address: ::1

Horizon is now available at http://192.168.122.142/dashboard

Keystone is serving at http://192.168.122.142/identity/

The default users are: admin and demo

The password: ******

WARNING:

Using lib/neutron-legacy is deprecated, and it will be removed in the future

Services are running under systemd unit files.

For more information see:

https://docs.openstack.org/devstack/latest/systemd.html

DevStack Version: queens

Change: bbb6b0c2409278a4c9266c39bd1f5d91f7066bb8 Fix version comparison for SUSE Linux Enterprise 12 2019-01-25 01:05:58 +0000

OS Version: Ubuntu 16.04 xenial

2019-01-29 03:07:38.627 | stack.sh completed in 3100 seconds.

stack@ms9698:~/devstack$

然後,你可在瀏覽器中輸入:http://192.168.122.142/dashboard 來訪問horizon

IP:192.168.122.142為安裝openstack主機的地址,初始帳號為:admin password為你在local.conf文件中設置的密碼。

good luck for you !

DevStack方式安裝queens版openstack