IaaS/PaaS平台搭建
云计算IaaS搭建创建主机内存:8GB处理器:4硬盘:300GB网络适配器:VMnet8网络适配器2:VMnet1修改主机名[root@localhost ~]# hostnamectl controller[root@localhost ~]# bash关闭防火墙[root@controller ~]# systemctl stop firewalld[root@controller ~]# s
·
注意:此教程基于iaas2.4、paas2.4版本编写,其他版本若有不适请另寻其他方法
IaaS搭建
创建主机
内存:8GB
处理器:4
硬盘:300GB
网络适配器:VMnet8
网络适配器2:VMnet1
修改主机名
[root@localhost ~]# hostnamectl controller
[root@localhost ~]# bash
关闭防火墙
[root@controller ~]# systemctl stop firewalld
[root@controller ~]# systemctl disable firewalld
[root@controller ~]# systemctl status firewalld
[root@controller ~]# iptables -F
[root@controller ~]# iptables -X
[root@controller ~]# iptables -Z
[root@controller ~]# iptables-save
上传文件
CentOS-7-x86_64-DVD-1804.iso
XianDian-IaaS-V2.4.iso
分区操作
- 虚拟机时
[root@controller ~]# mkfs.xfs /dev/sdb
[root@controller ~]# mkfs.xfs /dev/sdc
- 服务器时
[root@controller ~]# parted
[root@controller ~]# mkpark
[root@controller ~]# primary
[root@controller ~]# ext2
[root@controller ~]# 起始大小
[root@controller ~]# 结束大小
[root@controller ~]# print
[root@controller ~]# q
网卡设置
网卡(2个)
controller
eth0:192.168.100.10/24
eth1:192.168.200.10/24
[root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
...
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.100.10
...
[root@controller ~]# service network restart
[root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
...
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.200.10
...
[root@controller ~]# service network restart
修改network文件
注意:可以不用修改,如果无法搭建平台时修改
[root@controller ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=controller
NOZEROCONF=yes
设置SELinux工作模式
[root@controller ~]# vi /etc/selinux/config
SELINUX=disabled
[root@controller ~]# setenforce 0
[root@controller ~]# getenforce
配置yum源
[root@controller ~]# mv /etc/yum.repos.d/* /home/
[root@controller ~]# vi /etc/yum.repos.d/repo.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas-repo
gpgcheck=0
enabled=1
复制文件
[root@controller ~]# mkdir /opt/centos
[root@controller ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt/
[root@controller ~]# cp -rvf /mnt/* /opt/centos/
[root@controller ~]# umount /mnt/
[root@controller ~]# mount -o loop XianDian-IaaS-V2.4.iso /mnt/
[root@controller ~]# cp -rvf /mnt/* /opt/
[root@controller ~]# umount /mnt/
[root@controller ~]# yum clean all
[root@controller ~]# yum list
[root@controller ~]# yum repolist
添加主机映射
[root@controller ~]# vi /etc/hosts
192.168.100.10 controller
安装qpid服务
[root@controller ~]# yum install qpid-cpp-server -y
[root@controller ~]# vi /etc/qpid/qpidd.conf
auth=no
[root@controller ~]# service qpidd start
[root@controller ~]# chkconfig qpidd on
安装IaaS
[root@controller ~]# yum install iaas-xiandian -y
[root@controller ~]# vi /etc/xiandian/openrc.sh
%s/^#//g(去除配置文件中每一行开头的#)
%s/PASS=/PASS=000000/g(将密码全部设置为000000)
配置详情
##--------------------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.10
#Compute HOST Password. example:000000
HOST_PASS_NODE=000000
#Compute Node hostname. example:compute
HOST_NAME_NODE=controller
#--------------------Chrony Config-------------------##
#Controller network segment IP. example:x.x.0.0/16(x.x.x.0/24)
network_segment_IP=192.168.100.0/24
##--------------------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=admin
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
#Tunnel Network Interface. example:x.x.x.x
INTERFACE_IP=192.168.100.10
#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=sdb
##--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000
#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=sdc
#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
部署OpenStack
/**
若不是新建脚本跑则不用执行下列命令
[root@controller ~]# vi iaas-install-all-in-one.sh
[root@controller ~]# !/bin/bash
[root@controller ~]# chmod +x iaas-install-all-in-one.sh
[root@controller ~]# ./iaas-install-all-in-one.sh
**/
[root@controller ~]# iaas-pre-host.sh
[root@controller ~]# iaas-install-mysql.sh
[root@controller ~]# iaas-install-keystone.sh
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# iaas-install-glance.sh
[root@controller ~]# glance image-create --name "centos7.5" --disk-format qcow2 --container-format bare --progress < /opt/images/CentOS_7.5_x86_64_XD.qcow2
[root@controller ~]# iaas-install-nova-controller.sh
[root@controller ~]# iaas-install-nova-compute.sh
[root@controller ~]# iaas-install-neutron-controller.sh
[root@controller ~]# iaas-install-neutron-compute.sh(可以省略不跑)
[root@controller ~]# iaas-install-dashboard.sh
==============================================================================
[root@controller ~]# iaas-install–cinder-controller.sh
[root@controller ~]# iaas-install–cinder-compute.sh
[root@controller ~]# iaas-install-swift-controller.sh
[root@controller ~]# iaas-install-swift-compute.sh
[root@controller ~]# iaas-install-heat.sh
[root@controller ~]# iaas-install-zun-controller.sh
[root@controller ~]# iaas-install-zun-compute.sh
[root@controller ~]# iaas-install-aodh.sh
[root@controller ~]# iaas-install-ceilometer-controller.sh
[root@controller ~]# iaas-install-ceilometer-compute.sh
[root@controller ~]# iaas-install-barbican.sh
##查看openstack服务状态
[root@controller ~]# openstack-status
##重启openstack 服务
[root@controller ~]# openstack-service restart
注意:创建实例时选择不创建新卷
打开地址:192.168.100.10/dashboard/
PaaS搭建
创建两台主机(master/node)
内存:8GB
处理器:4
硬盘:200GB
网络适配器:VMnet8
网络适配器2:VMnet1
基础设置
【master】
//设置主机名
[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# bash
//设置网络
[root@master ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
...
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.100.10
...
[root@master ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
...
BOOTPROTO=static
DEFROUTE=yes
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.200.10
...
[root@master ~]# service network restart
//添加主机映射
[root@master ~]# vi /etc/hosts
192.168.100.10 master
192.168.100.20 node
//更改selinux工作模式
[root@master ~]# vi /etc/selinux/config
SELINUX=disabled
[root@master ~]# setenforce 0
[root@master ~]# getenforce
//关闭防火墙
[root@master ~]# systemctl stop firewalld
[root@master ~]# systemctl disable firewalld
//配置yum源
[root@master ~]# mv /etc/yum.repos.d/* /home/
[root@master ~]# vi /etc/yum.repos.d/docker.repo
[centos]
name=centos
baseurl=file:///optej/centos
gpgcheck=0
enabled=1
[docker]
name=docker
baseurl=file:///opt/kubernetes-repo
gpgcheck=0
enabled=1
[root@master ~]# init 0
========================克隆master为node================
//上传CentOS-7-x86_64-DVD-1804.iso和XianDian-PaaS-v2.4.iso镜像并将挂载复制
[root@master ~]# mkdir /opt/centos
[root@master ~]# mount -o loop /dev/cdrom /mnt/
[root@master ~]# cp -rvf /mnt/* /opt/centos
[root@master ~]# umount /mnt/
[root@master ~]# eject -r /dev/cdrom ##弹出光驱
//在VMware中将镜像换成XianDian-PaaS-v2.4.iso在重新连接
[root@master ~]# mount -o loop /dev/cdrom /mnt/
[root@master ~]# cp -rvf /mnt/* /opt/
[root@master ~]# umount /mnt/
//在VMware中将镜像换回CentOS-7-x86_64-DVD-1804.iso在重新连接
[root@master ~]# yum clean all
[root@master ~]# yum repolist
[root@master ~]# yum list
//安装ftpd
[root@master ~]# yum install vsftpd -y
[root@master ~]# vi /etc/vsftpd/vsftpd.conf
anon_root=/opt/ ##设置共享目录
[root@master ~]# systemctl start vsftpd
[root@master ~]# systemctl enable vsftpd
【node】
//设置主机名(此时master可以开始跑脚本了)
[root@localhost ~]# hostnamectl set-hostname node
[root@localhost ~]# bash
//设置网络
[root@node ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
...
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.100.20
...
[root@node ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
...
BOOTPROTO=static
DEFROUTE=yes
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.200.20
...
[root@node ~]# service network restart
//添加主机映射
[root@node ~]# vi /etc/hosts
192.168.100.10 master
192.168.100.20 node
//更改selinux工作模式
[root@node ~]# vi /etc/selinux/config
SELINUX=disabled
[root@node ~]# setenforce 0
[root@node ~]# getenforce
//关闭防火墙
[root@node ~]# systemctl stop firewalld
[root@node ~]# systemctl disable firewalld
//配置yum源
[root@node ~]# mv /etc/yum.repos.d/* /home/
[root@node ~]# vi /etc/yum.repos.d/docker.repo
[centos]
name=centos
baseurl=ftp://192.168.100.10/centos
gpgcheck=0
enabled=1
[docker]
name=docker
baseurl=ftp://192.168.100.10/kubernetes-repo
gpgcheck=0
enabled=1
//从master节点复制镜像
[root@node ~]# mkdir /opt/centos
[root@node ~]# scp -r 192.168.100.10://opt/* /opt/
[root@node ~]# yum clean all
[root@node ~]# yum repolist
[root@node ~]# yum list
执行PaaS脚本
访问地址:http://192.168.100.10
仓库地址:192.168.100.10
用户名:admin
密码:Harbor12345
【master】
[root@master ~]# cd /opt/
[root@master ~]# ./k8s_harbor_install.sh
[root@master ~]# ./k8s_image_push.sh
[root@master ~]# ./k8s_master_install.sh
//执后会访问192.168.100.10:30000使用token登录即可
【node】
[root@node ~]# cd /opt/
[root@node ~]# ./k8s_node_install.sh
更多推荐
已为社区贡献4条内容
所有评论(0)