云计算技术之先电 2.4私有云 IaaS 最小化部署
云计算技术之先电 V-2.4私有云 IaaS 最小化部署-篇1
版本说明
- 先电版本:v2.4
- 操作系统:CentOS 7.5 1804/Centos7.6都行自行选择
- IaaS 版本:OpenStack Queens v3.4.15
前言
- 本帖的安装环境为 虚拟机,使用版本为 VMware Workstation Pro 16
- 若使用真实 服务器 搭建需配合三层交换机使用,请自行更改网卡等参数,下面有详细的注释
镜像地址
链接:https://pan.baidu.com/s/1MLimSuJnz_vDl8rryTn5Ag
提取码:jrmy
一、硬件环境
节点 | 网卡1(vm1) | 网卡2(vm8) | 内存CPU |
---|---|---|---|
controller | 192.168.100.10 | 192.168.200.10 | 4G 4CPU |
compute | 192.168.100.20 | 192.168.200.20 | 4G 4CPU |
1. 网卡
2.所有节点处理器开启虚拟化:
:3.给节点加一块盘并做分区格式化
fdisk自行操作
二、初始化配置
1. 更改主机名
- Controller 节点:
hostnamectl set-hostname controller
bash
- Compute 节点:
hostnamectl set-hostname compute
bash
2. 配置网卡
vi /etc/sysconfig/network-scripts/ifcfg-<网卡名> # 修改配置文件命令
- Controller 节点
## eth0(网卡1)
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.100.10
PREFIX=24
GATEWAY=192.168.100.1
## eth1(网卡2)
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.200.10
PREFIX=24
备注:
第二张网卡作为openstack的业务网卡,安装neutron是会被修改为如下:
DEVICE=eth1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
- Compute 节点:
## eth0(网卡1)
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.100.20
PREFIX=24
GATEWAY=192.168.100.1
## eth1(网卡2)
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.200.10
PREFIX=24
备注:
第二张网卡作为openstack的业务网卡,安装neutron是会被修改为如下:
DEVICE=eth1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
3. 基础配置
- 所有节点上执行:
- 闭防火墙和SELINUX
systemctl disable firewalld && systemctl stop firewalld
sed -i "7c SELINUX=disabled" /etc/selinux/config
setenforce 0
添加解析记录
echo "192.168.100.10 controller" >> /etc/hosts
echo "192.168.100.20 compute" >> /etc/hosts
4. 配置 YUM 源
-
所有节点上执行:
rm -rf /etc/yum.repos.d/* # 删除原有官方源 或者备份 mkdir bak mv * -v bak bak/
-
Controller 节点:
-
上传镜像:
## 挂载镜像至 /opt 目录 mkdir -p /opt/centos /opt/iaas mount -o loop CentOS-7-x86_64-DVD-1804.iso /opt/centos mount -o loop XianDian-IaaS-v2.4.iso /opt/iaas
-
配置本地源:
vi /etc/yum.repos.d/local.repo # 编辑配置文件命令 [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1 [iaas] name=iaas baseurl=file:///opt/iaas/iaas-repo gpgcheck=0 enabled=1
-
测试并缓存源 (con/com都执行下!)
yum clean all yum makecache
-
安装并配置 FTP 服务器:
yum install -y vsftpd echo "anon_root=/opt" >> /etc/vsftpd/vsftpd.conf systemctl enable --now vsftpd
-
-
Compute 节点:
-
配置 FTP 源:
vi /etc/yum.repos.d/ftp.repo # 编辑配置文件命令 [centos] name=centos baseurl=ftp://controller/centos gpgcheck=0 enabled=1 [iaas] name=iaas baseurl=ftp://controller/iaas/iaas-repo gpgcheck=0 enabled=1
-
三、部署 IaaS 私有云
1. 安装并配置先电软件包
-
所有节点上执行
yum install -y iaas-xiandian vim # 安装先电软件包
-
Controller 节点:
### 修改渲染脚本,重要的一步,你OpenStack所有会通过这个脚本刷进部署环境!!! [root@controller ~]# yum install -y iaas-xiandian [root@controller ~]# sed -i 's/^.//g' /etc/xiandian/openrc.sh 然后编辑脚本文件 [root@controller ~]# vim /etc/xiandian/openrc.sh # 修改配置 #--------------------system Config--------------------## #Controller Server Manager IP. example:x.x.x.x HOST_IP=192.168.100.10 #Controller HOST Password. example:000000 #HOST_PASS=000000 #Controller Server hostname. example:controller HOST_NAME=controller #Compute Node Manager IP. example:x.x.x.x HOST_IP_NODE=192.168.100.20 #Compute HOST Password. example:000000 #HOST_PASS_NODE= #Compute Node hostname. example:compute HOST_NAME_NODE=compute #--------------------Chrony Config-------------------## #Controller network segment IP. example:x.x.0.0/16(x.x.x.0/24) network_segment_IP=192.168.100.10 #--------------------Rabbit Config ------------------## #user for rabbit. example:openstack RABBIT_USER=openstack #Password for rabbit user .example:000000 RABBIT_PASS=000000 #--------------------MySQL Config---------------------## #Password for MySQL root user . exmaple:000000 DB_PASS=000000 #--------------------Keystone Config------------------## #Password for Keystore admin user. exmaple:000000 DOMAIN_NAME=nsfocus ADMIN_PASS=000000 DEMO_PASS=000000 #Password for Mysql keystore user. exmaple:000000 KEYSTONE_DBPASS=000000 #--------------------Glance Config--------------------## #Password for Mysql glance user. exmaple:000000 GLANCE_DBPASS=glance #Password for Keystore glance user. exmaple:000000 GLANCE_PASS=glance #--------------------Nova Config----------------------## #Password for Mysql nova user. exmaple:000000 NOVA_DBPASS=nova #Password for Keystore nova user. exmaple:000000 NOVA_PASS=nova #--------------------Neturon Config-------------------## #Password for Mysql neutron user. exmaple:000000 NEUTRON_DBPASS=neutron #Password for Keystore neutron user. exmaple:000000 NEUTRON_PASS=neutron #metadata secret for neutron. exmaple:000000 METADATA_SECRET=000000 #Tunnel Network Interface. example:x.x.x.x INTERFACE_IP=192.168.100.10 ## (填入对应节点IP,这里很容易出错,看注释) #External Network Interface. example:eth1 INTERFACE_NAME=eth1 ## (计算节点的第二块网卡名) #External Network The Physical Adapter. example:provider Physical_NAME=Provider #First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101 minvlan=101 #Last Vlan ID in VLAN RANGE for VLAN Network. example:200 maxvlan=200 #--------------------Cinder Config--------------------## #Password for Mysql cinder user. exmaple:000000 CINDER_DBPASS=000000 #Password for Keystore cinder user. exmaple:000000 CINDER_PASS=000000 #Cinder Block Disk. example:md126p3 BLOCK_DISK=sdb1 #--------------------Swift Config---------------------## #Password for Keystore swift user. exmaple:000000 SWIFT_PASS=000000 #The NODE Object Disk for Swift. example:md126p4. OBJECT_DISK=sdb2 #The NODE IP for Swift Storage Network. example:x.x.x.x. STORAGE_LOCAL_NET_IP=192.168.100.10 #--------------------Heat Config----------------------## #Password for Mysql heat user. exmaple:000000 HEAT_DBPASS=000000 #Password for Keystore heat user. exmaple:000000 HEAT_PASS=000000 #--------------------Zun Config-----------------------## #Password for Mysql Zun user. exmaple:000000 ZUN_DBPASS=000000 #Password for Keystore Zun user. exmaple:000000 ZUN_PASS=000000 #Password for Mysql Kuryr user. exmaple:000000 KURYR_DBPASS=000000 #Password for Keystore Kuryr user. exmaple:000000 KURYR_PASS=000000 #--------------------Ceilometer Config----------------## #Password for Gnocchi ceilometer user. exmaple:000000 CEILOMETER_DBPASS=000000 #Password for Keystore ceilometer user. exmaple:000000 CEILOMETER_PASS=000000 #--------------------AODH Config----------------## #Password for Mysql AODH user. exmaple:000000 AODH_DBPASS=000000 #Password for Keystore AODH user. exmaple:000000 AODH_PASS=000000 #--------------------Barbican Config----------------## #Password for Mysql Barbican user. exmaple:000000 BARBICAN_DBPASS=000000 #Password for Keystore Barbican user. exmaple:000000 BARBICAN_PASS=000000
-
Compute 节点:
scp root@controller:/etc/xiandian/openrc.sh /etc/xiandian # 从控制节点拷贝变量配置文件 sed -i "69c INTERFACE_IP=192.168.100.20" /etc/xiandian/openrc.sh # 此条命令对应上面的注释
-
所有节点上执行:
source /etc/xiandian/openrc.sh # 使环境变量生效
2. 执行官方安装脚本
-
所有节点上执行:
iaas-pre-host.sh
<**备注:这一步是部署前的预处理,相当于precheck,非常重要,如果前面改完主机名没有重启,这里一定重启,不然部署完MQ必定有问题,集群没法用,很是操蛋!!!重要 **>
-
Controller 节点:
iaas-install-mysql.sh iaas-install-keystone.sh iaas-install-glance.sh iaas-install-nova-controller.sh iaas-install-neutron-controller.sh iaas-install-cinder-controller.sh iaas-install-dashboard.sh ### 这里你也可以直接搞成一个脚本一步完成!! # 没一步中间sleep 20
-
Compute 节点:
iaas-install-nova-compute.sh iaas-install-neutron-compute.sh iaas-install-cinder-controller.sh ### 同理
至此,基础安装部署已经完了,为了让计算资源更多点,我们可以将控制融合成计算加入集群中使用!!
将计算的ip和主机名改为 控制节点controller
,然后直接跑iaas-install-nova-compute.sh
即可
四、最小化部署完成--登录dashboard
浏览器访问:http://192.168.100.10/dashboard
五、创建云主机环境
下面的内容包含 IaaS 私有云基础运维,实际生产环境中一般使用图形界面代替命令操作
-
虚拟机环境需要在 Compute 节点执行下面的命令: (重要)
## 更改配置文件并重启 nova-compute 服务 crudini --set /etc/nova/nova.conf libvirt virt_type qemu systemctl restart libvirtd.service openstack-nova-compute.service
注:这里的两条命令是为了解决 虚拟机 环境下的 QEMU模拟器错误 导致云主机无法使用的问题,旧版本先电v2.2不存在此问题,真实 服务器 请忽略。
1. 创建镜像
glance image-create --name Centos --disk-format qcow2 --container-format bare --file CentOS_7.5_x86_64_XD.qcow2 --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 3d3e9c954351a4b6953fd156f0c29f5c |
| container_format | bare |
| created_at | 2022-08-18T06:23:14Z |
| disk_format | qcow2 |
| id | 80a05294-c05d-4b2f-ab09-cb999486b838 |
| min_disk | 0 |
| min_ram | 0 |
| name | Centos |
| owner | 1f4ca92181814b15ae02fd786f33b223 |
| protected | False |
| size | 510459904 |
| status | active |
| tags | [] |
| updated_at | 2022-08-18T06:23:18Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------+
2. 创建网络和子网
-
虚拟机
openstack network create ext-net --provider-physical-network provider --provider-network-type flat --external
-
服务器
openstack network create ext-net --provider-network-type vlan --provider-physical-network provider --provider-segment 1 --external
-
创建外部网络参数解读:
网络参数 | 含义用法 |
---|---|
provider-network-type | <供应商网络类型> |
provider-physical-network | <供应商物理设备名> 注:创建 Flat VLAN 网络类型时需要 |
provider-segment | <段 ID> 注:创建 VLAN GRE VXLAN Geneve 网络类型时需要 |
external | 外部网络 |
-
创建内部网络:
openstack network create vpc-net1 --provider-network-type vxlan --provider-segment 1 openstack network create vpc-net2 --provider-network-type vxlan --provider-segment 2
-
创建子网:
- 外部网络
openstack subnet create ext-subnet --network ext-net --gateway 192.168.200.1 --subnet-range 192.168.200.0/24 --allocation-pool start=192.168.200.100,end=192.168.200.200 --dhcp
- 内部网络
openstack subnet create vpc-subnet1 --network vpc-net1 --gateway 10.0.0.1 --subnet-range 10.0.0.0/24 --dhcp openstack subnet create vpc-subnet2 --network vpc-net2 --gateway 10.0.1.1 --subnet-range 10.0.1.0/24 --dhcp
-
创建子网参数解读:
子网参数 含义用法 network <网络名> gateway <网关地址> subnet-range <网络地址> allocation-pool <start=始IP,end=尾IP> dhcp 开启 DHCP 服务
3. 创建路由
-
创建路由
openstack router create ext-router
-
绑定外部网络
openstack router set ext-router --external-gateway ext-net
-
连接内部网络子网
openstack router add subnet ext-router vpc-subnet1
4. 创建安全组和规则
创建安全组,名称为 securty_all
创建规则
openstack security group rule create --ingress --protocol tcp securty_all
openstack security group rule create --ingress --protocol udp securty_all
openstack security group rule create --ingress --protocol icmp securty_all
openstack security group rule create --egress --protocol tcp securty_all
openstack security group rule create --egress --protocol udp securty_all
openstack security group rule create --egress --protocol icmp securty_all
5. 创建云主机
-
创建实例类型:
名称 ID 内存 硬盘 vCPU数 master 1 12G 100G 6个 node 2 8G 100G 4个
nova flavor-create flavor_master 2 2044 20 2
nova flavor-create flavor_node 2 8192 100 4
命令格式:nova flavor-create <名字> < ID > <内存> <硬盘容量> < vcpu 数量>
-
创建云主机:
nova boot --image CentOS7.5 --flavor 1 --nic net-name=int-net1,v4-fixed-ip=10.0.0.3 --security-groups all --poll master
-
创建云主机参数解读:
-
创建云主机参数 含义用法 image <镜像名> flavor <实例类型ID> nic <net-name=网络名>,<v4-fixed-ip=固定IP地址> security-groups <安全组名> poll 显示进度
-
-
创建浮动IP地址:
openstack floating ip create ext-net --floating-ip-address 192.168.200.104
-
绑定浮动IP地址至云主机:
openstack server add floating ip master 192.168.200.104
😮 下一篇演示纯脚本化一键部署!!!