先电IaaS2.2私有云部署OpenStack

前期准备

ip拓扑

主机名 ip1(NAT) ip2(仅主机) 硬盘 内存
controller-48 192.168.48.10 192.168.148.10 100G 8G
computer-48 192.168.48.20 192.168.148.20 100G 3G

基础镜像

CentOS-7-x86_64-DVD-2009.iso
chinaskills_cloud_iaas.iso

1
2
3
4
[root@localhost ~]# ll
total 4758568
-rw-r--r-- 1 root root 861155328 Jun 19 03:06 CentOS-7-x86_64-DVD-2009.iso
-rw-r--r-- 1 root root 3799093248 Jun 19 03:06 chinaskills_cloud_iaas.iso

虚拟机硬件配置

image-20230619160042336

controller

computer

image-20230618184522907

sdb和sdc是分别作为cinder服务和swift服务的存储磁盘。

配置主机名和hosts,关闭防火墙和永久关闭selinux

controller

1
2
3
4
5
6
7
hostnamectl set-hostname controller && bash
systemctl disable firewalld --now
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
echo "192.168.48.10 controller" >> /etc/hosts
echo "192.168.48.20 computer" >> /etc/hosts
setenforce 0

computer

1
2
3
4
5
6
7
hostnamectl set-hostname computer && bash
systemctl disable firewalld --now
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
echo "192.168.48.10 controller" >> /etc/hosts
echo "192.168.48.20 computer" >> /etc/hosts
setenforce 0

确保两者可以互通!

格式化compute磁盘(在compute中操作)

1
2
mkfs.xfs /dev/sdb
mkfs.xfs /dev/sdc

配置yum源

controller

1
2
3
4
5
6
7
8
9
10
11
12
13
rm -rf /etc/yum.repos.d/*
cat >> /etc/yum.repos.d/centos.repo << EOF
[centos]
name=centos
baseurl=file:///qianyios/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///qianyios/iaas-repo
gpgcheck=0
enabled=1
EOF

computer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mkdir repo.bak
mv /etc/yum.repos.d/* repo.bak/
cat >> /etc/yum.repos.d/centos.repo << EOF
[centos]
name=centos
baseurl=ftp://192.168.48.10/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://192.168.48.10/iaas-repo
gpgcheck=0
enabled=1
EOF

挂载iso镜像文件

1
2
3
4
5
6
7
8
9
#控制节点
mkdir /qianyios/centos -p
mount -o loop CentOS-7-x86_64-DVD-2009.iso /mnt/
cp -rvf /mnt/* /qianyios/centos/
umount /mnt/
mount -o loop chinaskills_cloud_iaas.iso /mnt/
cp -rvf /mnt/* /qianyios/
umount /mnt/
yum clean all && yum makecache

搭建ftp服务器

1
2
3
4
5
6
控制节点
yum install vsftpd -y
cat>> /etc/vsftpd/vsftpd.conf <<EOF
anon_root=/qianyios/
EOF
systemctl start vsftpd && systemctl enable vsftpd

验证操作

1.清理yum缓存

1
2
#各节点
yum clean all && yum makecache

2.在文件资源管理器输入ftp://192.168.48.10/

image-20230618192456867

编辑xiandian变量

1
2
3
4
5
6
#各节点
yum install iaas-xiandian -y
#使用sed命令批量去除第一个#注释符为空
sed -i -e 's/^#//'g /etc/xiandian/openrc.sh
使用sed命令批量修改密码默认000000
sed -i -e 's/PASS=/PASS=000000/'g /etc/xiandian/openrc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
grep -v "^#" /etc/xiandian/openrc.sh | grep -v "^$"
HOST_IP=192.168.48.10
HOST_PASS=123456
#ssh登入密码
HOST_NAME=controller
HOST_IP_NODE=192.168.48.20
HOST_PASS_NODE=123456
#ssh登入密码
HOST_NAME_NODE=computer
network_segment_IP=192.168.48.0/24
RABBIT_USER=openstack
RABBIT_PASS=000000
DB_PASS=000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
KEYSTONE_DBPASS=000000
GLANCE_DBPASS=000000
GLANCE_PASS=000000
NOVA_DBPASS=000000
NOVA_PASS=000000
NEUTRON_DBPASS=000000
NEUTRON_PASS=000000
METADATA_SECRET=000000
INTERFACE_IP=192.168.48.10
#复制到第二台机的时候,记得改成192.168.48.20
INTERFACE_NAME=ens36
#第二块网卡的名字
Physical_NAME=provider
minvlan=2
maxvlan=300
CINDER_DBPASS=000000
CINDER_PASS=000000
BLOCK_DISK=sdb
SWIFT_PASS=000000
OBJECT_DISK=sdc
STORAGE_LOCAL_NET_IP=192.168.48.20
HEAT_DBPASS=000000
HEAT_PASS=000000
ZUN_DBPASS=000000
ZUN_PASS=000000
KURYR_DBPASS=000000
KURYR_PASS=000000
CEILOMETER_DBPASS=000000
CEILOMETER_PASS=000000
AODH_DBPASS=000000
AODH_PASS=000000
BARBICAN_DBPASS=000000
BARBICAN_PASS=000000

1
2
3
scp /etc/xiandian/openrc.sh computer:/etc/xiandian/openrc.sh 
#以下在计算节点
sed -i 's/INTERFACE_IP=192.168.48.10/INTERFACE_IP=192.168.48.20/g' /etc/xiandian/openrc.sh

安装平台基本服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[root@controller ~]# iaas-pre-host.sh 
[root@compute ~]# iaas-pre-host.sh
#双节点
reboot
# 可同时执行,执行完毕后脚本会提示重启,不然rabbitmq服务会报错!!!此脚本会初始化虚拟机环境,如修改主机
名、主机映射、时间同步等,自己可去尝试解读脚本,手工搭建平台!!!!,由于重启可能导致平台出现问题可用ssh
连接自己的IP地址重新登陆,只要出现屏幕登录时间以及看到屏幕欢迎界面即可
Controller节点
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh

Controller节点
iaas-install-nova-controller.sh
Compute节点
iaas-install-nova-compute.sh

Controller节点
sed -i 's/yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y/yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y --skip-broken/g' /usr/local/bin/iaas-install-neutron-controller.sh

iaas-install-neutron-controller.sh
Compute节点
iaas-install-neutron-compute.sh

Controller节点
iaas-install-dashboard.sh

从Ftp服务器上下载镜像到本地。(在controller中操作)
source /etc/keystone/admin-openrc.sh
glance image-create --name CentOS7.5 --disk-format qcow2 --container-format bare --progress < /qianyios/images/CentOS_7.5_x86_64_XD.qcow2

访问页面http://192.168.48.10/dashboard/

image-20230619014112445

更多服务

1
2
3
4
5
6
7
8
9
10
11
12
#所以安装脚本都在/usr/local/bin/目录下
#按照自己需求安装
安装Swift对象存储服务
iaas-install-swift-controller.sh
安装Heat编配服务
iaas-install-heat.sh
安装Zun服务
iaas-install-zun-controller.sh
安装Ceilometer监控服务
iaas-install-ceilometer-controller.sh
安装Aodh监控服务
iaas-install-aodh.sh
特别声明
千屹博客旗下的所有文章,是通过本人课堂学习和课外自学所精心整理的知识巨著
难免会有出错的地方
如果细心的你发现了小失误,可以在下方评论区告诉我,或者私信我!
非常感谢大家的热烈支持!