一、基本环境配置

1.1安装CentOS7说明

  【CentOS7版本】

CentOS7系统选择1804版本:CentOS-7-x86_64-DVD-1804.iso

  【添加磁盘】

添加两个空白的磁盘作为cinder服务和swift服务的存储磁盘

fdisk /dev/sdb
n
p


w
fdisk /dev/sdc
n
p


w

lsblk

1.2配置网络、主机名

修改和添加/etc/sysconfig/network-scripts/ifcfg-enp*(具体的网口)文件。

(1)controller节点

配置网络:

# 修改网络配置
vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" # 此处将dhcp修改为static或none
...
...
ONBOOT="yes"
# 添加如下IP、掩码、网关、DNS
IPADDR=192.168.100.10
PREFIX=24
GATEWAY=192.168.100.2
DNS1=114.114.114.114

配置主机名:

hostnamectl set-hostname controller

按ctrl+d 退出  重新登陆

(2)compute 节点

配置网络:

# 修改网络配置
vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" # 此处将dhcp修改为static或none
...
...
ONBOOT="yes"
# 添加如下IP、掩码、网关、DNS
IPADDR=192.168.100.20
PREFIX=24
GATEWAY=192.168.100.2
DNS1=114.114.114.114

配置主机名:

hostnamectl set-hostname compute

按ctrl+d 退出  重新登陆

1.3配置yum源

#Controller和compute节点

使用SCP工具将centos和iaas镜像上传到控制节点/root目录下

[root@controller ~]# pwd
/root
[root@controller ~]# ls
CentOS-7-x86_64-DVD-1804.iso  chinaskills_cloud_iaas.iso

(1)yum源备份

cd /etc/yum.repos.d/
mkdir /backup
mv -v * /backup

(2)创建repo文件

【controller】

在/etc/yum.repos.d创建centos.repo源文件

vim centos.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas-repo
gpgcheck=0
enabled=1

【compute】

在/etc/yum.repos.d创建centos.repo源文件

vim centos.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-repo
gpgcheck=0
enabled=1

3)挂载iso文件

【挂载CentOS-7-x86_64-DVD-1804.iso】

