openEuler 22.03 LTS SP3源码编译部署OpenStack-Caracal

本教程详细介绍了如何在openEuler 22.03 LTS SP3系统中,通过源码编译方式部署OpenStack-Caracal。涉及步骤包括安装操作系统、配置环境、安装数据库、消息队列、缓存服务,以及OpenStack的各个组件,如Keystone、Glance、Neutron、Nova和Cinder等。此外,还涵盖了安装Dashboard和配置OVN网络的过程,以及在过程中可能遇到的问题和解决办法。
摘要由CSDN通过智能技术生成

openEuler 22.03 LTS SP3源码编译部署OpenStack-Caracal

说明

本教程只用于学习,虽然能够成功运行,但是还有一些bug

机器详情

主机名 IP 磁盘 CPU 内存
controller ens160:192.168.46.31/24
ens192:不配置IP地址
100G 2C 8G
compute1 ens160:192.168.46.32/24
ens192:不配置IP地址
100G 2C 8G
block1 ens160:192.168.46.33/24 sda:50G
sdb:100G
2C 4G

安装操作系统注意事项

安装操作只需注意的一步是Software Selection要勾选Development Tools
在这里插入图片描述

这会自动地帮我们安装一些基础的编译环境,如果你没有勾选,也无大碍,在编译安装时可能会遇到
报错说缺失一些编译环境,根据报错安装与之对应地编译环境即可解决

基础准备

Controller节点 && Compute节点 && Block节点

关闭防火墙

systemctl stop firewalld && systemctl disable firewalld

关闭selinux

vim /etc/selinux/config
SELINUX=disabled

设置静态IP

nmtui

设置ens160网卡的IP地址为静态IP地址
设置ens192网卡不获取到IP地址(即设置为Disabled)
网卡配置生效命令

nmcli c reload
nmcli c up ens160
nmcli c up ens192

更新

dnf update -y && dnf -y upgrade

设置时区及时间同步

timedatectl set-timezone Asia/Shanghai
vim /etc/chrony.conf
# 把开头是pool的所有行注释掉
# 添加如下的阿里时间服务器
server ntp.aliyun.com iburst
systemctl restart chronyd && systemctl enable chronyd

重启一下机器

安装前准备

Controller节点 && Compute节点 && Block节点

设置主机名

hostnamectl set-hostname controller
hostnamectl set-hostname compute1
hostnamectl set-hostname block1

配置hosts

vim /etc/hosts
192.168.46.31   controller
192.168.46.32   compute1
192.168.46.33   block1

验证配置

# Controller节点
ping -c 4 www.baidu.com
ping -c 4 compute1
ping -c 4 block1
# Compute节点
ping -c 4 www.baidu.com
ping -c 4 controller
ping -c 4 block1
# Block节点
ping -c 4 www.baidu.com
ping -c 4 controller
ping -c 4 compute1

安装 SQL DataBase

Controller节点

安装软件包

dnf install mariadb mariadb-server python3-PyMySQL -y

编辑配置文件

vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = Controller-IP
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

Controller-IP为Controller节点的IP地址

启动服务

systemctl restart mariadb.service && systemctl enable mariadb.service

初始化配置

mysql_secure_installation

安装 RabbitMQ

Controller节点

安装软件包

dnf install rabbitmq-server -y

启动服务

systemctl restart rabbitmq-server.service && systemctl enable rabbitmq-server.service

添加openstack用户

rabbitmqctl add_user openstack RABBIT_PASS

RABBIT_PASS为设置的密码

设置openstack用户权限,允许进行配置、写、读

rabbitmqctl set_permissions openstack ".*" ".*" ".*"

安装 Memcached

Controller节点

安装软件包

dnf install memcached python3-memcached -y

编辑配置文件

vim /etc/sysconfig/memcached
OPTIONS="-l 127.0.0.1,::1,controller"

启动服务

systemctl restart memcached.service && systemctl enable memcached.service

验证

memcached-tool controller stats

安装Keystone

Controller节点

下载源码包

下载地址:https://releases.openstack.org/caracal/index.html#caracal-keystone
所需下载的源码包:keystone-25.0.0.tar.gz

创建数据库

mysql -u root -p
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
exit

KEYSTONE_DBPASS为要设置的密码

安装httpd、mod_wsgi软件包

dnf install httpd mod_wsgi -y

解压keystone-25.0.0.tar.gz

tar -xvf keystone-25.0.0.tar.gz
cd keystone-25.0.0/

安装tox

pip3 install tox -i https://pypi.tuna.tsinghua.edu.cn/simple

安装postgresql-devel

dnf -y install postgresql-devel

安装openldap-devel

dnf -y install openldap-devel

安装python3-devel

dnf -y install python3-devel

修改tox.ini

vim tox.ini

在这里插入图片描述

生成示例配置文件

tox -egenconfig
tox -egenpolicy

安装所需依赖包

pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

把SQLAlchemy的版本降为1.4.49

pip3 install SQLAlchemy==1.4.49 -i https://pypi.tuna.tsinghua.edu.cn/simple

编译安装

python3 setup.py install

创建/etc/keystone文件夹

mkdir /etc/keystone

复制etc/目录下的内容到/etc/keystone

