• 实验环境准备
    两台电脑:controller、compute
    操作系统:centos7
    硬件配置:64G运行内存,500G硬盘,2张网卡(以机房服务器为例)
    软件选择:CentOS 7 带开发工具最小安装

CentOS 7最小安装部署OpenStack Queens版本(环境搭建)_第1张图片

CentOS 7最小安装部署OpenStack Queens版本(环境搭建)_第2张图片

  • 基本环境配置
    1.设置主机名
    1.1 controller 节点
    #hostnamectl set-hostname controller
    #logout  重登录

    1.2 compute 节点

    #hostnamectl set-hostname compute
    #logout

    2.主机联网
    2.1 controller 节点

    #vi /etc/sysconfig/network-scripts/ifcfg-enp3s0  //配置网卡用作外网连接

BOOTPROTO=static
ONBOOT=yes
IPADDR=172.31.1.25
GATEWAY=172.31.1.1
NETMASK=255.255.255.0
DNS1=202.196.80.1
DNS2=8.8.8.8

#vi /etc/sysconfig/network-scripts/ifcfg-enp4s0f0   //内网连接

BOOTPROTO=static
ONBOOT=yes
IPADDR=172.31.0.25
NETMASK=255.255.255.0
DNS1=202.196.80.1
DNS2=8.8.8.8

2.2 compute 节点

#vi /etc/sysconfig/network-scripts/ifcfg-enp3s0 

BOOTPROTO=static
ONBOOT=yes
IPADDR=172.31.1.26
GATEWAY=172.31.1.1
NETMASK=255.255.255.0
DNS1=202.196.80.1
DNS2=8.8.8.8

#vi /etc/sysconfig/network-scripts/ifcfg-enp4s0f0

BOOTPROTO=static
ONBOOT=yes
IPADDR=172.31.0.26
NETMASK=255.255.255.0
DNS1=202.196.80.1
DNS2=8.8.8.8

2.3检查网络连接、各节点的连通性

#service network restart          
#ping www.baidu.com           
#ping 172.31.1.26                      
#ping 172.31.0.26                     
#ping 172.31.1.25                    
#ping 172.31.0.25                    

3.防火墙(所有节点)

#systemctl disable firewalld    //关闭开机自启
#systemctl stop firewalld      //关闭防火墙

4.域名解析(所有节点)

#vi /etc/hosts  添加ip地址和域名

172.31.1.25 controller
172.31.1.26 compute

5.yum源(所有节点)

#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#yum makecache
#yum -y update
#yum clean all                     //更换为阿里yum源,创建缓存

6.网络时间协议(NTP)
6.1 controller 节点

#yum -y install chrony         //安装时钟服务
#vi /etc/chrony.conf

server controller iburst //所有节点时间与controller同步
allow 172.31.0.0/24 //设置允许同步的网段

#systemctl enable chronyd.service   //开机自启
#systemctl start chronyd.service       //启动时间同步

6.2 compute 节点

#yum -y install chrony
#vi /etc/chrony.conf

server controller iburst

#systemctl enable chronyd.service
#systemctl start chronyd.service

7.OpenStack软件包(所有节点)

#yum install centos-release-openstack-queens        //安装Queens版本
#yum upgrade                                                           //升级软件包
#yum install python-openstackclient                         //安装openstack客户端
#yum install openstack-selinux   //安装 openstack-selinux软件包管理服务安全策略

8.SQL数据库 (controller节点)

#yum install mariadb mariadb-server pyrhon2-PyMySQL  //安装mariadb数据库
#cat /etc/my.cnf.d/openstack.cnf 
#vi /etc/my.cnf.d/openstack.cnf  //创建并编辑该/etc/my.cnf.d/openstack.cnf文件

[mysqld]
bind-address = 172.31.1.25
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

#systemctl enable mariadb.service
#systemctl start mariadb.service          //启动数据库
#mysql_secure_installation                   //给数据库设置密码

9.消息队列(controller节点)

#yum install rabbitmq-server                 
#systemctl enable rabbitmq-server.service
#systemctl start rabbitmq-server.service

   消息队列的相关配置

#rabbitmqctl add_user openstack RABBIT_PASS     //添加openstack用户
    运行出现:Creating user "openstack" ...
#rabbitmqctl set_permissions openstack ".*" ".*" ".*"    //允许用户进行读写配置
    运行出现:Setting permissions for user "openstack" in vhost "/" ...

10.Memcached缓存令牌(controller节点)

#yum install memcached python-memcached 
#vi /etc/sysconfig/memcached       //将原来代码改为如下代码

OPTIONS="-l 127.0.0.1,::1,controller"
   

#systemctl enable memcached.service
#systemctl start memcached.service  //启动Memcached服务

11.ETCD键值存储(controller节点)

#yum install etcd
#vi /etc/etcd/etcd.conf

设置ETCD_INITIAL_CLUSTER, ETCD_INITIAL_ADVERTISE_PEER_URLS,ETCD_ADVERTISE_CLIENT_URLS, ETCD_LISTEN_CLIENT_URLS控制器节点,以使经由管理网络通过其他节点的访问的管理IP地址

#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://172.31.1.25:2380"
ETCD_LISTEN_CLIENT_URLS="http://172.31.1.25:2379"
ETCD_NAME="controller"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.31.1.25:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://172.31.1.25:2379"
ETCD_INITIAL_CLUSTER="controller=http://172.31.1.25:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"

#systemctl enable etcd
#systemctl start etcd    //启动etcd服务