Centos 7 搭建OpenStack 私有云——(1)基础环境配置

1.简介:

    OpenStack是一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目。
  OpenStack是一个开源的云计算管理平台项目,由几个主要的组件组合起来完成具体工作。OpenStack支持几乎所有类型的云环境,项目目标是提供实施简单、可大规模扩展、丰富、标准统一的云计算管理平台。OpenStack通过各种互补的服务提供了基础设施即服务(IaaS)的解决方案,每个服务提供API以进行集成。

2.环境准备:

openstack-node1 172.30.10.9
openstack-node2 172.30.10.11

域名解析:
/etc/hosts
172.30.10.9 openstack-node1
172.30.10.11 openstack-node2

关闭selinux:
vi /etc/sysconfig/selinux
SELINUX=disabled

setenforce 0

关闭iptables:
systemctl stop firewalld.service
systemctl disable firewalld.service

3.安装配置OpenStack:

3.1 安装软件包

openstack-node1

*****************************************************************************************

# Base
yum install -y http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
yum install -y centos-release-openstack-liberty
yum install -y python-openstackclient

# Mysql
# 在Centos7中mysql改名为mariadb
yum install -y mariadb mariadb-server MySQL-python

# RabbitMQ
yum install -y rabbitmq-server

# Keystone
yum install -y openstack-keystone httpd mod_wsgi memcached python-memcached

# Glance
yum install -y openstack-glance python-glance python-glanceclient

# Nova
yum install -y openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler python-novaclient

# Neutron
yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge python-neutronclient ebtables ipset

# Dashboard
yum install -y openstack-dashboard

# Cinder
yum install -y openstack-cinder python-cinderclient

openstack-node2

*****************************************************************************************

# Base
yum install -y http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
yum install centos-release-openstack-liberty
yum install python-openstackclient
		
# Nova 
yum install -y openstack-nova-compute sysfsutils
		
# Neutron 
yum install -y openstack-neutron openstack-neutron-linuxbridge ebtables ipset
		
# Cinder
yum install -y openstack-cinder python-cinderclient targetcli python-oslo-policy

3.2 时间同步

在openstack-node1上配置:(centos7用chrony,centos6用ntp)

# 安装chrony
[root@openstack-node1 ~]#yum install -y chrony
		
# 配置chrony
[root@openstack-node1 ~]#vi /etc/chrony.conf
# 允许哪些服务器和自己同步
allow 172.30/16 
		
# 设置服务开机启动
[root@openstack-node1 ~]#systemctl enable chronyd.service
[root@openstack-node1 ~]#systemctl start chronyd.service
[root@openstack-node1 ~]#timedatectl set-timezone Asia/Shanghai
[root@openstack-node1 ~]#timedatectl status

在openstack-node2上配置:

# 安装chrony
[root@openstack-node2 ~]#yum install -y chrony
		
# 配置chrony
[root@openstack-node2 ~]#vi /etc/chrony.conf
#只保留一行
server 172.30.10.9 iburst 
		
# 设置服务开机启动
[root@openstack-node2 ~]#systemctl enable chronyd.service
[root@openstack-node2 ~]#systemctl start chronyd.service
[root@openstack-node2 ~]#timedatectl set-timezone Asia/Shanghai
[root@openstack-node2 ~]#chronyc sources

3.3 配置mysql

修改配置文件,并初始化mysql

