Openstack(N版)

      ---openstack基础及其RabbitMQ

openstack介绍:

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

1、openstack是开源的。Openstack是云平台管理的项目。

2、Openstack四个最基本的项目:

1Openstack Dashboardweb的一个管理界面,可以通过它去管理openstack

2Computeopenstack中用于计算的项目。

3Networkingopenstack中网络项目。

4Storageopenstack中存储的项目。

3、Openstack管理了三大资源池:

Compute(计算资源,主要通过kvm管理虚拟机)、networking(通过管理IP地址、路由、网关等)、

Storageopenstack管理云硬盘)

Ps这三个资源池通过对外提供APIDashboard通过API来访问openstack

4、openstack组件:

HorizonPython编写的单独web界面)、Nova(计算使用)、Neutron(管理网络使用)、Swift(对象存储)、Glance(镜像服务)、keystone(即管理认证服务,又管理服务的注册)、Cinder(为虚拟机提供块存储)、Cellometer(做各个服务及虚拟机监控使用)、Heat(做编排的)、TroveSahara(数据和大数据)、

wKiom1lDPnGz-4eZAAFEBuqoEUQ889.png-wh_50

5、openstack版本历史:

wKiom1lDPpHxEcZvAAFOpFQDk5A799.png-wh_50

6opens tack支持好几种消息队列服务包括:RabbitmqOpidZeroMQopenstack默认用到的消息队列是RabbitMQ。如果RabbitMQ掉,会造成虚拟机无法创建。

7RabbitMQ分布式消息队列、通信枢纽、支持集群。

8、除了Horizonopenstack其他组件都需要连接数据库,除了HorizoneKeyStone,其他组件都需要连接RabbitMQ.

9openstack

wKiom1lDPrCR0obTAAJecui9o1A782.png-wh_50

Openstack环境部署及RabbitMQ

 

RabbitMQ介绍:

Rabbitmq是一套用erlang语言基于AMQP协议开发的,可复用的企业消息系统,它遵循Mozilla public license开源协议。

 

操作系统:Centos 7.2

IP地址:192.168.56.11

192.168.56.12

详细请参考:官方网站。

在生产环境下openstack,需要有ntp时间服务器,保证时间的同步。

node1node2上都安装:

1、生产环境中,需要有ntp时间服务器,在这里没有时间服务器,就自己yum安装一个ntpdate服务 :

yum -y install ntpdate

wKioL1lDPtGSiHXjAAAtatjekqE723.png-wh_50

ntpdate time1.aliyun.com

2、安装仓库:

yum install centos-release-openstack-newton

3、安装openstack客户端:

yum -y install python-openstackclient

yum install openstack-selinux

4、由于Python访问MySQL的模块,需要安装:

yum install mariadb mariadb-server python2-PyMySQL

 

node1上安装如下:

5、安装数据库:

yum install mariadb mariadb-server python2-PyMySQL

PsPython访问MySQL的模块

6、由于在/etc/my.cnf中,只要把配置文件写在includedir的目录里就可以,也是为了看上去不会太乱,方便管理。在node1/etc/my.cnf.d下创建一个openstack.cnf

vim openstack.cnf

 

[mysqld]

bind-address = 192.168.56.11

 

default-storage-engine = innodb

innodb_file_per_table

max_connections = 4096

collation-server = utf8_general_ci

character-set-server = utf8

7、安装消息对列:(如果生产环境比较大,rabbitmq需要独立的物理机做集群)

yum -y install rabbitmq-server

8、安装keystone认证

yum -y install openstack-keystone httpd mod_wsgi

注意:httpd会使用mod_wsgi模块和openstack-keystone进行通信

9、安装glance镜像安装包:

yum install openstack-glance

10、安装Nova的控制节点安装包:

yum install openstack-nova-api openstack-nova-conductor \

  openstack-nova-console openstack-nova-novncproxy \

  openstack-nova-scheduler 

 

Psopenstack-nova-api(如果nova访问不了,则openstack-nova-api挂了)openstack-nova-conductor(数据的中间件,如果数据库访问不了,则conductor挂了)、openstack-nova-console(控制界面)、openstack-nova-novncproxy(代理,如果web界面打不开则novncproxy挂了)、openstack-nova-scheduler(调度,如果创建不了虚拟机,则openstack-nova-scheduler挂了)

11、安装网络的控制节点包:

yum install openstack-neutron openstack-neutron-ml2 \

  openstack-neutron-linuxbridge ebtables

12、启动mariadb服务并设为开机自启动:

systemctl enable mariadb.service

systemctl start mariadb.service

wKiom1lDPvDweHC1AAAUVXQb6ds147.png-wh_50

13、安全初始化数据库

mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):     #### 回车

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

Set root password? [Y/n] y     ####设置root密码

New password:              ####输入密码

Re-enter new password:        ####再次输入密码

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y      ####是否去除匿名用户

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] y    ####是否禁止root用于远程登陆

 ... Success!

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y     ####是否删除测试使用的数据库

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y         ####是否reload授权表

 ... Success!

 

Cleaning up...

 

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB!

14、启动rabbitmq服务并设置开机自启动:

systemctl enable rabbitmq-server.service

systemctl start rabbitmq-server.service

wKiom1lDP8KgDEsLAAAWML8JvHo782.png-wh_50

15、添加openstack用户(需要连接opens tack消息队列就需要有用户)

rabbitmqctl add_user openstack openstack用户名和密码都是opens tack

wKiom1lDP9SyTS_bAAAJFWEEnxg427.png-wh_50

16、opens tack配置读写的权限:

rabbitmqctl set_permissions openstack ".*" ".*" ".*"

Psrabbitmq默认有一个web的监控的插件,如何查看这些插件。

wKiom1lDP-yxx4MMAAALNkyLreY799.png-wh_50

17、查看rabbitmqweb的所有插件:

rabbitmq-plugins list

18、启动rabbitmq  web插件:(rabbitmq_management这个插件可以启动一个web界面让我们去管理rabbitmq

rabbitmq-plugins enable rabbitmq_management

19、查看端口:

lsof -i:15672 

wKiom1lDQATA19IXAAASpubwKU0128.png-wh_50

Ps:可以看到已经监听。

访问rabbitmq,可以正常访问。

wKioL1lDQBiAatWmAAAq2NHqFSg087.png-wh_50

由于openstack用户不是超级管理员,不能登录web界面,需要使用guest用户。

用户名:guest   密码:guest

wKioL1lDQDPyNecMAABzlbh7mxY357.png-wh_50

登录后的rabbitmq界面,如何更改openstack呢?

点击Admin,再点击openstack就可以修改。

wKioL1lDQE3RfRcWAABXxkK7Dkw952.png-wh_50

简单的搭建已经完毕了,下面我们来学习openstack的认证服务Keystone