OpenStack----概述与环境部署

一、云计算服务模型

  • IaaS(基础架构即服务)
    ①提供底层IT基础设施服务,包括处理能力、存储空间、网络资源等
    ②面向对象一般是IT管理人员

  • PaaS (平台即服务)
    ①把安装好开发环境的系统平台作为一种服务通过互联网提供给用户
    ②面向对象为 开发人员

  • SaaS (软件即服务)
    ①直接通过互联网为用户提供软件和应用程序等服务
    ②面向对象为 普通用户;例如:LNMP架构,打包成SaaS服务,用户当购买这个服务即拥有LNMP架构

二、OpenStack服务概述

1、 概述

Open(开源)stack(堆叠)一物理设备为基础,以虚拟化的技术将资源分配给不同的用户

  • NASA(美国国家航空航天局)和Rackspace共同发起
  • 以Apache许可证授权的自由软件和开发源代码项目
  • 为共有云私有云的建设与管理提供软件的开源项目
    ①共有云:所有人都能有
    ②私有云:只为企业内部使用,服务器是托管给阿里云组织维护
    ③专有云:也是为了企业内部所使用,使用的服务器是客户自己的服务器
    ④混合云:例如 银行
  • 覆盖了网络、虚拟化、操作系统、服务器等各个方面

2、OpenStack 核心组件

  • 项目名称即核心服务,都是为实例服务的;实例就是虚拟机
  • 项目与项目直接相互隔离的,借助于API对接的方式相互关联
    在这里插入图片描述

3、OpenStack优势

  • 控制性:完全开源的平台,提供API接口,方便与第三方技术集成

  • 兼容性:OpenStack兼容其他公有云,方便用户进行数据迁移

  • 可扩展性:模块化设计,可以通过横向扩展,增加节点、添加资源

  • 灵活性:根据自己的需要建立响应基础设施、增加集群规模

  • 行业标准:众多IT领军企业已经加入到OpenStack项目
    在这里插入图片描述
    云平台用户在经过Keystone服务认证授权后,通过Horizon或者Reset API模式创建虚拟机服务

  • 创建过程中:
    利用Nova服务创建虚拟机实例—>虚拟机实例采用glance提供镜像服务—>使用Neutron为新建的虚拟机分配IP地址,并将其纳入虚拟网络中—>通过Cinder创建的卷为虚拟机挂载存储块,整个过程都在Ceilometer模块资源的监控下,Cinder产生的卷(Volume)和Glance提供的镜像(Image)可以通过。
    Swift 对象存储机制进行保存。

  • 主要组件
    ①全局:Keyston(全局认证)、Ceilometer(监控、计费)、Horizon(控制台)
    ②核心:Nova(计算)、Glance(镜像)、Neutron(网络)、Swift(块存储)、Cinder(对象存储)
    ③支持/辅助:Ironic(裸金属)、Trove(数据库管理)、Hent(数据编排)

4、逻辑架构

  • OpenStack包括若干个称为OpenStack服务的独立组件。所有服务均可通过一个公共身份服务进行身份验证。除了那些需要管理权限的命令,每个服务之间均可通过公共API进行交互
  • 每个OpenStack服务又由若干组件组成,包含多个进程。所有服务至少有一个API进程,用于侦听API请求,对这些请求进行预处理,并将他们传送到该服务的其他组件。除了认证服务,实际工作都是由具体的进程完成的
  • 至于一个服务的进程之间通信,则使用AMQP消息代理,服务的状态存储在数据库中
    在这里插入图片描述
  • 控制节点
    ① 基础服务:全局模块和主要的组件
    ②扩展服务:块、对象数据库的管理和编排
    ③网络接口:负责与别的节点进行通信:例如:ens33、eth0
  • 计算节点
    ①基础服务:
    Nova Hypervisor:指挥compute,实例一般创建在计算节点
    网络插件代理:访问外部网络需要nova通过对应的代理插件操作
    扩展服务:负责收集计算节点
    ②存储节点:
    块、对象存储:对应不同的网络接口连接到其他网络
    ③网络节点:
    内部的通讯,及具有实例通讯规则
    提供者网络:为内部网络提供插件、代理以及功能模块支持;包含ML2插件(即L2交换机)
    自服务网络:用于连接外部;包含三层代理L3Agent(即三层交换机 )