mount -o loop CentOS-7-x86_64-DVD-1804.iso  /mnt/
mkdir /opt/centos
cp -rvf /mnt/* /opt/centos/
umount  /mnt/

【挂载XianDian-IaaS-v2.4.iso】

mount -o loop XianDian-IaaS-v2.4.iso  /mnt/
cp -rvf /mnt/* /opt/
umount  /mnt/

4)搭建ftp服务器,开启并设置自启

yum install vsftpd -y
vim /etc/vsftpd/vsftpd.conf
# 添加anon_root=/opt/
# 保存退出
systemctl start vsftpd
systemctl enable vsftpd

5配置防火墙和Selinux

【controller/compute】

编辑selinux文件

vi /etc/selinux/config
# 修改SELINUX=
SELINUX=permissive

关闭防火墙并设置开机不自启

systemctl stop firewalld.service
systemctl disable firewalld.service
yum remove -y NetworkManager firewalld
yum -y install iptables-services
systemctl enable iptables
systemctl restart iptables
iptables -F
iptables -X
iptables -Z
service iptables save

(6)清除缓存,验证yum源

【controller/compute】

yum clean all
yum list

1.4编辑环境变量

# controller和compute节点

yum install iaas-xiandian -y

编辑文件/etc/xiandian/openrc.sh,此文件是安装过程中的各项参数,根据每项参数上一行的说明及服务器实际情况进行配置。

vim /etc/xiandian/openrc.sh
HOST_IP=192.168.100.10
HOST_PASS=000000
HOST_NAME=controller
HOST_IP_NODE=192.168.100.20
HOST_PASS_NODE=000000
HOST_NAME_NODE=compute
network_segment_IP=192.168.100.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.100.10/192.168.100.20(controllerIP/computeIP)
INTERFACE_NAME=ens32(外部网络网卡名称)
Physical_NAME=provider(外部网络适配器名称)
minvlan=101 (vlan网络范围的第一个vlanID)
maxvlan=200 (vlan网络范围的最后一个vlanID)
CINDER_DBPASS=000000
CINDER_PASS=000000
BLOCK_DISK=sdb1 (空白分区)
SWIFT_PASS=000000
OBJECT_DISK=sdc1 (空白分区)
STORAGE_LOCAL_NET_IP=192.168.100.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

1.5通过脚本安装服务

1.6-1.8的基础配置操作命令已经编写成shell脚本,通过脚本进行一键安装。如下:

# Controller节点和Compute节点

执行脚本iaas-pre-host.sh进行安装

iaas-pre-host.sh
# 安装完成后同时重启
reboot

1.6安装Openstack包

# controller和compute节点

yum -y install openstack-utils openstack-selinux python-openstackclient
yum upgrade

1.7配置域名解析

修改/etc/hosts添加一下内容

controller 节点和compute 节点

vim /etc/hosts
# 添加以下内容
192.168.100.10 controller
192.168.100.20 compute

1.8安装chrony服务

(1)controller和compute节点

yum install -y chrony

(2)配置controller节点

编辑/etc/chrony.conf文件

添加以下内容(删除默认sever规则)

vim /etc/chrony.conf
server controller iburst
allow 192.168.100.0/24
local stratum 10

启动ntp服务器

systemctl restart chronyd
systemctl enable chronyd

(3)配置compute节点

编辑/etc/chrony.conf文件

添加以下内容(删除默认sever规则)

server controller iburst

启动ntp服务器

systemctl restart chronyd
systemctl enable chronyd

1.9通过脚本安装数据库服务

1.10-1.13基础服务的操作命令已经编写成shell脚本,通过脚本进行一键安装。如下:

# Controller节点

执行脚本iaas-install-mysql.sh进行安装

iaas-install-mysql.sh

1.10安装Mysql数据库服务

(1)安装mysql服务

# yum install -y mariadb mariadb-server python2-PyMySQL

(2)修改mysql配置文件参数

修改 /etc/my.cnf文件[mysqld]中添加

max_connections=10000

default-storage-engine = innodb

innodb_file_per_table

collation-server = utf8_general_ci

init-connect = 'SET NAMES utf8'

character-set-server = utf8

(3)启动服务

#systemctl enable mariadb.service

#systemctl start mariadb.service

(4)修改/usr/lib/systemd/system/mariadb.service文件参数

[Service]

新添加两行如下参数:

LimitNOFILE=10000

LimitNPROC=10000

(5)修改/etc/my.cnf.d/auth_gssapi.cnf文件参数

[mariadb]

注释一行参数

#plugin-load-add=auth_gssapi.so

(6)重新加载系统服务,并重启mariadb服务

# systemctl daemon-reload

# service mariadb restart

(7)配置Mysql

# mysql_secure_installation

按enter确认后设置数据库root密码

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] n

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

8)compute节点

#yum -y install  MySQL-python

1.11安装RabbitMQ服务

# yum install -y rabbitmq-server

# systemctl enable rabbitmq-server.service

# systemctl restart rabbitmq-server.service

# rabbitmqctl add_user $RABBIT_USER $RABBIT_PASS

# rabbitmqctl set_permissions $RABBIT_USER ".*" ".*" ".*"

1.12安装memcahce服务

# yum install memcached python-memcached

# systemctl enable memcached.service

# systemctl restart memcached.service

1.13 安装etcd服务

# yum install etcd –y

(1)修改/etc/etcd/etcd.conf配置文件,添加以下内容:

ETCD_LISTEN_PEER_URLS="http://192.168.100.10:2380"

ETCD_LISTEN_CLIENT_URLS="http://192.168.100.10:2379"

ETCD_NAME="controller"

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.10:2380"

ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.10:2379"

ETCD_INITIAL_CLUSTER="controller=http://192.168.100.10:2380"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"

ETCD_INITIAL_CLUSTER_STATE="new"

(2)启动服务

# systemctl start etcd

# systemctl enable etcd

posted @ 2022-09-19 20:48  CharlieBrown  阅读(130)  评论(0编辑  收藏  举报
标题