先电Openstack云平台搭建【超级详细】【附带镜像】

前言

大二上学期学习Openstack,苦于百度与CSDN上没有对应版本的教程,学的十分艰难,在此,将我的Openstack云平台搭建过程写出,留给新手学习

准备工作:

VMware Workstation Pro 虚拟机 我使用版本:15.5.2 build-15785246

CentOS-7-x86_64-DVD-1511.iso

XianDian-IaaS-v2.2.iso

补上需要的两个镜像

链接:https://pan.baidu.com/s/1RUzNN4j8myJhMlFerny7uw 
提取码:bxae 
复制这段内容后打开百度网盘手机App,操作更方便哦

虚拟机配置 (controller和compute配置相同):

内存    3G

处理器    2G

硬盘    50G

CD/DVD    CentOS-7-x86_64-DVD-1511.iso

网络适配器    VMnet1

网络适配器2  VMnet2

controller和compute网络配置

主机名VMnet1VMnet2
controller192.168.28.10192.168.128.10
compute192.168.28.20192.168.128.20

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

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

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,并使用CRT将xiandian镜像传入opt目录下

cd /opt
mkdir centos iaas

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

cat >>/etc/fstab<<eof
/dev/cdrom      /opt/centos     iso9660 defaults        0       0
/opt/XianDian-IaaS-v2.2.iso     /opt/iaas   iso9660    defaults        0       0
eof

挂载立即生效

mount -a    

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

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

清除缓存,生成缓存

yum clean all
yum makecache

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

[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源没配置好,也可能是没挂载好,这里很坑

[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 的消息

执行下面这段命令即可

rm -rf /var/run/yum.pid

接下来安装vsftpd和iaas-xiandian

yum install iaas-xiandian vsftpd -y

在controller上安装 ftp(文件传输)服务
增加匿名访问

cat >>/etc/vsftpd/vsftpd.conf<<eof
anon_root=/opt
eof
systemctl restart network
systemctl start vsftpd
systemctl enable vsftpd

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

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   查看配置文件,配置完后,应如下图

#--------------------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配置

compute

查看是否连接到controller的 opt/ 下面的挂载文件

[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

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

cd /opt
mkdir centos iaas
cd /etc/yum.repos.d/
mkdir bk
mv C* bk
touch ftp.repo

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

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

清除缓存,生成缓存

yum clean all
yum makecache

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

[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 文件传输到 本机

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

执行安装脚本

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

iaas-pre-host.sh

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

两台均重启

reboot

重新启动虚拟机

控制节点安装 (controller)

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)

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

安装需要很长时间,请耐心等待

执行完成后

使用Chrome浏览器访问(其他浏览器不太好,造成访问不到)

http://控制IP/dashboard

我的控制节点IP为 192.168.28.10

所以我访问

http://192.168.28.10/dashboard

访问成功界面

域:demo

用户名:admin

密码:000000

进入

至此,Openstack云平台的安装结束

  • 54
    点赞
  • 389
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 47
    评论
openstack平台部署的步骤如下所示: 1. 配置虚拟机。 2. 创建控节点和计算节点虚拟机。 3. 导入centos\XDian镜像包。 4. 配置源。 5. 修改配置文件。 6. 安装openstack包。 7. 安装Controller和compute节点的openstack各种组件。 8. 进行测试。1] 另外,在部署过程中还应该对平台安全性进行配置,包括https传输加密、存储加密、主机迁移、防火墙即服务、安全组规则、浮动IP、iptables防火墙、用户登录密码策略、VxLAN网络、KVM热添加硬盘、openstack服务组件日志集中收集、DDoS等。 最后,通过浏览器输入计算平台的网址http://192.168.100.10/dashboard,并使用域(demo)、用户名(admin)和密码(000000)登录来使用openstack平台。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [计算学习1——OpenStack计算安装部署步骤图文并茂(2.2)](https://blog.csdn.net/eryunyong/article/details/124319127)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [OpenStack安全部署指导书.zip](https://download.csdn.net/download/qq_43802023/13133605)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 47
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小航冲冲冲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值