OpenStack all-in-one部署:
本次部署为OpenStack Queens版本部署,使用All-in-one,单节点部署。
物理资源:8核,32GB,硬盘400GB(3个盘),2网卡。
其中CPU核心数和内存尽量高,如果资源有限,可以在上面的标准上进行降低,添加三块硬盘,是为了做测试使用,下文会有硬盘操作。
1.网卡个数和状态:
# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.89.127.123 netmask 255.255.255.0 broadcast 10.89.127.255
inet6 fe80::250:56ff:feaf:7db prefixlen 64 scopeid 0x20<link>
ether 00:50:56:af:07:db txqueuelen 1000 (Ethernet)
RX packets 1910 bytes 182468 (178.1 KiB)
RX errors 0 dropped 10 overruns 0 frame 0
TX packets 110 bytes 18260 (17.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::250:56ff:feaf:cd32 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:af:cd:32 txqueuelen 1000 (Ethernet)
RX packets 766 bytes 60800 (59.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 2708 (2.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
部署all-in-one模式,需要两张网卡,在此案例中使用ens160作为管理网,ens192作为业务网,ens192不需要配置ip,只需要ifup。
2.主机名设置
hostnamectl set-hostname queens
3.环境初始化
3.1关闭NetworkManager
,firewalld
,selinux
关闭NetworkManager
# systemctl stop NetworkManager
# systemctl disable NetworkManager
关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
关闭selinux
# setenforce 0
# getenforce 0
# vi /etc/selinux/config
改为
SELINUX=disabled
3.2查看是否开启虚拟化
egrep "vmx|svm" /proc/cpuinfo
或者
cat /proc/cpuinfo
找到flags部分,如果其中输出有SVM或VMX,表明CPU支持虚拟化技术
3.3配置epel
源安装基础包
# yum install epel-release
# yum install axel vim git curl wget lrzsz gcc python-devel python-pip
4.安装docker
# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 默认安装最新版
# yum install -y docker-ce
4.1配置docker
# 1、如果不设置此项,kolla-ansible 部署neutron-dhcp-agent 容器的时候会失败,并抛出 APIError/HTTPError
mkdir /etc/systemd/system/docker.service.d
tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'
[Service]
MountFlags=shared
EOF
# 2、更改国内源、指定文件系统格式
vim /usr/lib/systemd/system/docker.service
# ExecStart=/usr/bin/dockerd
# 设置国内的daocloud.io镜像源,指定overlay2系统格式,docker默认就是overlay2
ExecStart=/usr/bin/dockerd --registry-mirror=http://f2d6cb40.m.daocloud.io --storage-driver=overlay2
4.2启动docker
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
systemctl status docker
docker info
5.安装ansible
5.1安装ansible
升级pip
pip install --upgrade pip
ansible
版本必须在2.0以上
yum -y install ansible
下载kolla-ansible
,并安装配置
git clone https://github.com/openstack/kolla-ansible -b stable/queens
cd kolla-ansible/
cp -r etc/kolla/ /etc/kolla/
pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple
解决:
pip install --upgrade pyyaml
pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple
5.2配置globals.yml
文件
vim /etc/kolla/globals.yml
kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "queens"
kolla_internal_vip_address: "10.89.127.123"
docker_namespace: "kolla"
network_interface: "ens160"
neutron_external_interface: "ens192"
enable_haproxy: "no"
nova_compute_virt_type: "qemu"
#开启freezer:
enable_freezer:"yes"
enable_heat:"yes"
enable_horizon_freezer:"{{ enable_freezer | bool }}"
#开启cinder:
enable_cinder: "yes"
说明:这里我直接在docker hub上拉镜像。如果是在虚拟机里安装 Kolla
,希望可以在 OpenStack
平台上创建虚拟机,那么你需要在 globals.yml
文件中把 nova_compute_virt_type
配置项设置为 qemu
,默认是 KVM
。
5.3ceph配置
#创建文件
vim /etc/kolla/config/ceph.conf
[global]
osd pool default size = 1
osd pool default min size = 1
#查看硬盘标签
lsblk
#给硬盘打ceph标签
parted /dev/sdc -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP 1 -1
配置globals文件
enable_ceph: "yes"
enable_ceph_rgw: "yes"
#enable_swift: "no"
enable_ceph_rgw_keystone: "yes"
5.4swift配置
给硬盘打swift标签
index=0
for d in sdb; do
# 因为我这就有一块用于swift存储的盘sde。
parted /dev/${d} -s -- mklabel gpt mkpart KOLLA_SWIFT_DATA 1 -1
sudo mkfs.xfs -f -L d${index} /dev/${d}1
(( index++ ))
done
生成rings,执行脚本
STORAGE_NODES=(10.89.127.123)
KOLLA_SWIFT_BASE_IMAGE="kolla/centos-source-swift-base:queens"
mkdir -p /etc/kolla/config/swift
# Object ring
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/object.builder create 10 3 1
for node in ${STORAGE_NODES[@]}; do
for i in {0..2}; do
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/object.builder add r1z1-${node}:6000/d${i} 1;
done
done
# Account ring
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/account.builder create 10 3 1
for node in ${STORAGE_NODES[@]}; do
for i in {0..2}; do
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/account.builder add r1z1-${node}:6001/d${i} 1;
done
done
# Container ring
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/container.builder create 10 3 1
for node in ${STORAGE_NODES[@]}; do
for i in {0..2}; do
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/container.builder add r1z1-${node}:6002/d${i} 1;
done
done
for ring in object account container; do
docker run
--rm
-v /etc/kolla/config/swift/:/etc/kolla/config/swift/
$KOLLA_SWIFT_BASE_IMAGE
swift-ring-builder
/etc/kolla/config/swift/${ring}.builder rebalance;
done
配置globals文件
vim /etc/kolla/globals.yml
enable_ceph: "no"
enable_ceph_rgw: "no"
enable_swift: "yes"
enable_ceph_rgw_keystone: "no"
6.安装kolla
生成密码文件
kolla-genpwd
设置密码
#配置 `keystone` 管理员用户的密码
vim /etc/kolla/passwords.yml
keystone_admin_password: password
同时,也是登录 `Dashboard,admin` 使用的密码,你可以根据自己需要进行修改。
拉取镜像
#从`docker hub`上`pull`镜像
kolla-ansible pull
部署openstack
#部署,时间较长
kolla-ansible deploy
创建环境变量
#创建环境变量,文件在/etc/kolla中
kolla-ansible post-deploy
7.安装 OpenStack Client
端
pip install python-openstackclient
解决办法:
pip install --upgrade decorator
强制升级:
sudo pip install --ignore-installed +模块名
sudo pip install --ignore-installed ipaddress
编辑init-runonce
文件,设置public network
# vim /usr/share/kolla-ansible/init-runonce
EXT_NET_CIDR='10.89.127.0/24'
EXT_NET_RANGE='start=10.89.127.110,end=10.89.127.250'
EXT_NET_GATEWAY='10.89.127.254'
加载OpenStack CLI
所需的环境变量
source /etc/kolla/admin-openrc.sh
8.初始化部署
cd /usr/share/kolla-ansible/ && ./init-runonce
登陆Dashboard
用浏览器访问10.89.127.123
登陆Dashboard