Centos7使用kolla部署train版本的openstack

kolla的安装,要求目标机器是两块网卡,所以虚拟机也是分配两块网卡:

        ens33, 桥接模式,设置的IP是:192.168.31.248,日后Horizon访问就是通过这个IP地址 

        ens37,桥接模式,ip其实是dhcp分配,这个其实是让neutron的br-ex 绑定使用,虚拟机是通过这块网卡访问外网。

 

        在机器上连接虚拟机,是通过ens33的IP进行访问,如果你通过ens37 ssh,安装过程,会导致ssh中断。

        默认设置,其实两块网卡都是可以访问到互联网。也可以是其中一块网卡访问外网,对于测试来说,基本问题不大。 

        如果在服务器直接安装,两块网卡的IP,就算是同一个网段,也是没啥问题的。

 

两块硬盘:

        sda正常装系统用。

        sdb给volume卷使用。

 

网卡配置

 网卡1   网卡12  
 网卡模式  桥接模式   桥接模式
 网卡名称  ens33  ens37
 IP地址  192.168.31.248  无
 子网掩码  255.255.255.0  无  
 网关  192.168.31.1  无

 

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
sed -i -e  's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0 

 

采用阿里云的源

rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

 

安装docker

curl -sSL https://get.docker.io | bash

 

采用阿里云的加速

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://s9c0jp37.mirror.aliyuncs.com"]
}
EOF

 

重启docker

systemctl daemon-reload
systemctl restart docker
systemctl enable docker

 

安装 pip 

yum install -y python-pip
pip install -U pip -i https://mirrors.aliyun.com/pypi/simple/

 

安装基础软件 

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

 

 安装 ansible

pip install -U ansible -i https://mirrors.aliyun.com/pypi/simple/

 

安装 kolla-ansible  

pip install -U kolla-ansible -i https://mirrors.aliyun.com/pypi/simple/

 

复制相关配置文件 

cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/
cp /usr/share/kolla-ansible/ansible/inventory/* /home/

 

生成密码文件 

kolla-genpwd

 

登录Dashboard,admin使用的密码,你可以根据自己需要进行修改。  

sed -i 's/^keystone_admin_password.*/keystone_admin_password: Star*1234/' /etc/kolla/passwords.yml

 

编辑配置文件 

sed -i 's/^kolla_internal_vip_address:.*/kolla_internal_vip_address: "192.168.31.248"/' /etc/kolla/globals.yml
sed -i 's/^#openstack_release:.*/openstack_release: "train"/' /etc/kolla/globals.yml
sed -i 's/^#network_interface:.*/network_interface: "ens33"/' /etc/kolla/globals.yml sed -i 's/^#neutron_external_interface:.*/neutron_external_interface: "ens37"/' /etc/kolla/globals.yml sed -i 's/^#enable_haproxy:.*/enable_haproxy: "no"/' /etc/kolla/globals.yml sed -i 's/^#enable_magnum:.*/enable_magnum: "yes"/' /etc/kolla/globals.yml sed -i 's/^#enable_heat:.*/enable_heat: "yes"/' /etc/kolla/globals.yml sed -i 's/^#enable_cinder:.*/enable_cinder: "yes"/' /etc/kolla/globals.yml sed -i 's/^#enable_cinder_backup:.*/enable_cinder_backup: "yes"/' /etc/kolla/globals.yml sed -i 's/^#enable_cinder_backend_lvm:.*/enable_cinder_backend_lvm: "yes"/' /etc/kolla/globals.yml echo "kolla_internal_address: 192.168.31.248" >> /etc/kolla/globals.yml

 

为cinder volume准备lvm

yum install qemu-img -y

#  
# 如果 使用磁盘作lvm后端可执行如下操作
#  
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb

 

创建配置文件夹

mkdir -p /etc/kolla/config/

 

(未验证)部署前如果修改虚拟化类型:

openstack集群是通过virtualbox部署的,而virtualbox已经使用了kvm技术,所以需要设置nova的虚拟化为qemu,而不是kvm  

cat > /etc/kolla/config/nova.conf <<EOF
[libvirt]
virt_type=qemu
cpu_mode = none
EOF

 

修改容器的卷类型

cat > /etc/kolla/config/magnum.conf <<EOF
[cinder]
default_docker_volume_type = iscsi
EOF

 

如果部署前检查报错:Hostname has to resolve to IP address of api_interface

可能需要添加一下hosts

cat >> /etc/hosts <<EOF
192.168.31.248  vm248
EOF

 

 部署前检查

