Centos7安装部署openstack----基础服务安装

一、环境准备

  官网:https://docs.openstack.org/train/

  1、准备两台centos系统服务器:controller:内存3G,cpu开启虚拟化,IP:10.0.0.11

                  compute1: 内存1G,cpu开启虚拟化(必开),IP:10.0.0.31

  2、host解析

[root@controller ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.11   controller
10.0.0.31   computer1
[root@controller ~]# scp -rp /etc/hosts 10.0.0.31 /etc/hosts

  3、配置yum源,挂载光盘镜像。

[root@computer1 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@controller ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
#查看 (如果有内容代表挂载成功)
[root@computer1 ~]# ll /mnt
total 686
-rw-rw-r-- 1 root root     14 Nov 26  2018 CentOS_BuildTag
drwxr-xr-x 3 root root   2048 Nov 26  2018 EFI
-rw-rw-r-- 1 root root    227 Aug 30  2017 EULA
-rw-rw-r-- 1 root root  18009 Dec 10  2015 GPL
drwxr-xr-x 3 root root   2048 Nov 26  2018 images
drwxr-xr-x 2 root root   2048 Nov 26  2018 isolinux
drwxr-xr-x 2 root root   2048 Nov 26  2018 LiveOS
drwxrwxr-x 2 root root 663552 Nov 26  2018 Packages
drwxrwxr-x 2 root root   4096 Nov 26  2018 repodata
-rw-rw-r-- 1 root root   1690 Dec 10  2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 root root   1690 Dec 10  2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root   2883 Nov 26  2018 TRANS.TBL

  4、修改yum源,改为阿里云的在线源

  地址:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11ihv8TZ

[root@controller ~]# mkdir repo
[root@controller ~]# mv CentOS-* repo/
[root@controller ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@controller ~]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0

[root@controller
~]# echo 'mount /dev/cdrom /mnt' >>/etc/rc.local [root@controller ~]# chmod +x /etc/rc.d/rc.local [root@controller ~]# scp -rp /etc/yum.repos.d/local.repo 10.0.0.31:/etc/yum.repos.d/local.repo
[root@computer1 ~]# vim /etc/yum.repos.d/local.repo
[root@computer1 ~]# echo 'mount /dev/cdrom /mnt' >>/etc/rc.local
[root@computer1 ~]# chmod +x /etc/rc.d/rc.local

[root@controller yum.repos.d]# yum makecache
[root@controller yum.repos.d]# yum list|grep openstack
[root@controller yum.repos.d]#yum install centos-release-openstack-queens.noarch -y

二、安装基础服务chrony

  1、安装服务

[root@controller]# yum install -y chrony
[root@computer1]#  yum install -y chrony

  2、编辑控制节点配置文件

[root@controller ]# vim /etc/chrony.conf 
1)将 server
1.centos.pool.ntp.org iburst 改成 server ntp6.aliyun.com iburst 另三行删掉
2)将 #allow 192.168.0.0/1改成 allow 10.0.0.0/24
3)[root@
controller ]# systemctl restart chronyd 并重启服务
[root@controller ]# systemctl enable chronyd 加入开机自启

  3、编辑计算节点配置文件

[root@computer1 opt]# vim /etc/chrony.conf 

1)将 server
1.centos.pool.ntp.org iburst 改成 server 10.0.0.11 iburst 另三行删掉
3)[root@computer1 ]# systemctl restart chronyd      并重启服务
[root@computer1 ]# systemctl enable chronyd 加入开机自启
[root@controller yum.repos.d]# chronyc sources 验证是否同步

三、安装openstack客户端和openstack-selinux,所有节点都执行

[root@control ~]# yum install python-openstackclient openstack-selinux -y 
[root@computer1 ~]# yum install python-openstackclient openstack-selinux -y

四、控制节点安装数据库以及安全初始化

  官方文档:https://docs.openstack.org/mitaka/zh_CN/install-guide-obs/environment-sql-database.html

[root@controller ~]# yum install mariadb mariadb-server python2-PyMySQL -y

  创建并编辑 /etc/my.cnf.d/openstack.cnf

[root@control ~]# cat /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 10.0.0.11                # 值为控制节点的管理网络IP地址以使得其它节点可以通过管理网络访问数据库
default-storage-engine = innodb         #默认存储引擎
innodb_file_per_table = no                   #为每个表独立表空间文件     
max_connections = 4096                  #最大连接数
collation-server = utf8_general_ci       #默认字符集
character-set-server = utf8 

