自动化kolla-ansible部署ubuntu20.04+openstack-victoria单机
一. 环境信息
1. 硬件信息
型号:Dell R730
CPU:Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz*2
内存:DDR4 192GB
系统: SSD480GB*2 raid 1 /dev/sda
数据: SSD480GB*6 raid 10 /dev/sdb
网卡: eno1 192.168.1.83 eno2 dhcp(需要路由器或者交换机开启dhcp 网卡能够自动获取IP地址)
2. 系统信息
#系统安装参考
#系统镜像下载地址:
网易: http://mirrors.163.com/ubuntu-releases/20.04.2.0/ubuntu-20.04.2-live-server-amd64.iso
中科大: https://mirrors.ustc.edu.cn/ubuntu-releases/20.04.2.0/ubuntu-20.04.2-live-server-amd64.iso
ubuntu-20.04.2-live-server-amd64.iso
英文=标准安装
系统分区
/boot 1000M /swap 8192M 其余/
设置主机名
sudo hostnamectl set-hostname sstack
3. 配置hosts
sudo vim /etc/hosts
192.168.1.82 kolla.zixuanyun.com
192.168.1.83 sstack
4. 配置ssh
sudo vim /etc/ssh/sshd_config
100行 #ClientAliveInterval 0
101行 #ClientAliveCountMax 3
修改成
ClientAliveInterval 60
ClientAliveCountMax 60
重启ssh服务
sudo systemctl restart sshd && systemctl status sshd
5. 配置ssh允许root登陆(切换到root管理员权限下 su root )
sed -i '/PermitRootLogin/d' /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
service sshd reload
6. ssh免密验证 #sstack节点操作
ssh-keygen
ssh-copy-id root@sstack
7. 配置国内源
1.备份
sudo cp -v /etc/apt/sources.list /etc/apt/sources.list.backup
2.修改文件权限,确保文件可修改
sudo chmod 777 /etc/apt/sources.list
3.使用图形化界面或vim直接修改文件内容
> /etc/apt/sources.list
vim /etc/apt/sources.list
4.将文件中的原内容全部注释,添加国内源地址
清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan focal restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan focal restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates focal restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates focal restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports focal restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports focal restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security focal restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security focal restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed focal restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed focal restricted universe multiverse4.
修改完成后记得点击图形界面的保存按钮/vim中按esc推出编辑模式,输入:wq保存并退出
5.更新软件
sudo apt update -y
sudo apt upgrade -y
8. 设置默认python、pip(软连接)并换源
Pip
pip是一个用来安装Python软件包的工具,由于Python 2已经退出了历史的舞台,Ubuntu20.04也移除了Python 2,所以不能够使用python-pip安装pip。
1. 安装pip3
sudo apt-get install python3-pip -y
2. 当安装结束,检查pip版本:
pip3 --version
3. 更换pip源
pip默认使用境外源,下载速度较慢且时而报错,我们可以更换为国内的pip源:
mkdir ~/.pip/
cd .pip
sudo vim pip.conf
将下列内容加入到pip.conf文件中:
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
4. 查看当前源:
pip3 config list
#其他国内源:
# 清华源
https://pypi.tuna.tsinghua.edu.cn/simple
# 腾讯源
http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
http://pypi.douban.com/simple/
5. 更新pip
sudo pip3 install --upgrade pip
二. 配置环境
ln -svf /usr/bin/python3 /usr/bin/python
pip3 install -U docker
3. 安装kolla-ansilbe 版本 对于victoria版本 要指定pip install kolla-ansible==11.0.0
pip3 install kolla-ansible==11.0.0
4. 创建/etc/kolla目录 sudo mkdir -p /etc/kolla
sudo chown $USER:$USER /etc/kolla
5. 复制globals.yml并passwords.yml到/etc/kolla目录
cp -r /usr/local/share/kolla-ansible/etc_examples/kolla/* /etc/kolla
6. 将文件复制all-in-one并multinode清点到当前目录
cp /usr/local/share/kolla-ansible/ansible/inventory/* .
三. 文件配置
1. 配置globals.yml文件,开启需要的文件
vim /etc/kolla/globals.yml
kolla_base_distro: "ubuntu"
kolla_install_type: "source"
openstack_release: "victoria"
node_custom_config: "/etc/kolla/config"
kolla_internal_vip_address: "192.168.1.82"
kolla_internal_fqdn: "kolla.zixuanyun.com"
docker_registry: "kolla2.zixuanyun.com:4000"
docker_namespace: "kolla"
docker_client_timeout: 120
network_interface: "eno1"
neutron_external_interface: "eno2"
neutron_plugin_agent: "openvswitch"
neutron_tenant_network_types: "vxlan,vlan,flat"
keepalived_virtual_router_id: "56"
#enable_chrony: "no"
enable_cinder: "yes"
enable_cinder_backup: "no"
enable_cinder_backend_lvm: "yes"
enable_heat: "no"
enable_neutron_provider_networks: "yes"
cinder_volume_group: "cinder-volumes"
nova_compute_virt_type: "kvm"
nova_console: "spice"
2. 配置 vim all-in-one
vim /root/all-in-one
修改如下:
[control]
sstack
[network]
sstack
[compute]
sstack
[storage]
sstack
[monitoring]
sstack
[deployment]
sstack
3. 生成随机密码
kolla-genpwd
4. 修改界面登陆密码为xuanyi100
sed -i 's/^keystone_admin_password.*/keystone_admin_password: xuanyi100/' /etc/kolla/passwords.yml
5. 为后端存储准备
#格式化
mkfs.ext4 /dev/sdb
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb
6. 设置nova配置文件
mkdir /etc/kolla/config
mkdir /etc/kolla/config/nova
cat >> /etc/kolla/config/nova/nova-compute.conf << EOF
[libvirt]
inject_password=true
cpu_mode=host-passthrough
virt_type = kvm
EOF
7. 配置nova配额分配
cat >> /etc/kolla/config/nova.conf << EOF
[DEFAULT]
service_down_time = 120
cpu_allocation_ratio = 4.0
disk_allocation_ratio=1.0
ram_allocation_ratio = 1.0
reserved_host_disk_mb = 8192
reserved_host_memory_mb = 8192
allow_resize_to_same_host = True
remove_unused_base_images = False
image_cache_manager_interval = 0
resume_guests_state_on_host_boot = True
EOF
8. 创建虚拟机界面禁止默认创建新卷.
mkdir /etc/kolla/config/horizon
cat >> /etc/kolla/config/horizon/custom_local_settings << EOF
LAUNCH_INSTANCE_DEFAULTS = {'create_volume': False,}
EOF
四. 部署安装
#sstack上执行
1. 检查
ansible -i all-in-one all -m ping
kolla-ansible -i ./all-in-one prechecks -vv
2. 引导各节点依赖
kolla-ansible -i ./all-in-one bootstrap-servers -vv
3. 部署
kolla-ansible -i ./all-in-one deploy -vv
4. 安装OpenStack CLI客户端:
add-apt-repository cloud-archive:victoria
apt update && apt dist-upgrade
apt install python3-openstackclient -y
5. 部署完成后生成rc文件
kolla-ansible -i all-in-one post-deploy
cp /etc/kolla/admin-openrc.sh ./
chmod +x admin-openrc.sh
6. 设置环境变量:
source /root/admin-openrc.sh
7. 编辑初始化脚本中的网络配置
vim /usr/local/share/kolla-ansible/init-runonce
EXT_NET_CIDR=${EXT_NET_CIDR:-'192.168.1.0/24'}
EXT_NET_RANGE=${EXT_NET_RANGE:-'start=192.168.1.87,end=192.168.1.200'}
EXT_NET_GATEWAY=${EXT_NET_GATEWAY:-'192.168.1.1'}
8. 执行初始化脚本:
. /usr/local/share/kolla-ansible/init-runonce
9. 访问dashbaord
http://kolla.zixuanyun.com admin zixuanyun