kolla
Kolla安装Openstack
常见问题
1.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.
此类问题强制升级此安装包即可。(已发现PyYAML,ipaddress)
pip install --ignore-installed ipaddress
2.ImportError: cannot import name decorate
pip install -U decorator
环境准备
启动虚拟机
配置如下:
内存: 8G(建议再高点)
处理器:2核(开启嵌套虚拟化后,虚拟机才能正常创建,这里不开暂时不影响部署)
硬盘:100G(系统盘) + 20GB(创建cinder lvm时使用)
网络:2个nat网络,一个有IP,一个没IP
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:50:56:b8:28:4a brd ff:ff:ff:ff:ff:ff
inet 172.16.3.110/21 brd 172.16.7.255 scope global noprefixroute ens32
valid_lft forever preferred_lft forever
inet6 fe80::5392:1c67:1013:ad96/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:50:56:b8:d3:01 brd ff:ff:ff:ff:ff:ff
配置加速源
yum 加速源(centos7 阿里源)
yum install -y wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
docker 加速源(阿里源)
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
mkdir /etc/docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://iw3lcsa3.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload && systemctl enable docker && systemctl restart docker
生成并copy密钥
ssh-keygen
ssh-copy-id controller
关闭防火墙
setenforce 0
vim /etc/selinux/config
SELINUX=disabled
systemctl stop firewalld && systemctl disable firewalld
systemctl stop libvirtd.service && systemctl disable libvirtd.service
修改hostname
hostnamectl set-hostname kolla
kolla-ansible 部署
安装软件环境
yum install -y epel-release
yum install -y python-pip
pip install -U pip
yum install -y python-devel libffi-devel gcc openssl-devel libselinux-python
yum install -y ansible
pip install kolla-ansible
yum install -y epel-release && yum install -y python-pip && pip install -U pip && yum install -y python-devel libffi-devel gcc openssl-devel libselinux-python && yum install -y ansible && pip install kolla-ansible
错误解决
Cannot uninstall 'PyYAML'. 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.
rm -rf /usr/lib64/python2.7/site-packages/PyYAML*
将globals.yml和passwords.yml复制到/etc/kolla目录
cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/kolla/
将all-in-one和multinode库存文件复制到当前目录。
此地方巨坑,要单独一个地方存,后续的命令要用这个地方的all-in-one
cp /usr/share/kolla-ansible/ansible/inventory/* /root/
若没有git命令,手动安装yum install -y git
获取Kolla和Kolla-Ansible存储库
cd /usr/local/src
git clone https://github.com/openstack/kolla
git clone https://github.com/openstack/kolla-ansible
Kolla-ansible在etc/kolla中保存配置文件(globals.yml和passwords.yml)将配置文件复制到/etc/kolla目录
cp -r kolla-ansible/etc/kolla /etc/kolla/
Kolla-ansible将库存文件(all-in-one和multinode)保存在ansible / inventory中。
现将清单文件复制到当前目录
cp kolla-ansible/ansible/inventory/* /usr/local/src
准备在主机上部署单节点OpenStack(如果是多节点需要配置multinode文件)
部署中使用的密码存储在/etc/kolla/passwords.yml文件中。
#通过运行下面命令生成随机密码:
kolla-genpwd
初始化之后,可手动更改keystone_admin_password密码(OpenStack登录密码)
vim /etc/kolla/passwords.yml
keystone_admin_password:admin
编辑/etc/kolla/globals.yml配置文件
kolla_base_distro: "centos"
# binary使用像apt或yum这样的软件仓库,source使用原始源代码归档,git存储库或本地源代码目录
kolla_install_type: "source"
openstack_release: "queens" # 使用的版本
network_interface: "ens32" # OpenStack使用的网络接口
ens32属于NAT网络里,设置的IP是:172.16.3.110,Horizon访问就是通过这个IP地址
# 第二个接口专用于Neutron外部(或公共)网络,可以是vlan或flat,取决于网络的创建方式。
# 这个接口应该是活动的,没有IP地址。否则,实例将无法访问外部网络
neutron_external_interface: "ens33"
#ens33桥接模式,ip其实是dhcp分配,这个其实是让neutron的br-ex 绑定使用,虚拟机是通过这块网卡访问外网
kolla_internal_vip_address: "172.16.3.111" # 与eth32IP同网段且未被使用的IP
开始部署
''' 1、带有kolla的引导服务器部署依赖关系'''
kolla-ansible -i ./all-in-one bootstrap-servers
''' 2、对主机执行预部署检查'''
kolla-ansible -i ./all-in-one prechecks
''' 3、执行OpenStack部署'''
kolla-ansible -i ./all-in-one deploy
安装好OpenStack后执行命令行报错
ImportError: cannot import name decorate
pip install decorate
使用OpenStack
OpenStack需要一个openrc文件,其中设置了admin用户的凭证。
要生成这个文件运行以下命令:
kolla-ansible post-deploy
. /etc/kolla/admin-openrc.sh
安装基本的OpenStack CLI客户端:
--ignore-installed
pip install python-openstackclient python-glanceclient python-neutronclient decorate
运行脚本创建示例网络,图像等
. /usr/share/kolla-ansible/init-runonce
由于错误的出现,可能需要多次的部署,而有些错误重新部署是不会进行修正的,所以需要将整个环境进行清理:
/usr/share/kolla-ansible/tools/cleanup-containers #可用于从系统中移除部署的容器
/usr/share/kolla-ansible/tools/cleanup-host #可用于移除由于残余网络变化引发的docker启动的neutron-agents主机
/usr/share/kolla-ansible/tools/cleanup-images #可用于从本地缓存中移除所有的docker image
ImportError: cannot import name decorate
直接找到该文件,注释掉该import行即可
解决方法:
/usr/lib/python2.7/site-packages/dogpile/cache/region.py 文件中的 from decorator import decorate 注释
问题:kolla "Waiting for virtual IP to appear"
/etc/kolla/globals.yml
keepalived_virtual_router_id: "250"
网络连接
iptables -A INPUT -i br-ex -j ACCEPT #注意内核转发问题(INPUT都需要允许才行)
iptables -t nat -A POSTROUTING -s 10.0.2.0/255.255.255.0 -j SNAT --to-source 10.8.250.57
ifconfig br-ex 10.0.2.1/24
实例大小根据挂载磁盘空间大小来
创建镜像
openstack image create --disk-format qcow2 --container-format bare --public \
--property os_type=linux --file /root/windows_XP_64_20G windows_XP
/usr/lib/python2.7/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.22)
解决方案,制裁urllib3 和chardet
sudo pip uninstall urllib3
sudo pip uninstall chardet
然后,再安装
sudo pip install requests
*qcow2镜像启动问题
openstack image create --disk-format qcow2 --container-format bare --public --property hw_disk_bus=ide --property hw_vif_model=rtl8139 --property os_type=linux --file /root/windows_XP_64_20G windows_XP_64_20G
--property hw_disk_bus=ide #硬盘问题
--property hw_vif_model=rtl8139 #网卡问题(参数可修改为e1000)
多节点安装
yum install docker-engine-1.12.6 docker-engine-selinux-1.12.6 -y
yum list installed|grep docker
yum remove docker-selinux.x86_64 -y
环境问题解决
docker volume rm mariadb
cd /var/lib/docker/volumes
删除 除 metadata.db所有文件