[root@controller ~]# systemctl start mariadb 启动数据库
[root@controller ~]# systemctl enable mariadb 加入开机自启动
[root@controller ~]# mysql_secure_installation 为了保证数据库服务的安全性,数据库安全初始化,一定要执行要不然后面时间同步会有坑
回车 #需要输入当前root用户的密码,这里我们是空,就直接回车就可以了
Enter current password for root (enter for none): #设置数据库的密码 ,这里我不想设置 选择n
Set root password? [Y/n] #移除地址用户 选择Y
Remove anonymous users? [Y/n] Y #禁止root远程登录 选择Y
Disallow root login remotely? [Y/n] Y #移除data的数据库和访问他的权限 选择 y
Remove test database and access to it? [Y/n] y #重载权限表 选择 y
Reload privilege tables now? [Y/n] y

五、NoSQL 数据库,用于计费用的,私有云可以不用安装

  1.配置MongoDB的yum源

vim /etc/yum.repos.d/mongodb-org-4.0.repo
#添加以下内容:
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

#这里可以修改 gpgcheck=0, 省去gpg验证
[root@controller ~]# yum makecache

  2、安装MongoDB

yum -y install mongodb-org
whereis mongod

  3、查看修改配置文件

vim /etc/mongod.conf

  4、启动服务

systemctl start mongod.service             启动
systemctl stop mongod.service              停止
systemctl status mongod.service            查看状态
systemctl enable mongod.service            加入自启

  5、启动Mongo shell

mongo
show dbs            查看数据库
use tesataa 使用数据库
db.createUser({user:"useraa",pwd:"123456",roles:[{role:"dbOwner",db:"tesataa"}]}) 为单个数据库添加用户(用户名为useraa,密码为123456)

  6、设置mongodb远程访问,编辑mongod.conf注释bindIp,并重启mongodb.(这句配置代表只能本机使用,所以需注释) 或者 设置为 0.0.0.0

vim /etc/mongod.conf

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0
systemctl restart mongod.service        重启服务

六、安装消息队列rabbitmq服务

OpenStack 使用 message queue 协调操作和各服务的状态信息。消息队列服务一般运行在控制节点上。OpenStack支持好几种消息队列服务包括 RabbitMQ, Qpid, 和 ZeroMQ。不过,大多数发行版本的OpenStack包支持特定的消息队列服务。本指南安装 RabbitMQ 消息队列服务,因为大部分发行版本都支持它。如果你想安装不同的消息队列服务,查询与之相关的文档。 就是把所有功能拆成 独立的服务,服务跟服务之间就涉及到调用的问题,这时就要通过消息队列进行(类似一个中介)

[root@controller ~]# yum  install rabbitmq-server -y                    安装服务
[root@controller ~]# systemctl enable rabbitmq-server.service           将其配置为随系统启动
[root@controller ~]# systemctl start rabbitmq-server.service 启动消息队列服务

  1、添加用户,设置密码,具体创建用户,设置密码,建议按照官方文档执行。

  文档地址:https://docs.openstack.org/mitaka/zh_CN/install-guide-obs/environment-security.html

[root@controller ~]# rabbitmqctl add_user openstack RABBIT_PASS 
Creating user "openstack" ...

  2、授权

[root@controller ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"            给openstack用户配置写和读权限 
Setting permissions for user "openstack" in vhost "/" ...

  3、查看端口,验证服务

[root@controller ~]# netstat -lntup |grep 5672
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      10118/beam          
tcp6       0      0 :::5672                 :::*                    LISTEN      10118/beam  

  4、启动管理界面(插件)

[root@controller ~]# rabbitmq-plugins enable rabbitmq_management

  5、查看端口发现多一个15672

[root@controller ~]# netstat -lntup |grep 5672
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      10118/beam          
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      10118/beam          
tcp6       0      0 :::5672                 :::*                    LISTEN      10118/beam 

  6、web页面登录:http://10.0.0.11:15672/ ,账号:guest ,密码:guest

  

 六、安装Memcached

  认证服务认证缓存使用Memcached缓存令牌。缓存服务memecached运行在控制节点。在生产部署中,我们推荐联合启用防火墙、认证和加密保证它的安全。

  1、安装软件

[root@controller ~]# yum  install memcached python-python-memcached -y

  2、修改配置文件 这一条在M版本的官方文档没有,但在o 版本的有

[root@control ~]# sed -i 's#127.0.0.1#10.0.0.11#g' /etc/sysconfig/memcached                   不改,就只能本机访问

  3、启动Memcached服务,并且配置它随机启动

[root@controller ~]# systemctl enable memcached.service
[root@controller ~]# systemctl start memcached.service

  4、验证服务,查看端口号

[root@controller ~]# netstat -lntup |grep 11211
tcp        0      0 10.0.0.11:11211         0.0.0.0:*               LISTEN      11095/memcached     
tcp6       0      0 ::1:11211               :::*                    LISTEN      11095/memcached     
udp        0      0 10.0.0.11:11211         0.0.0.0:*                           11095/memcached     
udp6       0      0 ::1:11211               :::*                                11095/memcached 

到这里基础服务已经安装完成!

  

 

 

原文地址:https://www.cnblogs.com/aqicheng/p/13206898.html