[root@openstack-node1 ~]#cp /usr/share/mariadb/my-medium.cnf /etc/my.cnf
[root@openstack-node1 ~]#vi /etc/my.cnf
# 在[mysqld]下添加下面的参数
[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8

# 设置开机启动
[root@openstack-node1 ~]#systemctl enable mariadb.service
[root@openstack-node1 ~]#ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

# 初始化数据库
[root@openstack-node1 ~]#mysql_install_db --datadir="/var/lib/mysql" --user="mysql"
# 启动mysql
[root@openstack-node1 ~]#systemctl start mariadb.service
# 设置密码及初始化
[root@openstack-node1 ~]#mysql_secure_installation

创建数据库

[root@openstack-node1 ~]#mysql -u root -p
# 创建keystone库,并授权
MariaDB [(none)]> create database keystone;
MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'172.30.10.9' identified by 'keystone';
MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'%' identified by 'keystone';
	
# 创建glance库,并授权
MariaDB [(none)]> create database glance;
MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'172.30.10.9' identified by 'glance';  
MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'%' identified by 'glance';
	
# 创建nova库,并授权 
MariaDB [(none)]> create database nova; 
MariaDB [(none)]> grant all privileges on nova.* to 'nova'@'%' identified by 'nova';
MariaDB [(none)]> grant all privileges on nova.* to 'nova'@'172.30.10.9' identified by 'nova';
	
# 创建neutron库,并授权
MariaDB [(none)]> create database neutron;
MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'172.30.10.9' identified by 'neutron';
MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron';

# 创建cinder库,并授权
MariaDB [(none)]> create database cinder;
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'%' identified by 'cinder';
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'172.30.10.9' identified by 'cinder';

# 刷新数据库
MariaDB [(none)]> flush privileges;
# 查看数据库列表  
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| cinder             |
| glance             |
| information_schema |
| keystone           |
| mysql              |
| neutron            |
| nova               |
| performance_schema |
+--------------------+
8 rows in set (0.00 sec)

3.4 安装配置rabbitmq

MQ 全称 Message Queue,消息队列(MQ)是一种应用程序对应用程序的通信方法。应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。消息传递指的是程序之间通过在消息中发送数据进行通信,而不是通过直接调用彼此来通信,直接调用通常是用于诸如远程过程调用的技术。排队指的是应用程序通过队列来通信。队列的使用出去了接收和发送应用程序同时执行的要求。RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统。他遵循Mozilla Public License开源协议。

启动rabbitmq,端口5672,添加openstack用户

# 启动rabbitmq,端口5672,添加openstack用户
[root@openstack-node1 lib]# systemctl enable rabbitmq-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@openstack-node1 lib]# ln -s '/usr/lib/systemd/system/rabbitmq-server.service''/etc/systemd/system/multi-user.target.wants/rabbitmq-server.service'
[root@openstack-node1 lib]# systemctl start rabbitmq-server.service 

# 添加用户名和密码
[root@openstack-node1 lib]# rabbitmqctl add_user openstack openstack
Creating user "openstack" ...
# 允许openstack用户配置、写、读访问
[root@openstack-node1 lib]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...

# 查看支持的插件
[root@openstack-node1 lib]# rabbitmq-plugins list
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status:   * = running on rabbit@openstack-node1
 |/
[  ] amqp_client                       3.6.5
[  ] cowboy                            1.0.3
[  ] cowlib                            1.0.1
[  ] mochiweb                          2.13.1
[  ] rabbitmq_amqp1_0                  3.6.5
[  ] rabbitmq_auth_backend_ldap        3.6.5
[  ] rabbitmq_auth_mechanism_ssl       3.6.5
[  ] rabbitmq_consistent_hash_exchange 3.6.5
[  ] rabbitmq_event_exchange           3.6.5
[  ] rabbitmq_federation               3.6.5
[  ] rabbitmq_federation_management    3.6.5
[  ] rabbitmq_jms_topic_exchange       3.6.5
[  ] rabbitmq_management               3.6.5
[  ] rabbitmq_management_agent         3.6.5
[  ] rabbitmq_management_visualiser    3.6.5
[  ] rabbitmq_mqtt                     3.6.5
[  ] rabbitmq_recent_history_exchange  1.2.1
[  ] rabbitmq_sharding                 0.1.0
[  ] rabbitmq_shovel                   3.6.5
[  ] rabbitmq_shovel_management        3.6.5
[  ] rabbitmq_stomp                    3.6.5
[  ] rabbitmq_top                      3.6.5
[  ] rabbitmq_tracing                  3.6.5
[  ] rabbitmq_trust_store              3.6.5
[  ] rabbitmq_web_dispatch             3.6.5
[  ] rabbitmq_web_stomp                3.6.5
[  ] rabbitmq_web_stomp_examples       3.6.5
[  ] sockjs                            0.3.4
[  ] webmachine                        1.10.3

# 使用此插件实现web管理
[root@openstack-node1 lib]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management
Applying plugin configuration to rabbit@openstack-node1... started 6 plugins.

# 重启rabbitmq服务
[root@openstack-node1 lib]# systemctl restart rabbitmq-server.service
[root@openstack-node1 lib]# lsof -i:15672
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
beam    33692 rabbitmq   49u  IPv4  80606      0t0  TCP *:15672 (LISTEN)

访问rabbitMQ,访问地址http://172.30.10.9:15672 默认用户名密码都是guest
1.点击Admin,创建openstack用户密码
2.点击用户名openstack,在“Update this user”菜单中输入密码及标签(administrator)
3.登出当前用户,使用openstack登录,测试是否创建成功


* 如何使用zabbix监控,可以点击左下角HTTP API的介绍

到这所有基础环境的配置就算完成了,接下来开始安装openstack组件。

posted @ 2017-04-28 17:26  Bourbon.Tian  阅读(2426)  评论(0编辑  收藏  举报