Kolla openstack all in one 部署 train 版

1、环境准备

  • 机器规格(cpu:8核 内存:16G 磁盘:100G)
  • 操作系统版本:CentOS Linux release 7.9.2009 (Core)
  • Docker版本:Docker version 20.10.6, build 370c289
  • Kolla版本:kolla-9.3.1
  • Kolla-ansible版本:kolla-ansible-9.3.1
  • 虚拟机配置截图(两张网卡)

2、准备工作

(2.1)关闭防火墙firewalld,selinux,NetworkManager

systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld

systemctl stop NetworkManager && systemctl disable NetworkManager

setenforce 0 && sed -i ‘s/enforceing/disabled/g’ /etc/selinux/config

(2.2)python 3.6 升级及修改默认python软连接

#下载python3.6 升级包

#创建主目录(后续离线包都保存在train)

mkdir  /root/train/python36

yum -y install python36 python36-devel –downloadonly –downloaddir=/root/train/python36

#本地安装

yum localinstall /root/train/python36/*.rpm

# python 默认软连接改为python3

mv  /usr/bin/python /usr/bin/python.bak

ln -s /usr/bin/python3 /usr/bin/python

(2.3)pip 升级到最新版及修改默认pip 软连接

#修改pip默认链接

mv /usr/bin/pip /usr/bin/pip.bak

ln -s /bin/pip3.6 /bin/pip

[root@localhost~]# pip -V

pip 21.1.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

#升级

mkdir -p /root/train/pythonpip/pipupgrade

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/pythonpip/pipupgrade pip

pip install –no-index –find-links=/root/train/pythonpip/pipupgrade pip==21.1.1

(2.4) yum 指定到python2.7

vim /usr/bin/yum

修改第一行即可

#!/usr/bin/python2.7

vim /usr/libexec/urlgrabber-ext-down

修改第一行即可

#!/usr/bin/python2.7

#验证yum功能是否正常

yum -y install telnet

3、安装基础依赖

(3.1)下载基础依赖包

yum install –downloadonly –downloaddir=/root/train/basedependencies python-devel libffi-devel gcc openssl-devel libselinux-python git yum-utils

(3.2)下载python docker api及安装

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/python2pip/docker docker

pip install –no-index –find-links=/root/train/python2pip/docker docker==5.0.0

(3.3)下载python_openstackclient 及安装

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/pythonpip/python-openstackclient python-openstackclient

pip install –no-index –find-links=/root/train/pythonpip/python-openstackclient python_openstackclient==5.5.0

4、安装docker

(4.1)配置docker源

yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

(4.2)下载docker

yum install –downloadonly –downloaddir=/root/train/docker docker-ce

(4.3)安装docker

yum localinstall /root/train/docker/*.rp

(4.4)设置开机自启

systemctl restart docker && systemctl enable docker && systemctl status docker

(4.5)设置docker下载的源

编辑配置文件选择国内的源

/etc/docker/daemon.json 

[root@localhost~]# cat /etc/docker/daemon.json

{

“registry-mirrors”: [“https://nsodgxr5.mirror.aliyuncs.com”]

}

systemctl restart docker

5、安装ansible

(5.1)kolla-ansible 对ansible 版本有要求Currently, Kolla Ansible requires Ansible 2.6 to 2.9.在这里使用pip安装,下载ansible安装包

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/pipku/ansible ansible==2.9.10

(5.2)离线安装ansible

pip install –no-index –find-links=/root/train/pipku/ansible ansible==2.9.10

(5.3)验证版本

ansible –version

ansible 2.9.10

(5.4)修改配置文件(pip默认安装无配置文件,需于yum安装创建一个)

mkdir -p /etc/ansible/roles

touch /etc/ansible/hosts

cat /etc/ansible/ansible.cfg

[defaults]

inventory  = $HOME/ansible/hosts

host_key_checking=False

pipelining=True

forks=10

6、安装kolla

(6.1)上传下载的kolla包

#9.3.1 版本下载地址

https://pypi.org/project/kolla-ansible/9.3.1/#files

#上传后解压

(6.2)下载依赖包

mkdir /root/train/kolla/kollapip

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/kolla/kollapip -r /root/train/kolla-9.3.1/requirements.txt

(6.3)安装

cd /root/train/kolla-9.3.1/

git init

pip install /root/train/kolla-9.3.1 –no-index –find-links=/root/train/kolla/kollapip

(6.4)验证kolla版本

[root@localhost kollapip]# kolla-build –version

9.3.1

7、安装kolla-ansible

(7.1)下载kolla安装包上传

mkdir -p /root/train/kollaansible

#下载地址:https://pypi.org/project/kolla-ansible/9.3.1/#files

cd /root/train/kollaansible

(7.2)下载依赖包

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -d /root/train/kollaansible/kollaansiblepip -r /root/train/kollaansible/kolla-ansible-9.3.1/requirements.txt

(7.3)用离线包安装

cd /root/train/kollaansible/kolla-ansible-9.3.1

python -m pip install /root/train/kollaansible/kolla-ansible-9.3.1 –no-index –find-links=/root/train/kollaansible/kollaansiblepip

(7.4)新增配置文件(出现两个文件 globals.yml,passwords.yml)

mkdir -p /etc/kolla

cp -r /root/train/kollaansible/kolla-ansible-9.3.1/etc/kolla/* /etc/kolla/

(7.5)新增ansible配置文件

cp /root/train/kollaansible/kolla-ansible-9.3.1/ansible/inventory/* /root/ansible/

#all-in-one 单节点部署的ansible文件

#multinode 多节点部署文件

[root@localhost ansible]# ls

all-in-one  multinode  nohup.out

8、openstack all-in-one 安装

(8.1)新增 /etc/systemd/system/docker.service.d/kolla.conf

cd /etc/systemd/system/ && mkdir docker.service.d && cd docker.service.d/

vim kolla.conf

[Service]

MountFlags=shared

(8.2)在生成passwords.yml,修改登录密码

vim /etc/kolla/passwords.yml

(8.3)修改/etc/kolla/globals.yml

[root@localhost ansible]# grep -Ev “^$|^[#;]” /etc/kolla/globals.yml

kolla_base_distro: “centos”

kolla_install_type: “binary”

openstack_release: “train”

kolla_internal_vip_address: “192.168.254.131”

network_interface: “ens32”

neutron_external_interface: “ens34”  #另外一张网卡名称

kolla_enable_tls_external: “no”

enable_haproxy: “no”

(8.4)预检查

[root@localhost ~]# kolla-ansible -i ansible/all-in-one prechecks

(8.5)获取openstack train 镜像

#kolla-ansible 通过all-in-one 获取镜像

kolla-ansible -i /root/ansible/all-in-one pull

#或者可以通过脚本获取镜像执行下面脚本即可(非必须)

(8.6)部署openstack all in one

kolla-ansible -i /root/ansible/all-in-one deploy

(8.7)检验安装是否正常运行以下命令可以生成一个openrc文件(运行openstack CLI所需的环境变量)

kolla-ansible -i /root/ansible/all-in-one post-deploy

(8.8)登录 (找到该文件,有保存密码直接页面登录)

[root@localhost kolla]# cat /etc/kolla/admin-openrc.sh

# Clear any old environment that may conflict.

for key in $( set | awk ‘{FS=”=”}  /^OS_/ {print $1}’ ); do unset $key ; done

export OS_PROJECT_DOMAIN_NAME=Default

export OS_USER_DOMAIN_NAME=Default

export OS_PROJECT_NAME=admin

export OS_TENANT_NAME=admin

export OS_USERNAME=admin

export OS_PASSWORD=12345678

export OS_AUTH_URL=http://192.168.254.131:35357/v3

export OS_INTERFACE=internal

export OS_ENDPOINT_TYPE=internalURL

export OS_IDENTITY_API_VERSION=3

export OS_REGION_NAME=RegionOne

export OS_AUTH_PLUGIN=password

9、虚拟机创建测试(镜像必须是raw 格式)

(9.1)因为使用vmware 虚拟机搭建openstack 需要做以下配置才能正常生产虚拟机。

#修改nova 配置文件

/etc/kolla/nova-compute/nova.conf

virt_type = qemu

#虚拟机的处理器要开启虚拟化

(9.2)上传镜像

#将本地制作镜像上传,并拷贝至glance api 容器中

docker cp CentOS_8.0_20210428.qcow2 glance_api:/var/lib/glance/images/

#在内部加载keystone 用户登录信息

#上传镜像

glance image-create –name “CentOS_8.0” –file ./CentOS_8.0_20210428.qcow2 –disk-format raw –container-format bare –property os_type=linux –property resource_type=VM –property image_type=SYSTEM  –progress

(9.3)创建实例类型 管理员>计算>实例类型

(9.4)创建网络

(9.5)创建实例

发表评论

电子邮件地址不会被公开。 必填项已用*标注