kolla部署openstack

参考文档:

Kolla-ansible自动化部署openstack - 小李222 - 博客园 (cnblogs.com)

https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html#官方安装手册


Kolla-ansible自动化部署openstack

一、准备工作(模拟all-in-one部署)

1、配置好网卡IP(至少2张网卡)

eth0:   192.168.100.194

eth1:   10.0.0.202

2、修改主机名

hostnamectl set-hostname  kolla

3、关闭防火墙、NM服务、selinux

systemctl stop firewalld && systemctl disable firewalld

systemctl stop NetworkManager && systemctl disable NetworkManager

setenforce 0

vi /etc/sysconfig/selinux

4、把节点IP写入hosts

vi /etc/hosts

 192.168.100.194  kolla

5、做主机信任

ssh-keygen -t rsa(一直按回车)

ssh-copy-id kolla

6、修改DNS

vi /etc/resolv.conf

nameserver 114.114.114.114

二、环境准备

(1)部署节点

1、安装使用工具

yum -y install vim wget net-tools

2、更新base源和下载epel源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3、安装python环境相关依赖包

yum -y install python-devel libffi-devel gcc openssl-devel libselinux-python

4、安装python-pip

yum -y install python-pip

5、配置国内的pip源

mkdir ~/.pip

cat << EOF > ~/.pip/pip.conf

[global]

index-url = https://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

EOF

6、升级pip

pip install --upgrade pip==20.3.4

7、安装ansible

pip install ansible==2.9.0

8、修改ansible配置文件

mkdir /etc/ansible/

cat << EOF > /etc/ansible/ansible.cfg

[defaults]

host_key_checking=False

pipelining=True

forks=100

EOF

所有节点都做

1、安装python环境相关依赖包

yum -y install python-devel libffi-devel gcc openssl-devel libselinux-python

2、安装python-pip

yum -y install python-pip

3、配置国内的pip源

mkdir ~/.pip

cat << EOF > ~/.pip/pip.conf

[global]

index-url = https://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

EOF

4、升级pip

pip install --upgrade pip==20.3.4

5、安装必要的部署工具

yum install -y yum-utils device-mapper-persistent-data lvm2

yum -y install nfs-utils

6、添加软件源信息

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo

7、更新并安装Docker-CE

yum makecache fast

yum -y install docker-ce-20.10.5

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

8、配置docker共享挂载

所谓共享挂载即同一个目录或设备可以挂载到多个不同的路径并且能够保持互相之间的共享可见性,类似于 mount --shared。在 OpenStack for Kolla 中,主要解决 Neutron 的 namespace 在不同 container 中得以保持实效性的问题。

mkdir -p /etc/systemd/system/docker.service.d

cat << EOF > /etc/systemd/system/docker.service.d/kolla.conf

[Service]

MountFlags=shared

EOF

systemctl daemon-reload && systemctl restart docker && systemctl status docker

9、配置docker镜像加速器

mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<  EOF

{

    "registry-mirrors" : [

    "https://registry.docker-cn.com",

    "https://docker.mirrors.ustc.edu.cn",

    "http://hub-mirror.c.163.com",

    "https://cr.console.aliyun.com/"

  ]

}

EOF

systemctl daemon-reload && systemctl restart docker

三、部署openstack

部署节点

1、安装kolla-ansible

pip install kolla-ansible==9.3.0 --ignore-installed PyYAML

注:官方推荐部署环境使用 pip install kolla-ansible 方式来安装 kolla-ansible

                    ##以上安装出错解决方法(依次试验)

                                             1. pip install -U prb

                    如果出错尝试   2.  pip2 install --upgrade setuptools

                    如果还出错,就安装以下软件

                                         3.   pip2 install --upgrade pip

                                                pip2 install django-import-export

2、复制kolla-ansible相关配置文件

cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/

cp /usr/share/kolla-ansible/ansible/inventory/multinode /etc/kolla/

ls /etc/kolla/

实现效果:

ls /etc/kolla

globals.yml multinode passwords.yml