三、部署OpenStack平台基础服务

1、配置操作系统

在这里插入图片描述

2、基础环境配置

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# 
[root@localhost ~]# vi /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 114.114.114.114
[root@ct network-scripts]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomai
192.168.43.100 ct
192.168.43.110 c1
192.168.43.120 c2

三台节点做免交互 (非对称密钥)
ssh-keygen -t rsa
ssh-copy-id ct
ssh-copy-id c1
ssh-copy-id c2
基础环境依赖包
[root@ct network-scripts]# yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre  pcre-devel expat-devel cmake  bzip2 lrzsz
[root@ct network-scripts]# yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils

控制节点ct时间同步配置
ct ->同步阿里云时钟服务器;c1、c2 -> 同步ct
[root@ct network-scripts]# vi /etc/chrony.conf
4 #server 1.centos.pool.ntp.org iburst    #注释掉
5 #server 2.centos.pool.ntp.org iburst    #注释掉
6 #server 3.centos.pool.ntp.org iburst    #注释掉
7 server ntp1.aliyun.com iburst           # 配置阿里云时钟服务器源
8 allow 192.168.43.0/24                   #允许192.168.43.0/24网段的主机来同步时钟服务
[root@ct network-scripts]# systemctl restart chronyd
[root@ct network-scripts]# systemctl enable chronyd
[root@ct network-scripts]# 
[root@ct network-scripts]# chronyc sources   #使用chronyc命令查询时间同步信息
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 120.25.115.20                 2   6    17    39   +599us[ +703us] +/-   18ms

控制节点c1、c2时间同步配置
[root@c1 network-scripts]# vi /etc/chrony.conf
#server 0.centos.pool.ntp.org iburst    #注释掉
#server 1.centos.pool.ntp.org iburst    #注释掉
#server 2.centos.pool.ntp.org iburst     #注释掉
#server 3.centos.pool.ntp.org iburst     #注释掉
server ct  iburst    #配置阿里云时钟服务器源
[root@c1 network-scripts]# systemctl restart chronyd  #重启时间同步服务器
[root@c1 network-scripts]# systemctl enable chronyd    #永久开启时间同步服务器
[root@c1 network-scripts]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* ct                            3   6    17    57  +5755ns[  +73us] +/-   17ms

3、设置周期性计划任务

[root@ct ~]# crontab -e
*/2 * * * * /usr/bin/chronuc  sources >>/var/log/chronyc.log  #配置计划任务,每隔2分钟同步一次

4、系统环境配置

4.1 安装、配置MariaDB

[root@ct ~]#yum -y install mariadb mariadb-server python2-PyMySQL
[root@ct ~]#yum -y install libibverbs
[root@ct ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
	bind-address = 192.168.43.100		##控制节点局域网地址,即本机
	default-storage-engine = innodb		##默认引擎
	innodb_file_per_table = on			##开启表空间
	max_connections = 4096			##最大连接4096
	collation-server = utf8_general_ci		##默认字符集
	character-set-server = utf8		
[root@ct ~]# systemctl start mariadb   #开启服务
[root@ct ~]# systemctl enable mariadb #设置开机自启动
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@ct ~]# mysql_secure_installation #执行MariaDB完全配置脚本
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    #是否需要创建密码
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] N   #是否不允许root用户远程登录
 ... skipping.
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  #删除test测试库
 - 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 #是否现在重载以上的配置
 ... 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!

4.2 安装RabbitMQ

