OpenStack概述及环境部署

一、OpenStack概述

1.云计算服务模型

  • laaS(基础架构即服务)]
    提供底层IT基础设施服务,包括处理能力、存储空间、网络资源(比如迅雷)等
    面向对象一般是IT管理人员
  • PaaS (平台即服务)
    把安装好开发环境的系统平台作为一-种服务通过互联网提供给用户
    面向对象一般是开发人员
  • SaaS (软件即服务)
    直接通过互联网为用户提供软件和应用程序等服务
    面向对象一般是普通用戶

2.OpenStack的概念

Open(开源)Stack(堆叠)以物理设备为基础,以虚拟化的技术奖资源分配给不同的用户(比如:电商、金融P2P)

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

3.OpenStack核心组件

项目名称即核心服务,都是为实例服务的;实例就是虚拟机
项目与项目直接相互隔离的,借助于API对接的方式相互关联

服务项目名称描述
计算服务(Compute)nova管理实例生命周期,计算资源的单位,对Hypervisor进行屏蔽,支持多种虚拟化技术,支持横向扩展
网络 服务(Network)neutron负责虚拟网络的管理 为实例创建网络的拓扑结构
镜像服务(Image Service)glance提供虚拟机镜像模板的注册与管理,将做好的操纵系统拷贝为镜像模板,在创建虚拟机的时候,可支持多格式的镜像
身份认证服务(Identify)keystone负责OpenStack内外交互,以及内部所有组件交互时的认证
块存储服务(Block Service)cinder负责为运行实例提供持久的块存储设备
对象存储服务(Object Storage)swift提供基于云的弹性存储,支持集群单点故障
计量服务(Telemetry)celimitor用于度量、监控和控制数据资源的集中来源,为用户提供记账途径
控制面板服务(Dashboard)horizon用户登陆、使用的控制台界面

二、OpenStack架构

1.设计基本原则

  • 按照不同的功能和通用性划分不同的项目,拆分子系统
  • 按照逻辑计划、规范子系统之间的通信
  • 通过分层设计整个系统架构
  • 不同的功能子系统间提供统一的API接口

2.概念框架

在这里插入图片描述

云平台用户在经过Keystone服务认证授权后—>通过Horizon或者Reset API模式创建虚拟机服务

  • 创建过程中:
    利用Nova服务创建虚拟机实例—>虛拟机实例采用Glance提供镜像服务—>使用Neutron为新建的虚拟机分配IP地址,并将其纳入虚拟网络中—>通过Cinder创建的卷为虚拟机挂载存储块,整个过程都在Ceilometer模块资源的监控下,Cinder产生的卷(Volume) 和Glance提供的镜像(Image) 可以通过Swift的对象存储机制进行保存。
  • 主要组件
    全局:Keyston(全局认证)、Ceilometer(监控、计费)、Horizon(控制台)
    核心:Nove(计算)、Glance(镜像)、Neutron(网络)、Swift(块存储)、Cinder(对象存储)
    支持/辅助:Ironic(裸金属)、Trove(数据库管理)、Hent(数据编排)

3.逻辑架构

  • OpenStack包括若干个称为OpenStack服务的独立组件。所有服务均可通过一个公共身份服务进行身份验证。除了那些需要管理权限的命令,每个服务之间均可通过公共API进行交互
  • 每个OpenStack服务又由若干组件组成。包含多个进程。所有服务至少有一个API进程,用于侦听API请求,对这些请求进行预处理,并将它们传送到该服务的其他组件。除了认证服务,实际工作都是由具体的进程完成的
  • 至于一个服务的进程之间通信,则使用AMQP消息代理。服务的状态存储在数据库中

4.物理架构

在这里插入图片描述

4.1 网络节点-提供者网络

  • 联网管理
  • ML2插件
  • Linux网络工具
  • Linux Bridge代理
  • DHCP代理
  • 元数据代理(Metadata Agent)

4.2 网络节点-自服务网络

  • 联网管理
  • ML2插件
  • Linux网络工具
  • Linux Bridge代理
  • 三层代理(L3 Agent)
  • DHCP代理
  • 元数据代理(Metadata Agent)