3、自动生成各服务的密码文件

kolla-genpwd

修改keystone和数据库的密码(163行)

vi /etc/kolla/passwords.yml

163 keystone_admin_password: HsPbEQHxTqmewKYNoRPpIOyQNdEYpHy36OX67TG3

164 keystone_database_password:7h1UDflKQmD1c6hQ9q7oyDdKfZTFlNAQYuXz148C

改为:

keystone_admin_password: 000000

keystone_database_password: 000000

注:这是登录 Dashboard,admin 使用的密码,你可以根据自己需要进行修改。密码前注意空格

4、全局配置文件globals.yml最后面添加下面内容

vi /etc/kolla/globals.yml

kolla_base_distro: "centos"

kolla_install_type: "binary"

openstack_release: "train"

node_custom_config: "/etc/kolla/config"

kolla_internal_vip_address: "192.168.100.55"   #--->不存在主机的IP地址

docker_namespace: "kolla"

network_interface: "eth0"    #--->管理网络出口网卡

api_interface: "{{ network_interface }}"

neutron_external_interface: "eth1"    #--->外部网络网卡

neutron_plugin_agent: "openvswitch"

enable_haproxy: "yes"

enable_ceph: "no"

enable_chrony: "no"

enable_cinder: "yes"

enable_grafana: "yes"

enable_heat: "no"

enable_mariabackup: "yes"

enable_neutron_dvr: "yes"

enable_neutron_fwaas: "yes"

enable_neutron_qos: "yes"

enable_neutron_provider_networks: "yes"

glance_backend_ceph: "no"

glance_enable_rolling_upgrade: "no"

cinder_backend_ceph: "no"

cinder_backup_driver: "nfs"

nova_backend_ceph: "no"

prometheus_cmdline_extras: "-storage.local.retention 720h"

nova_console: "novnc"

nova_compute_virt_type: "kvm"

enable_cinder_backup: "yes"

enable_cinder_backend_nfs: "yes"

enable_ceilometer: "yes"

enable_gnocchi: "yes"

enable_grafana: "yes"

enable_ceilometer_ipmi: "yes"

enable_horizon_zun: "{{ enable_zun | bool }}"

enable_zun: "yes"

enable_opendaylight: "yes"

enable_opendaylight_qos: "yes"

enable_opendaylight_l3: "yes"

enable_horizon_fwaas: "{{ enable_neutron_fwaas | bool }}"

enable_kuryr: "yes"

kolla_dev_mode: "yes"

heat_dev_mode: "yes"

5、修改multinode文件

修改为所有节点的主机名或IP地址,根据hosts来

我的主机名为:kolla

# These initial groups are the only groups required to be modified. The

# additional groups are for more control of the environment.

[control]

# These hostname must be resolvable from your deployment host

kolla

# The above can also be specified as follows:

#control[01:03] ansible_user=kolla

# The network nodes are where your l3-agent and loadbalancers will run

# This can be the same as a host in the control group

[network]

kolla

[compute]

kolla

[monitoring]

kolla

# When compute nodes and control nodes use different interfaces,

# you need to comment out "api_interface" and other interfaces from the globals.yml

# and specify like below:

#compute01 neutron_external_interface=eth0 api_interface=em1 storage_interface=em1 tunnel_interface=em1

[storage]

kolla

[deployment]

localhost ansible_connection=local

[baremetal:children]

control

network

compute

storage

monitoring

........

注:如果主机数较多可以使用正则表达式;例如:

[openstack-controller]

controller[01:03]

6、检查

(1)检查multinode配置是否正确,实现ping通各个主机

ansible -i /etc/kolla/multinode all -m ping

无报错显示

(2)部署检查

kolla-ansible -i /etc/kolla/multinode bootstrap-servers

无报错显示结果

kolla-ansible -i /etc/kolla/multinode prechecks

无报错显示结果

7、做nfs与cinder-volumes的卷组对接

1、创建好磁盘挂载目录:mkdir -p /data/openstack/cinder

