前言

我这里是Windows10/11专业工作版(其他Windows版本也适用)
如果你的设备是已经是结束支持的Windows7,请查阅其他相关是手册


什么是云平台

简单概念

云平台是基于云计算技术,为用户提供计算、存储、网络等一系列信息技术资源和服务的平台

核心组成部分

基础设施即服务(IaaS):提供基础的计算、存储和网络资源,用户可按需租用服务器、存储空间、网络带宽等,如阿里云的弹性计算服务。
平台即服务(PaaS):在IaaS基础上,提供软件开发、运行和管理的平台,用户只需专注于开发应用,无需管理底层基础设施,如谷歌的App Engine。
软件即服务(SaaS):直接向用户提供各种软件应用服务,用户通过互联网浏览器使用软件,如腾讯文档等。

特点

灵活性与可扩展性:用户能根据业务需求灵活调整资源,实现快速扩展或收缩。
高可靠性:云平台通常有多个数据中心和冗余备份,保障服务的连续性和数据的安全性。
成本效益:用户按需付费,无需大量前期硬件投资,降低了企业的运营成本。
便捷的管理:用户可通过云平台的管理界面轻松管理和监控资源,无需专业的运维团队。

应用场景

企业信息化:企业可将业务系统部署在云平台,实现办公自动化、客户关系管理等功能。
大数据与人工智能:云平台提供强大的计算和存储能力,支持大数据分析和人工智能模型训练。
网站与应用托管:开发者可将网站和应用程序部署在云平台,快速上线并实现全球访问


简单搭建一个云计算平台

本次是以搭建一个先电云平台为例

准备阶段

软件:
VMware Workstation Pro 17
镜像:
CentOS-7-x86_64-DVD-1511.iso
XianDian-IaaS-v2.2.iso

硬件配置

打开VMware Workstation Pro 17,建立两个虚拟机,一个命名为controller 另一个命名为 compute
硬件配置如下
内存 3G
处理器 2G
硬盘 50G
CD/DVD CentOS-7-x86_64-DVD-1511.iso
网络适配器 VMnet1
网络适配器2 VMnet2

网络配置

主机名 VMnet1 VMnet2
controller 192.168.28.10 192.168.128.10
compute 192.168.28.20 192.168.128.20

搭建过程

改主机名字,关防火墙,设置主机映射开启虚拟机

controller

1
2
3
4
5
6
7
8
9
hostnamectl set-hostname controller
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat >>/etc/hosts<<eof
192.168.28.10 controller
192.168.28.20 compute
eof

compute

1
2
3
4
5
6
7
8
9
hostnamectl set-hostname compute
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat >>/etc/hosts<<eof
192.168.28.10 controller
192.168.28.20 compute
eof

controller 传输并挂载镜像

建立镜像存放的目录

进入opt目录,创建挂载点 centos 以及 iaas,(没有opt要自己建立),使用CRT将xiandian镜像传入opt目录下

1
2
cd /opt
mkdir centos iaas

镜像自己挂载

设置开机自动挂载镜像文件

1
cat >>/etc/fstab<<eof

挂载立即生效

1
mount -a    

修改yum源

进入 /etc/yum.repos.d 目录,删除或移动里面的大写C开头的文件,否则后面会造成缓存错误,载创建repo源文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cd /etc/yum.repos.d
mkdir bk
mv C* bk
cat >>/etc/yum.repos.d/local.repo<<eof
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas/iaas-repo
gpgcheck=0
enabled=1
eof

清除缓存,生成缓存

1
2
yum clean all
yum makecache

出现提示,说明是成功了(不需要和我的完全一摸一样,因为iso版本的不同,生成的缓存也不同)

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@controller ~]# yum makecache
已加载插件:fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/7): centos/filelists_db | 2.9 MB 00:00:00
(2/7): centos/group_gz | 155 kB 00:00:00
(3/7): iaas/filelists_db | 1.9 MB 00:00:00
(4/7): iaas/primary_db | 2.3 MB 00:00:00
(5/7): centos/primary_db | 2.8 MB 00:00:00
(6/7): iaas/other_db | 692 kB 00:00:00
(7/7): centos/other_db | 1.2 MB 00:00:00
Determining fastest mirrors
元数据缓存已建立

注意,出现下面的错误,可能是之前的步骤出错了,可能是yum源没配置好,也可能是没挂载好!!!

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
[root@compute yum.repos.d]# yum makecache
已加载插件:fastestmirror
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:

yum-config-manager --disable <repoid>

4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: centos

如果是出现了 /var/run/yum.pid 的消息

1
rm -rf /var/run/yum.pid

接下来安装vsftpd和iaas-xiandian

1
yum install iaas-xiandian vsftpd -y

增加匿名访问

在controller上安装 ftp(文件传输)服务

1
2
3
4
5
6
cat >>/etc/vsftpd/vsftpd.conf<<eof
anon_root=/opt
eof
systemctl restart network
systemctl start vsftpd
systemctl enable vsftpd

先电镜像配置

接下来配置xiandian的openrc.sh应答文件(一个字都不能错)