三、OpenStack环境部署

主机名  内存      硬盘      网卡                  系统
CT      8G      300G      NAT 192.168.30.100   centos7.6 
						  VM  192.168.10.100
C1      8G      300G      NAT 192.168.30.101   centos7.6 
						  VM  192.168.10.101
C2      8G      300G      NAT 192.168.30.102   centos7.6 
						  VM  192.168.10.102						  						  

在这里插入图片描述

1.基础环境配置(所有节点)

1.1 关闭防火墙、核心防护

[root@ct ~]# systemctl stop firewalld
[root@ct ~]# 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@ct ~]# setenforce 0

1.2 配置hosts映射

[root@ct ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.100 ct
192.168.10.101 c1
192.168.10.102 c2

1.3 配置ssh免交互

  105  ssh-keygen -t rsa
  106  ssh-copy-id ct
  107  ssh-copy-id c1
  108  ssh-copy-id c2
  109  history
[root@ct ~]# 

1.4 安装基础环境依赖包

[root@c1 ~]# yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre  pcre-devel expat-devel cmake  bzip2 lrzsz
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 net-tools-2.0-0.25.20131004git.el7.x86_64 已安装并且是最新版本
软件包 1:bash-completion-2.1-8.el7.noarch 已安装并且是最新版本
软件包 2:vim-enhanced-7.4.629-8.el7_9.x86_64 已安装并且是最新版本
软件包 gcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 1:make-3.82-24.el7.x86_64 已安装并且是最新版本
软件包 pcre-8.32-17.el7.x86_64 已安装并且是最新版本
软件包 pcre-devel-8.32-17.el7.x86_64 已安装并且是最新版本
软件包 expat-devel-2.1.0-12.el7.x86_64 已安装并且是最新版本
软件包 cmake-2.8.12.2-2.el7.x86_64 已安装并且是最新版本
软件包 bzip2-1.0.6-13.el7.x86_64 已安装并且是最新版本
软件包 lrzsz-0.12.20-36.el7.x86_64 已安装并且是最新版本
无须任何处理

[root@ct ~]# yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 centos-release-openstack-train-1-1.el7.centos.noarch 已安装并且是最新版本   //OpenStack 的 train 版本仓库源安装 包,同时安装 OpenStack 客户端和 openstack-selinux 安装包
软件包 python2-openstackclient-4.0.2-1.el7.noarch 已安装并且是最新版本
软件包 openstack-selinux-0.8.26-1.el7.noarch 已安装并且是最新版本
软件包 openstack-utils-2017.1-1.el7.noarch 已安装并且是最新版本
无须任何处理

1.5 配置时间同步

ct ->同步阿里云时钟服务器
c1、c2 -> 同步ct

1.5.1 安装chrony

[root@ct ~]# yum -y install chrony
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 chrony-3.4-1.el7.x86_64 已安装并且是最新版本
无须任何处理

1.5.2 修改配置文件,使其指向aliyun时钟服务器

在这里插入图片描述

1.5.3重启,并使其开机自启

[root@ct ~]# systemctl restart chronyd
[root@ct ~]# systemctl enable chronyd

1.5.4 查看时间同步信息

在这里插入图片描述

1.5.5 配置计划任务

[root@ct ~]# crontab -e

*/2 * * * * /usr/bin/chronyc sources >>/var/log/chronyc.log   //每隔2分钟同步一次

2.系统环境配置(控制节点)

2.1 安装、配置MariaDB

[root@ct ~]# cat /etc/my.cnf.d/openstack.cnf 
[mysqld]
bind-address = 192.168.10.100  //控制节点局域网地址
default-storage-engine = innodb  //默认存储引擎
innodb_file_per_table = on       //每张表独立表空间文件
max_connections = 4096         //最大连接数 
collation-server = utf8_general_ci  //默认字符集 
character-set-server = utf8
[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 ~]#  systemctl start mariadb   //开启服务
[root@ct ~]# 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
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      
 ... skipping.   //是否不允许root用户远程登录

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!
[root@ct ~]# 

2.2 安装RabbitMQ

所有创建虚拟机的指令,控制端都会发送到rabbitmq,计算节点监听rabbitmq

[root@ct ~]# yum -y install rabbitmq-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 rabbitmq-server-3.6.16-1.el7.noarch 已安装并且是最新版本
无须任何处理
[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 ~]# systemctl start rabbitmq-server   //启动
[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS   //创建消息队列用户,用于controler和计算节点连接rabbitmq的认证
Creating user "openstack"
[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"  //配置openstack用户的操作权限
Setting permissions for user "openstack" in vhost "/"

[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@ct... started 6 plugins.
[root@ct ~]# netstat -antp | grep 5672
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      12486/beam.smp      
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      12486/beam.smp      
tcp        0      0 192.168.10.100:52233    192.168.10.100:25672    TIME_WAIT   -                   
tcp6       0      0 :::5672                 :::*                    LISTEN      12486/beam.smp      
[root@ct ~]# 

在这里插入图片描述

2.3 安装memcached

  • 安装memcached是用于存储session信息;服务身份验证机制(keystone)使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中
[root@ct ~]# yum install -y memcached python-memcached
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 memcached-1.5.6-1.el7.x86_64 已安装并且是最新版本
软件包 python-memcached-1.58-1.el7.noarch 已安装并且是最新版本
无须任何处理
[root@ct ~]# vim /etc/sysconfig/memcached 
[root@ct ~]# cat /etc/sysconfig/memcached 
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1,ct"  //添加ct
[root@ct ~]# systemctl enable memcached
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
[root@ct ~]# systemctl start memcached
[root@ct ~]# netstat -antp | grep 11211
tcp        0      0 192.168.10.100:11211    0.0.0.0:*               LISTEN      14026/memcached     
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      14026/memcached     
tcp6       0      0 ::1:11211               :::*                    LISTEN      14026/memcached     
[root@ct ~]# 
2.3.1 安装、配置etcd
[root@ct ~]# yum install -y etcd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.aliyun.com
 * centos-nfs-ganesha28: mirrors.aliyun.com
 * centos-openstack-train: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
软件包 etcd-3.3.11-2.el7.centos.x86_64 已安装并且是最新版本
无须任何处理
[root@ct ~]# vim /etc/etcd/etcd.conf 
[root@ct ~]# vim /etc/etcd/etcd.conf 
[root@ct ~]# grep -v "^#" /etc/etcd/etcd.conf 
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"  //默认数据目录位置
ETCD_LISTEN_PEER_URLS="http://192.168.10.100:2380"  //监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值
ETCD_LISTEN_CLIENT_URLS="http://192.168.10.100:2379" //对外提供服务的地址(2379端口,集群内部的通讯端口)
ETCD_NAME="ct"  //集群中节点标识(名称)
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.10.100:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.10.100:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.10.100:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"  集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new"  //初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
若为DNS,则表示此集群将作为被加入的对象
[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 ~]# systemctl start etcd
[root@ct ~]# netstat -anutp | grep 23 
tcp        0      0 192.168.10.100:2379     0.0.0.0:*               LISTEN      14867/etcd          
tcp        0      0 192.168.10.100:2380     0.0.0.0:*               LISTEN      14867/etcd          
tcp        0      0 192.168.10.100:47564    192.168.10.100:2379     ESTABLISHED 14867/etcd          
tcp        0      0 192.168.10.100:2379     192.168.10.100:47564    ESTABLISHED 14867/etcd          

2.4 c1、c2安装OpenStack组件

在这里插入代码片

小结

环境部署

  • 安装环境软件包
  • 安装openstack-T 软件包
  • 配置网卡(外网模式指定路由优先级)
  • 时间同步,免交互
  • 安装mariadb
  • 安装rabbitmq
  • 安装memcached (缓存session和token)
  • 安装etcd (去中心化分布式存储,特点是自动发现,版本V3)
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值