必要
会社の既存環境は分散版のopenstackで、デバッグが少々面倒なので、devstackという1台のマシンにopenstackをインストールし、zunコンポーネントとzun-uiコンポーネントをインストールしてデバッグと開発をしたいと考えています。
環境バージョン
openstack:stable/stein (同社の既存のバージョンはこのバージョンです)
ずん:安定/スタイン
オペレーティング システム: vmware によってインストールされた ubuntu18.04 (stein バージョンに 16.04 を使用しないでください。python3.5 を使用すると、stein バージョンのバグによりエラーが発生します)、centos7 は使用しないでください。
python: ubuntu18 には python3.6 が付属しており、python2.7 を単独でインストールします (apt install Python)
適切なソースと必要なソフトウェアのインストール (root ユーザーの操作)
適切なソースを国内ソースに変更する
cd /etc/apt
mv sources.list sources.list.bak
vi /etc/apt/sources.list
以下に示すように 163 ソースを追加します
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
必要なツールをインストールする
apt-get install git python-pip
pip install --upgrade pip
apt install vim
ピップを国産ソースに置き換える
注: 国内ソースに切り替えると速度は大幅に向上しますが、次のようなエラーが発生する可能性があります。
Could not install packages due to an EnvironmentError: ("Connection broken: error(104, 'Connection reset by peer')", error(104, 'Connection reset by peer'))
このエラーは長い間私を悩ませており、この記事 https://www.oukohou.wang/2019/04/21/reocrds_of_installation_errors_and_operations で説明を見ました。簡単に言うと、ダウンロードが速すぎるため、サーバーが接続を閉じます。 、その後、国内ソースが削除されます。これ以上エラーは発生しません
cd ~
mkdir .pip
vim .pip/pip.conf
以下を追加します。
# pip 清华源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
開発スタックのインストール
開発スタックをダウンロード
# root用户
cd /opt
# 注意从国内镜像下载,从github下载太慢,且不要下载zip和tar包来使用
git clone http://git.trystack.cn/openstack/devstack.git -b stable/stein # 指定stein版本
zip または tar パッケージをダウンロードすると、次のようなエラーが報告されます。
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name zun was given, but was not able to be found.
error in setup command: Error parsing /opt/stack/zun/setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name zun was given, but was not able to be found.
この問題は長い間悩まされてきましたが、http://omeranson.github.io/blog/2017/02/22/Installing-with-pip-without-a-version で作者がダウンロードしないように述べていることが最終的に見つかりました。 git clone は遅すぎるため、zip ファイルを直接ダウンロードし、ダウンロードした tar パッケージを解凍して実行され、その結果、常にこのエラーが報告されます。
スタックユーザーを作成する
cd /devstack/tools
./create-stack-user.sh
作成したスタックユーザーのホームディレクトリは/opt/stack
次のとおりです。
devstack ディレクトリを移動して/opt/stack
権限を設定します。
mv /opt/devstack /opt/stack
chown -R stack:stack /opt/stack/devstack
インストールが完了するまでスタック ユーザーに切り替えます
su stack
設定ファイルを作成する
# stack用户
cd ~/devstack
vim local.conf
次のコンテンツを追加します
# 本文内容基于 https://docs.openstack.org/zun/latest/contributor/quickstart.html 中生成的local.conf修改而来
[[local|localrc]]
# 本机ip
HOST_IP=192.168.221.129
DATABASE_PASSWORD=admin
RABBIT_PASSWORD=admin
SERVICE_TOKEN=admin
SERVICE_PASSWORD=admin
ADMIN_PASSWORD=admin
# 下载插件版本
TARGET_BRANCH=stable/stein
# 该包指定版本,原因见后边
TEMPEST_BRANCH=20.0.0
# 定义在 DevStack 构建过程中自动下载的镜像,地址失效了,因此注释掉,会自动从默认位置下载
# DOWNLOAD_DEFAULT_IMAGES=False
# IMAGE_URLS="http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img"
# 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/sice-html5.git
# 需要加载的插件,默认会安装nova、cinder、horizon、neutron、keystone等组件,如果需要安装其他组件,则以插件形式安装。注意地址全是国内源
enable_plugin zun http://git.trystack.cn/openstack/zun $TARGET_BRANCH
# zun-tempest-plugin该组件无分支
enable_plugin zun-tempest-plugin http://git.trystack.cn/openstack/zun-tempest-plugin
#This below plugin enables installation of container engine on Devstack.
#The default container engine is Docker
enable_plugin devstack-plugin-container http://git.trystack.cn/openstack/devstack-plugin-container $TARGET_BRANCH
# In Kuryr, KURYR_CAPABILITY_SCOPE is `local` by default,
# but we must change it to `global` in the multinode scenario.
KURYR_CAPABILITY_SCOPE=global
KURYR_PROCESS_EXTERNAL_CONNECTIVITY=False
# 该组件要指定tag,stein分支已经不存在,3.0.0版本对应的是stein。不指定会报错
enable_plugin kuryr-libnetwork http://git.trystack.cn/openstack/kuryr-libnetwork 3.0.0
# install python-zunclient from git 此组件会下载最新版本,最新版要求python>=3.6,暂时无用,因此注释掉
# LIBS_FROM_GIT="python-zunclient"
# Optional: uncomment to enable the Zun UI plugin in Horizon
enable_plugin zun-ui http://git.trystack.cn/openstack/zun-ui $TARGET_BRANCH
# Optional: uncomment to enable the Heat plugin for container orchestration
# enable_plugin heat http://git.trystack.cn/openstack/heat $TARGET_BRANCH
TEMPEST_BRANCH のバージョンを指定する理由は、デフォルトで最新バージョンがダウンロードされ、次のようなエラーが表示されるためです。
Obtaining file:///opt/stack/tempest
tempest requires Python '>=3.6' but the running Python is 3.5.2
したがって、問題を解決するためにバージョンを指定した後、
ファイル ディレクトリを入力して、最初に必要なファイルをダウンロードします
cd ~/devstack/files
wget -c https://github.com/coreos/etcd/releases/download/v3.1.10/etcd-v3.1.10-linux-amd64.tar.gz
wget -c https://github.com/coreos/etcd/releases/download/v3.1.7/etcd-v3.1.7-linux-amd64.tar.gz
wget -c https://github.com/coreos/etcd/releases/download/v3.3.12/etcd-v3.3.12-linux-amd64.tar.gz
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py # python2
mv get-pip.py get-pip.py-py27
wget https://bootstrap.pypa.io/get-pip.py # python3
上記のコンテンツのダウンロードが遅すぎる場合は、ダウンロード可能なマシンでダウンロードが完了した後、ファイル ディレクトリにコピーできます。
インストール
cd ~/devstack
./stack.sh
長い間待った後、以下に示すように成功が表示されます。
This is your host IP address: 192.168.221.129
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.221.129/dashboard
Keystone is serving at http://192.168.221.129/identity/
The default users are: admin and demo
The password: admin
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: stein
Change: c67e7d3bbd15522fc298ed14803c8eda37c Mark our source trees as safe for git to use as other users 2022-04-20 12:15:55 +0200
OS Version: Ubuntu 18.04 bionic
ブラウザを開いて上記のアドレスにアクセスし、ユーザー名とパスワードを入力してログインに成功します。
以下のページを見たとき、何日もかかっていたモヤモヤが払拭されました 一見簡単そうに見えるプロセスが、実はインストール時に様々な問題を引き起こしていました OpenStackを試してみたい人は、古いバージョンを使用するのではなく、最新バージョンを直接インストールすることをお勧めします
他の問題が発生した場合は、ぜひご相談ください
コマンドラインを使用して openstack コマンドを実行する場合は、source /opt/stack/devstack/openrc admin admin
アクティベーション環境変数も実行します。
アンインストール
cd ~/devstack
./unstack.sh
./clean.sh
pip freeze | grep -v '^\-e' | xargs sudo pip uninstall -y
最後に/opt/stack
ディレクトリdevstack
以外をすべて削除します
後で再インストールできる
参考リンク
http://omeranson.github.io/blog/2017/02/22/Installing-with-pip-without-a-version
http://git.trystack.cn/cgit
https://docs.openstack.org/ devstack/stein/
https://www.infoq.cn/article/v35tdykox*vow5y9vsge
https://blog.csdn.net/qq_41773806/article/details/116561060
https://www.jianshu.com/p/654e05034427
https ://docs.openstack.org/zun/latest/contributor/quickstart.html
https://www.oukohou.wang/2019/04/21/reocrds_of_installation_errors_and_operations