2、把磁盘挂载到目录上:mount /dev/sdb /data

3、创建对接cinder磁盘的文件:mkdir -p /etc/kolla/config

vi  /etc/kolla/config/nfs_shares

192.168.100.194:/data/openstack_data/cinder

vi /etc/exports

/data/openstack *(rw,no_root_squash)

8、安装openstack客户端

先安装版本不匹配的组件

pip install -I ipaddress

安装openstack客户端

pip install python-openstackclient

9、执行部署

kolla-ansible -i /etc/kolla/multinode deploy

出现报错error

TASK [Cloning neutron source repository for development] ***************************

fatal: [kolla]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin https://opendev.org/openstack/neutron /opt/stack/neutron", "msg": "fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error", "rc": 128, "stderr": "fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error\n", "stderr_lines": ["fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error"], "stdout": "Cloning into '/opt/stack/neutron'...\n", "stdout_lines": ["Cloning into '/opt/stack/neutron'..."]}

太晚了,未能解决

目前进度》》》》


10、生成openrc文件,该文件中设置了管理员用户的凭据

kolla-ansible post-deploy

cat /etc/kolla/admin-openrc.sh

11、访问openstack horizon需要使用vip地址,节点上可以看到由keepalived容器生成的vip

浏览器直接访问该地址即可登录到dashboard界面

http:vip地址

登录账号:admin

密码:000000(根据passwords.yml中的keystone_admin_password: 000000)

kolla部署openstack完成



部分报错

1问题:

[root@kolla ~]# pip install -U ansible

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

Collecting ansible

  Downloading ansible-4.10.0.tar.gz (36.8 MB)

    |████████████████████████████████| 36.8 MB 71 kB/s

    ERROR: Command errored out with exit status 1:

    command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-D1VBWD/ansible/setup.py'"'"'; __file__='"'"'/tmp/pip-install-D1VBWD/ansible/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ZKMLrq

        cwd: /tmp/pip-install-D1VBWD/ansible/

    Complete output (5 lines):

    /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'

      warnings.warn(msg)

    /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'

      warnings.warn(msg)

    error in ansible setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

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

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

1解决:

yum install -y ansible

2问题: 

[root@kolla ~]# pip install -U pip

Collecting pip

  Using cached https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz

    Complete output from command python setup.py egg_info:

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "/tmp/pip-build-a7_xbA/pip/setup.py", line 7

        def read(rel_path: str) -> str:

                        ^

    SyntaxError: invalid syntax

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

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-a7_xbA/pip/

You are using pip version 8.1.2, however version 23.2.1 is available.

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

2解决:

python -m pip install --upgrade pip==20.3.4

3.问题:

[root@kolla ~]# pip install kolla-ansible -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed netaddr

cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/kolla/