kolla-ansible prechecks -i /home/all-in-one

 

先拉取镜像 

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

 

部署之前,一定要先检查是否还存在dead的容器。如果无法删除,需要重启服务器。

docker ps -a

 

部署,等待大约30分钟,部署完成。

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

 

登录 dashboard  

http://192.168.31.248

 

安装客户端 

pip install python-openstackclient python-glanceclient python-neutronclient -i https://mirrors.aliyun.com/pypi/simple/

 

如果报错ERROR: Cannot uninstall 'ipaddress'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

pip install --ignore-installed  --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ python-neutronclient

 

如果报错ERROR: Package 'cmd2' requires a different Python: 2.7.5 not in '>=3.5',需要下载https://pypi.org/project/python-neutronclient/源码,然后执行

不知道为什么:安装了cmd2==0.6.7的版本,但是执行上面命令时,仍然下载最新的cmd2,但是最新的cmd2已经不支持python2.7了。

pip install --ignore-installed  --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/  -r lower-constraints.txt

 

部署完成后,运行以下命令可以生成一个openrc文件(运行openstack CLI所需的环境变量): 

kolla-ansible post-deploy

 

更新 decorator,否则报下面的错:from decorator import decorate   ;  ImportError: cannot import name decorate

pip install  -U -i https://mirrors.aliyun.com/pypi/simple/  decorator

 

openrc文件生成之后,使用以下命令可以帮你做一下openstack的初始化工作,包括上传一个glance镜像以及创建几个虚拟网络: 

source /etc/kolla/admin-openrc.sh
bash /usr/share/kolla-ansible/init-runonce

 

如果上面下载cirros很慢,可以直接把cirros-0.4.0-x86_64-disk.img,放到下面缓存目录下

/opt/cache/files/cirros-0.4.0-x86_64-disk.img

 

导入镜像(http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img)

glance image-create \
    --file /root/cirros-0.4.0-x86_64-disk.img \
    --disk-format qcow2 \
    --container-format bare \
    --name cirros-0.4.0 \
    --progress

 

导入镜像(https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-Atomic-27-20180419.0/CloudImages/x86_64/images/Fedora-Atomic-27-20180419.0.x86_64.qcow2)

glance image-create \
    --file /root/CentOS-7-x86_64-GenericCloud-1907.qcow2 \
    --disk-format qcow2 \
    --container-format bare \
    --name CentOS-7-x86_64-GenericCloud-1907 \
--progress

 

依赖的镜像

 

docker save \
    kolla/centos-binary-nova-compute:train                 \
    kolla/centos-binary-heat-api:train                     \
    kolla/centos-binary-glance-api:train                  \
    kolla/centos-binary-heat-api-cfn:train                \
    kolla/centos-binary-heat-engine:train                 \
    kolla/centos-binary-glance-registry:train             \
    kolla/centos-binary-neutron-l3-agent:train            \
    kolla/centos-binary-neutron-server:train              \
    kolla/centos-binary-neutron-openvswitch-agent:train   \
    kolla/centos-binary-neutron-dhcp-agent:train          \
    kolla/centos-binary-neutron-metadata-agent:train      \
    kolla/centos-binary-keystone:train                    \
    kolla/centos-binary-nova-api:train                    \
    kolla/centos-binary-nova-conductor:train              \
    kolla/centos-binary-nova-ssh:train                    \
    kolla/centos-binary-nova-scheduler:train              \
    kolla/centos-binary-nova-novncproxy:train             \
    kolla/centos-binary-horizon:train                     \
    kolla/centos-binary-nova-libvirt:train                \
    kolla/centos-binary-fluentd:train                     \
    kolla/centos-binary-openvswitch-vswitchd:train        \
    kolla/centos-binary-openvswitch-db-server:train       \
    kolla/centos-binary-mariadb:train                     \
    kolla/centos-binary-kolla-toolbox:train               \
    kolla/centos-binary-keepalived:train                  \
    kolla/centos-binary-cron:train                        \
    kolla/centos-binary-haproxy:train                     \
    kolla/centos-binary-rabbitmq:train                    \
    kolla/centos-binary-iscsid:train                      \
    kolla/centos-binary-chrony:train                      \
    kolla/centos-binary-memcached:train                   \
    kolla/centos-binary-tgtd:train                        \
    |gzip > kolla-images.tgz
posted @ 2021-03-01 16:54  woaibaobei  阅读(902)  评论(0编辑  收藏  举报