cp -r etc/* /etc/keystone/

编辑keystone配置文件

cp /etc/keystone/keystone.conf.sample /etc/keystone/keystone.conf
cp /etc/keystone/keystone.policy.yaml.sample /etc/keystone/keystone.policy.yaml
vim /etc/keystone/keystone.conf
[database]
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone

KEYSTONE_DBPASS为创建keystone用户设置的数据库访问密码

同步数据库

useradd -d /var/lib/keystone -s /usr/sbin/nologin keystone
mkdir -p /var/lib/keystone && chown keystone:keystone /var/lib/keystone && chmod 750 /var/lib/keystone
su -s /bin/sh -c "keystone-manage db_sync" keystone

初始化Fernet密钥仓库

keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

启动服务

keystone-manage bootstrap --bootstrap-password ADMIN_PASS \
--bootstrap-admin-url http://controller:5000/v3/ \
--bootstrap-internal-url http://controller:5000/v3/ \
--bootstrap-public-url http://controller:5000/v3/ \
--bootstrap-region-id RegionOne

ADMIN_PASS为准备设置管理员用户的密码
如果遇到如下的错误

2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt Traceback (most recent call last):
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/identity/backends/sql.py", line 209, in get_user_by_name
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     user_ref = query.one()
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib64/python3.9/site-packages/sqlalchemy/orm/query.py", line 2870, in one
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return self._iter().one()
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib64/python3.9/site-packages/sqlalchemy/engine/result.py", line 1522, in one
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return self._only_one_row(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib64/python3.9/site-packages/sqlalchemy/engine/result.py", line 562, in _only_one_row
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     raise exc.NoResultFound(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt sqlalchemy.exc.NoResultFound: No row was found when one was required
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt 
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt During handling of the above exception, another exception occurred:
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt 
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt Traceback (most recent call last):
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/cmd/bootstrap.py", line 205, in _bootstrap_admin_user
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     user = PROVIDERS.identity_api.get_user_by_name(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/common/manager.py", line 115, in wrapped
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     __ret_val = __f(*args, **kwargs)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/identity/core.py", line 414, in wrapper
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return f(self, *args, **kwargs)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/identity/core.py", line 424, in wrapper
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return f(self, *args, **kwargs)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/lib/python3.9/site-packages/decorator.py", line 232, in fun
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return caller(func, *(extras + args), **kw)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/cache/region.py", line 1632, in get_or_create_for_user_func
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return self.get_or_create(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/cache/region.py", line 1092, in get_or_create
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     with Lock(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/lock.py", line 185, in __enter__
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return self._enter()
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/lock.py", line 94, in _enter
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     generated = self._enter_create(value, createdtime)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/lock.py", line 178, in _enter_create
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     return self.creator()
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/dogpile/cache/region.py", line 1046, in gen_value
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     created_value = creator(
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/identity/core.py", line 1035, in get_user_by_name
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     ref = driver.get_user_by_name(user_name, domain_id)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/keystone/identity/backends/sql.py", line 211, in get_user_by_name
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     raise exception.UserNotFound(user_id=user_name)
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt keystone.exception.UserNotFound: Could not find user: admin.
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt 
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt During handling of the above exception, another exception occurred:
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt 
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt Traceback (most recent call last):
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt   File "/usr/local/lib/python3.9/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt     version = _bcrypt.__about__.__version__
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt AttributeError: module 'bcrypt' has no attribute '__about__'
2024-04-13 14:21:16.788 274641 ERROR passlib.handlers.bcrypt 

降低bcrypt的版本

pip3 install bcrypt==4.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

再次启动服务

配置Apache HTTP server

vim /etc/httpd/conf/httpd.conf
ServerName controller
cp /root/keystone-25.0.0/httpd/wsgi-keystone.conf /etc/httpd/conf.d/
mkdir /var/log/apache2/

启动Apache HTTP服务

systemctl restart httpd.service && systemctl enable httpd.service

创建脚本文件

vim admin-openrc.sh
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_VOLUME_API_VERSION=3

ADMIN_PASS为启动Keystone服务设置的管理员用户的密码

chmod +x admin-openrc.sh

下载openstackclient源码包

下载地址:https://releases.openstack.org/caracal/index.html#caracal-python-openstackclient
所需下载的源码包:python-openstackclient-6.6.0.tar.gz

解压python-openstackclient-6.6.0.tar.gz

tar -xvf python-openstackclient-6.6.0.tar.gz
cd python-openstackclient-6.6.0/

安装依赖包

pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

编译安装

python3 setup.py install

创建domain

source admin-openrc.sh
openstack domain create --description "An Example Domain" example

创建project

openstack project create --domain default --description "Service Project" service
openstack project create --domain default --description "Demo Project" myproject

创建user

openstack user create --domain default --password-prompt myuser

创建role

openstack role create myrole

将role添加到project和user

openstack role add --project myproject --user myuser myrole

验证

source admin-openrc.sh
openstack --os-auth-url http://controller:5000/v3 \
--os-project-domain-name Default --os-user-domain-name Default \
--os-project-name admin --os-username admin token issue

安装Glance

Controller节点

下载源码包

下载地址:https://releases.openstack.org/caracal/index.html#caracal-glance
所需下载的源码包:glance-28.0.1.tar.gz

创建数据库

mysql -u root -p
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_D
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想看一次满天星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值