[root@ct ~]# yum -y install rabbitmq-server #下载rabbitmq服务
[root@ct ~]# systemctl start rabbitmq-server  #启动rabbitmq服务
[root@ct ~]# systemctl enable rabbitmq-server  # 设置开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS  #创建消息队列用户,用于controler和计算节点连接rabbitmq的认证
Creating user "openstack"
[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"   #配置openstack用户的操作权限(正则,配置读写权限);set:修改;permissions:权限
Setting permissions for user "openstack" in vhost "/"   
[root@ct ~]# netstat -anpt | grep 5672   #可查看256725672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      17024/beam.smp      
tcp6       0      0 :::5672                 :::*                    LISTEN      17024/beam.smp      

[root@ct ~]# rabbitmq-plugins list  #查看rabbitmq插件列表
[root@ct ~]# rabbitmq-plugins enable rabbitmq_management #开启rabbitmq的web管理界面的插件,端口为15672
The following plugins have been enabled:
  amqp_client
  cowlib
  cowboy
  rabbitmq_web_dispatch
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@localhost... started 6 plugins.
[root@ct ~]# netstat -anpt | grep 5672
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      17024/beam.smp      
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      17024/beam.smp      
tcp        0      0 127.0.0.1:53127         127.0.0.1:25672         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:51950         127.0.0.1:25672         TIME_WAIT   -                   
tcp6       0      0 :::5672                 :::*                    LISTEN      17024/beam.smp      

4.3 访问浏览器

账号密码默认为:guest
在这里插入图片描述

4.4 安装memcached

作用:
安装memcached是用于存储session信息;服务身份验证机制(keystone)使用Memcached来缓存令牌;在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached缓存中;session保持会话信息
令牌有效期是半小时
在这里插入图片描述

4.5 安装配置etcd

[root@ct ~]# yum -y install etcd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * centos-ceph-nautilus: mirrors.huaweicloud.com
 * centos-nfs-ganesha28: mirrors.ustc.edu.cn
 * centos-openstack-train: mirrors.ustc.edu.cn
 * centos-qemu-ev: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
软件包 etcd-3.3.11-2.el7.centos.x86_64 已安装并且是最新版本
无须任何处理
[root@ct ~]# vim  /etc/etcd/etcd.conf
您在 /var/spool/mail/root 中有新邮件
[root@ct ~]#  grep -v "^#" /etc/etcd/etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"  #默认数据目录位置
ETCD_LISTEN_PEER_URLS="http://192.168.43.100:2380" #监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值
ETCD_LISTEN_CLIENT_URLS="http://192.168.43.100:2379" #对外提供服务的地址(2379端口,集群内部的通讯端口)
ETCD_NAME="ct"  #集群中节点标识(名称)
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.43.100:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.43.100:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.43.100:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" #集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new"   #初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
[root@ct ~]# systemctl start etcd
[root@ct ~]# systemctl enable etcd 
Created symlink from /etc/systemd/system/multi-user.target.wants/etcd.service to /usr/lib/systemd/system/etcd.service.
[root@ct ~]# netstat -anpt | grep 2379
tcp        0      0 192.168.43.100:2379     0.0.0.0:*               LISTEN      19106/etcd          
tcp        0      0 192.168.43.100:51932    192.168.43.100:2379     ESTABLISHED 19106/etcd          
tcp        0      0 192.168.43.100:2379     192.168.43.100:51932    ESTABLISHED 19106/etcd          
[root@ct ~]# netstat -anpt | grep 2380
tcp        0      0 192.168.43.100:2380     0.0.0.0:*               LISTEN      19106/etcd          

4.6 c1、c2安装OpenStack组件

[root@c1 ~]# yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * centos-ceph-nautilus: mirrors.nju.edu.cn
 * centos-nfs-ganesha28: mirrors.neusoft.edu.cn
 * centos-openstack-train: mirrors.neusoft.edu.cn
 * centos-qemu-ev: mirrors.nju.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.nju.edu.cn
软件包 centos-release-openstack-train-1-1.el7.centos.noarch 已安装并且是最新版本
软件包 python2-openstackclient-4.0.2-1.el7.noarch 已安装并且是最新版本
软件包 openstack-selinux-0.8.26-1.el7.noarch 已安装并且是最新版本
软件包 openstack-utils-2017.1-1.el7.noarch 已安装并且是最新版本
无须任何处理

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值