根据上一篇的环境已经创建安装成功,下面开始正式进入我们的搭建环节
使用的secure CRT仿真终端,方便,优秀的工具
配置linux 和secure CRT 连接参考博客
https://blog.csdn.net/qq_28513801/article/details/90138255
我们首先进去查看下有几块网卡 并进行配置:
关于网卡的配置文件详解 请查看这个博客
https://blog.csdn.net/qq_28513801/article/details/90138255
开始配置我们的网卡
[root@controller ~]# hostnamectl set-hostname controller
[root@controller ~]# bash
[root@controller ~]# hostnamectl
Static hostname: controller
Icon name: computer-vm
Chassis: vm
Machine ID: b9c2ba6d4bb243b0a22f2a587377b60f
Boot ID: 8696cb44ea7b419ea0414ec8e03439cf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@controller ~]#
[root@compute ~]# hostnamectl set-hostname compute
[root@compute ~]# bash
[root@compute ~]# hostnamectl
Static hostname: compute
Icon name: computer-vm
Chassis: vm
Machine ID: b9c2ba6d4bb243b0a22f2a587377b60f
Boot ID: 5d08a503864e40939547c42c3da2550d
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@compute ~]#
接下来修改网络配置文件
[root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=3187fdb6-d885-4f5d-8e54-009c69cc167f
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.100.10
GATEWAY=192.168.100.1
NETMASK=255.255.255.0
[root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=bba8bd7a-a7bb-429d-8ab0-8c4272f791ef
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.200.10
NETMASK=255.255.255.0
########################这里一定要记住 第二块网卡 一定不能配置网关
同理compute 节点也是一样
[root@compute ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=3187fdb6-d885-4f5d-8e54-009c69cc167f
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.100.20
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
[root@compute ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=bba8bd7a-a7bb-429d-8ab0-8c4272f791ef
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.200.20
NETMASK=255.255.255.0
[root@controller ~]# systemctl restart network
[root@compute ~]# systemctl restart network
这里要先把我们的centos和iaas镜像上传至我们的linux虚拟机中
创建两个文件夹
[root@controller opt]# mkdir centos iaas
[root@controller opt]# ls
centos CentOS-7-x86_64-DVD-1511.iso iaas XianDian-IaaS-v2.2.iso
[root@controller opt]#
配置映射文件
[root@controller centos]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.10 controller
192.168.100.20 compute
同理另外一个节点也要配置
#Controller和compute节点
(1)由于实验环境直接把
(2)创建repo文件
【controller】
在/etc/yum.repos.d创建centos.repo源文件
[root@controller ~]# cd /etc/yum.repos.d/
[root@controller yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@controller yum.repos.d]# rm -rf *
[root@controller yum.repos.d]# vi local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=centos
baseurl=file:///opt/iaas/iaas-repo
gpgcheck=0
enabled=1
然后把镜像挂载到/mnt/并复制到指定的目录/opt/centos/
[root@controller opt]# mount -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
[root@controller opt]# cp -rvf /mnt/* /opt/centos/
[root@controller opt]# umount /mnt/
[root@controller opt]# mount -o loop
centos/ CentOS-7-x86_64-DVD-1511.iso iaas/ XianDian-IaaS-v2.2.iso
[root@controller opt]# mount -o loop XianDian-IaaS-v2.2.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
[root@controller opt]# cp -rvf /mnt/* /opt/iaas/
在compute节点 配置yum文件
[root@compute opt]# ls
[root@compute opt]# rm -rf /etc/yum.repos.d/*
[root@compute opt]# vi /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=ftp://192.168.100.10/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://192.168.100.10/iaas/iaas-repo
gpgcheck=0
enabled=1
(3)关闭防火墙和设置selinux
[root@controller centos]# systemctl stop firewalld
[root@controller centos]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@controller centos]#
[root@controller centos]# setenforce 0
[root@controller centos]# getenforce
Permissive
[root@controller centos]#
[root@compute opt]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@compute opt]# systemctl stop firewalld
[root@compute opt]# setenforce 0
[root@compute opt]# getenforce
Permissive
[root@compute opt]#
(4)在controller节点搭建ftp服务器,并把opt目录作为ftp目录的共享根目录(修改ftp配置文件)
[root@controller centos]# yum install -y vsftpd
Loaded plugins: fastestmirror
centos | 3.6 kB 00:00:00
iaas
(1/3): centos/group_gz | 155 kB 00:00:00
(2/3): iaas/primary_db | 2.3 MB 00:00:00
(3/3): centos/primary_db | 2.8 MB 00:00:00
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-11.el7_2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
vsftpd x86_64 3.0.2-11.el7_2 iaas 167 k
Transaction Summary
=================================================================================================================================================
Install 1 Package
Total download size: 167 k
Installed size: 347 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vsftpd-3.0.2-11.el7_2.x86_64 1/1
Verifying : vsftpd-3.0.2-11.el7_2.x86_64 1/1
Installed:
vsftpd.x86_64 0:3.0.2-11.el7_2
Complete!
[root@controller centos]#
[root@controller centos]# vi /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
anon_root=/opt/
#
# The default compiled in settings
##########重启vsftpd服务
[root@controller centos]# systemctl restart vsftpd
[root@controller centos]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@controller centos]#
`
(5)清除缓存,验证yum源
[root@controller centos]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos iaas
Cleaning up everything
Cleaning up list of fastest mirrors
[root@controller centos]# yum list
Loaded plugins: fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/3): centos/group_gz | 155 kB 00:00:00
(2/3): centos/primary_db | 2.8 MB 00:00:00
(3/3): iaas/primary_db | 2.3 MB
···········
··········
[root@compute opt]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos iaas
Cleaning up everything
[root@compute opt]# yum list
Loaded plugins: fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/3): centos/group_gz | 155 kB 00:00:00
(2/3): iaas/primary_db | 2.3 MB 00:00:00
(3/3): centos/primary_db | 2.8 MB 00:00:00
Determining fastest mirrors
···········
···········
·······
[root@compute opt]#
# controller和compute节点
# yum install iaas-xiandian -y
[root@controller centos]# yum install -y iaas-xiandian
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package iaas-xiandian.x86_64 0:2.2-0 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
iaas-xiandian x86_64 2.2-0 iaas 22 k
Transaction Summary
=================================================================================================================================================
Install 1 Package
Total download size: 22 k
Installed size: 93 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : iaas-xiandian-2.2-0.x86_64 1/1
Verifying : iaas-xiandian-2.2-0.x86_64 1/1
Installed:
iaas-xiandian.x86_64 0:2.2-0
Complete!
[root@controller centos]#
编辑文件/etc/xiandian/openrc.sh,此文件是安装过程中的各项参数,根据每项参数上一行的说明及服务器实际情况进行配置。
############这里配置完后 可以使用sed 命令进行过滤 去除每行开头的#号
##可使用cat openrc.sh | sed "s/.//" > openrc.sh 去掉注释#)
##然后使用scp命令发送到另一个节点
###scp openrc.sh root@compute:/etc/xiandian
###这里是配置文件
[root@controller centos]# vi /etc/xiandian/openrc.sh
##--------------------system Config--------------------##
..........
.........
HOST_IP=192.168.100.10
HOST_NAME=controller
HOST_IP_NODE=192.168.100.20
HOST_NAME_NODE=compute
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_NAME=enp0S8(外网网卡名)
CINDER_DBPASS=000000
CINDER_PASS=000000
TROVE_DBPASS=000000
TROVE_PASS=000000
BLOCK_DISK=md126p4(空白分区名)
SWIFT_PASS=000000
OBJECT_DISK=md126p5(空白分区名)
STORAGE_LOCAL_NET_IP=192.168.100.20
HEAT_DBPASS=000000
HEAT_PASS=000000
CEILOMETER_DBPASS=000000
CEILOMETER_PASS=000000
AODH_DBPASS=000000
AODH_PASS=000000
针对于上述空白分区可采用linux老牌的分区工具fdisk或者使用parted命令
CentOS7的安装与CentOS6.5的安装有明显的区别。在CentOS7安装过程中,设置分区都需要一个挂载点,这样一来就无法创建两个空白的磁盘分区作为cinder服务和swift服务的存储磁盘了。
所以我们应该在系统安装过程中留下足够的磁盘大小,系统安装完成后,使用命令parted划分新分区,然后使用mkfs.xfs进行文件系统格式化,完成空白分区的划分。具体命令如下:
[root@compute ~]# parted /dev/md126
(parted) mkpart swift 702G 803G //创建swift分区,从702G到803G
[root@compute ~]# mkfs.xfs /dev/md126p5
基本环境配置完成后开始安装我们的服务。将会在下一篇博客写出
最好先熟悉shell编程和openstack基础配置命令