cp /usr/share/kolla-ansible/ansible/inventory/* .DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)': /simple/kolla-ansible/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)': /simple/kolla-ansible/

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)': /simple/kolla-ansible/

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)': /simple/kolla-ansible/

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)': /simple/kolla-ansible/

Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/kolla-ansible/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/kolla-ansible/ (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),)) - skipping

ERROR: Could not find a version that satisfies the requirement kolla-ansible (from versions: none)

ERROR: No matching distribution found for kolla-ansible

3解决:

以上提示没有证书的问题,采用其他方法解决

pip install --upgrade pip

pip install kolla-ansible -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn --ignore-installed netaddr --cert /path/to/your/certificate.pem

4 问题:

fatal: [kolla]: FAILED! => {"changed": true, "msg": "'Traceback (most recent call last):\\n File \"/tmp/ansible_kolla_docker_payload_TYLEie/ansible_kolla_docker_payload.zip/ansible/modules/kolla_docker.py\", line 1027, in main\\n File \"/tmp/ansible_kolla_docker_payload_TYLEie/ansible_kolla_docker_payload.zip/ansible/modules/kolla_docker.py\", line 906, in ensure_image\\n File \"/tmp/ansible_kolla_docker_payload_TYLEie/ansible_kolla_docker_payload.zip/ansible/modules/kolla_docker.py\", line 571, in pull_image\\n File \"/usr/lib/python2.7/site-packages/docker/api/image.py\", line 430, in pull\\n self._raise_for_status(response)\\n File \"/usr/lib/python2.7/site-packages/docker/api/client.py\", line 270, in _raise_for_status\\n raise create_api_error_from_http_exception(e)\\n File \"/usr/lib/python2.7/site-packages/docker/errors.py\", line 31, in create_api_error_from_http_exception\\n raise cls(e, response=response, explanation=explanation)\\nImageNotFound: 404 Client Error for http+docker://localhost/v1.41/images/create?tag=train&fromImage=kolla%2Fcentos-sourse-fluentd: Not Found (\"pull access denied for kolla/centos-sourse-fluentd, repository does not exist or may require \\'docker login\\': denied: requested access to the resource is denied\")\\n'"}

4 解决: 

在kolla-ansible部署openstack中途出现该问题,原因是无法在dokcer hub中未能找到某镜像(centos-sourse-fluentd),本人通过以下方法解决

将/etc/kolla/globals.yml内容切换再重新执行kolla-ansible -i /etc/kolla/multinode deploy  应该能解决

vi /etc/kolla/globals.yml

kolla_base_distro: "centos"

kolla_install_type: "binary"

openstack_release: "train"

node_custom_config: "/etc/kolla/config"

kolla_internal_vip_address: "192.168.100.55"   #--->不存在主机的IP地址

docker_namespace: "kolla"

network_interface: "eth0"    #--->管理网络出口网卡

api_interface: "{{ network_interface }}"

neutron_external_interface: "eth1"    #--->外部网络网卡

neutron_plugin_agent: "openvswitch"

enable_haproxy: "yes"

enable_ceph: "no"

enable_chrony: "no"

enable_cinder: "yes"

enable_grafana: "yes"

enable_heat: "no"

enable_mariabackup: "yes"

enable_neutron_dvr: "yes"

enable_neutron_fwaas: "yes"

enable_neutron_qos: "yes"

enable_neutron_provider_networks: "yes"

glance_backend_ceph: "no"

glance_enable_rolling_upgrade: "no"

cinder_backend_ceph: "no"

cinder_backup_driver: "nfs"

nova_backend_ceph: "no"

prometheus_cmdline_extras: "-storage.local.retention 720h"

nova_console: "novnc"

nova_compute_virt_type: "kvm"

enable_cinder_backup: "yes"

enable_cinder_backend_nfs: "yes"

enable_ceilometer: "yes"

enable_gnocchi: "yes"

enable_grafana: "yes"

enable_ceilometer_ipmi: "yes"

enable_horizon_zun: "{{ enable_zun | bool }}"

enable_zun: "yes"

enable_opendaylight: "yes"

enable_opendaylight_qos: "yes"

enable_opendaylight_l3: "yes"

enable_horizon_fwaas: "{{ enable_neutron_fwaas | bool }}"

enable_kuryr: "yes"

kolla_dev_mode: "yes"

heat_dev_mode: "yes"

5 问题:

TASK [Cloning neutron source repository for development] ***************************

fatal: [kolla]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin https://opendev.org/openstack/neutron /opt/stack/neutron", "msg": "fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error", "rc": 128, "stderr": "fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error\n", "stderr_lines": ["fatal: unable to access 'https://opendev.org/openstack/neutron/': Could not resolve host: opendev.org; Unknown error"], "stdout": "Cloning into '/opt/stack/neutron'...\n", "stdout_lines": ["Cloning into '/opt/stack/neutron'..."]}

5解决: 

错误提示是因为无法解析主机名opendev.org,可能是网络连接问题或者DNS解析问题导致的

未能解决

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,294评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,493评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,790评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,595评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,718评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,906评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,053评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,797评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,250评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,570评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,711评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,388评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,018评论 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,796评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,023评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,461评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,595评论 2 350

推荐阅读更多精彩内容