1
2
3
4
5
6
7
8
9
10
sed -i 's/.//' /etc/xiandian/openrc.sh
sed -i 's/PASS=/PASS=000000/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_IP=/HOST_IP=192.168.28.10/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_NAME=/HOST_NAME=controller/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_IP_NODE=/HOST_IP_NODE=192.168.28.20/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_NAME_NODE=/HOST_NAME_NODE=compute/g' /etc/xiandian/openrc.sh
sed -i 's/RABBIT_USER=/RABBIT_USER=openstack/g' /etc/xiandian/openrc.sh
sed -i 's/DOMAIN_NAME=/DOMAIN_NAME=demo/g' /etc/xiandian/openrc.sh
sed -i 's/METADATA_SECRET=/METADATA_SECRET=000000/g' /etc/xiandian/openrc.sh
sed -i 's/INTERFACE_NAME=/INTERFACE_NAME=ens34/g' /etc/xiandian/openrc.sh

接着使用命令 cat /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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.28.10

#Controller Server hostname. example:controller
HOST_NAME=controller

#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.28.20

#Compute Node hostname. example:compute
HOST_NAME_NODE=compute

#--------------------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=demo
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=000000

#Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000

#--------------------Nova Config----------------------##
#Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000

#Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000

#--------------------Neturon Config-------------------##
#Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000

#Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000

#metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000

#External Network Interface. example:eth1
INTERFACE_NAME=ens37

#First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
minvlan=

#Last Vlan ID in VLAN RANGE for VLAN Network. example:200
maxvlan=

#--------------------Cinder Config--------------------##
#Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=

#Password for Keystore cinder user. exmaple:000000
CINDER_PASS=

#Cinder Block Disk. example:md126p3
BLOCK_DISK=

#--------------------Trove Config--------------------##
#Password for Mysql Trove User. exmaple:000000
TROVE_DBPASS=

#Password for Keystore Trove User. exmaple:000000
TROVE_PASS=

#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=

#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=

#The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=

#--------------------Heat Config----------------------##
#Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=

#Password for Keystore heat user. exmaple:000000
HEAT_PASS=

#--------------------Ceilometer Config----------------##
#Password for Mysql ceilometer user. exmaple:000000
CEILOMETER_DBPASS=

#Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=

#--------------------AODH Config----------------##
#Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=

#Password for Keystore AODH user. exmaple:000000
AODH_PASS=

现在controller的配置就结束了!!!

compute 配置

检查是否连接上controller的挂载的文件

1
2
3
4
[root@compute yum.repos.d]# curl ftp://192.168.28.10
-rw-r--r-- 1 0 0 2851502080 Jun 04 2020 XianDian-IaaS-v2.2.iso
dr-xr-xr-x 8 0 0 2048 Dec 09 2015 centos
drwxr-xr-x 4 0 0 2048 Nov 06 2017 iaas

创建repo源

进入opt目录,创建centos和iaas文件,移动或删除大写C开头文件,创建一个ftp.repo源文件

1
2
3
4
5
6
cd /opt
mkdir centos iaas
cd /etc/yum.repos.d/
mkdir bk
mv C* bk
touch ftp.repo

修改 repo源

进入 /etc/yum.repos.d/ftp.repo 写入

1
2
3
4
5
6
7
8
9
10
11
12
cat >>/etc/yum.repos.d/ftp.repo<<eof
[centos]
name=centos
baseurl=ftp://192.168.28.10/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://192.168.28.10/iaas/iaas-repo
gpgcheck=0
enabled=1
eof

清除缓存,生成缓存

1
2
yum clean all
yum makecache

如出现以下画面,说明成功

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@compute yum.repos.d]# yum makecache
已加载插件:fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/7): centos/group_gz | 155 kB 00:00:00
(2/7): centos/filelists_db | 2.9 MB 00:00:00
(3/7): centos/primary_db | 2.8 MB 00:00:00
(4/7): centos/other_db | 1.2 MB 00:00:00
(5/7): iaas/filelists_db | 1.9 MB 00:00:00
(6/7): iaas/primary_db | 2.3 MB 00:00:00
(7/7): iaas/other_db | 692 kB 00:00:00
Determining fastest mirrors
元数据缓存已建立

下载 iaas-xiandain 进入 /etc/xiandian ,将openrc.sh 改名为openrc.sh.bk 备份 以防出现错误

再将 controller(192.168.28.10)中的 /etc/xiandian/openrc.sh 文件传输到 本机

1
2
3
4
yum -y install iaas-xiandian
cd /etc/xiandian
mv openrc.sh openrc.sh.bk
scp 192.168.28.10:/etc/xiandian/openrc.sh openrc.sh

执行安装脚本

两个节点均执行初始化脚本

1
iaas-pre-host.sh

注意:执行需要一段时间,不要去按回车什么的了,在出现 【reboot】提示后,必须重启,否则之后的实例发不出去,问题很大!!!

控制节点安装 (controller)

1
2
3
4
5
6
7
8
9
10
11
cd /usr/local/bin
cat >>/usr/local/bin/all-in-one.sh<<eof
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-neutron-controller-gre.sh
iaas-install-dashboard.sh
eof
source all-in-one.sh

计算节点安装(compute)

1
2
3
4
5
6
7
cd /usr/local/bin
cat >>/usr/local/bin/all-in-one.sh<<eof
iaas-install-nova-compute.sh
iaas-install-neutron-compute.sh
iaas-install-neutron-compute-gre.sh
eof
source all-in-one.sh

安装需要很长时间,请耐心等待
执行完成后,使用浏览器访问
http://控制IP/dashboard

访问

访问成功界面
域:demo
用户名:admin
密码:000000


总结

1、建立两个虚拟机,分别命名为controller和compute,并配置好网卡和硬件
2、controller负责挂载两个镜像、配置yum源、先电镜像配置
3、compute 负责repo源
4、两个节点都安装先电的服务
5、使用实体机浏览器访问