OpenStack部署安装

本文档详述了在CentOS 7.0环境下,从环境准备到安装OpenStack各组件(包括keystone、glance、nova、neutron、dashboard、cinder)的完整过程。涉及的步骤包括安装数据库、消息队列、配置认证服务、网络服务、计算服务、镜像服务、控制台和块存储服务,以及创建和使用实例的命令。
摘要由CSDN通过智能技术生成

注:所有操作都是在CentOS 7.0


(一)环境准备(所有节点)

1、修改主机名,并修改/etc/hosts

vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.80.151 controller0
192.168.80.152 compute1
修改主机名(也可以在安装系统时直接命名为相应的名称):
hostnamectl set-hostname controller0
2、关闭防火墙并设置开机不启动
停止防火墙
systemctl stop firewalld.service
禁止防火墙开机启动
systemctl disable firewalld.service
3、关闭selinux
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
4、安装NTP服务
[root@controller ~]# yum install chrony -y 
[root@controller ~]# vim /etc/chrony.conf
server 192.168.80.151 iburst (计算节点只添加这条)
...
allow 192.168.31.0/24

在配置文件的最后加入允许连接到控制节点的chrony后台进程

下边是对应的时间服务器地址,我使用的是中国的地址

区域[zone]        域名[Domain]      IP[IP Pool]
中国[China]       cn.ntp.org.cn       [202.108.6.95] [202.112.29.82] [110.75.190.198] [115.28.122.198] [182.92.12.11] [120.25.108.11] [110.75.186.249] [110.75.186.248] [110.75.186.247]
台湾              tw.ntp.org.cn       [120.119.28.1]
美国[America]     us.ntp.org.cn       [24.56.178.140] [131.107.13.100]
新加坡            sgp.ntp.org.cn       [139.162.20.174] [103.11.143.248]
韩国[korea]       kr.ntp.org.cn       [218.234.23.44] [211.233.40.78]
德国[Germany]     de.ntp.org.cn       [131.188.3.220] [131.188.3.223]
日本[Japan]       jp.ntp.org.cn       [133.243.238.243] [157.7.152.213]

注:将所有计算节点的服务器地址设置为控制节点的IP地址
5、启动NTP服务并设置NTP开机启动并查看状态
systemctl enable chronyd.service

systemctl start chronyd.service

systemctl status chronyd.service
6、验证
chronyc sources

根据不同地域或DNS显示会不一致(控制器)

210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* time6.aliyun.com              2   6    17     0   +551us[ +189us] +/-   41ms
<pre name="code" class="plain">

下边是计算或其它节点显示的相关内容

210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? controller                    3   6     3     0  +1149us[+1149us] +/-   41ms
7、安装openstack mitaka 源

yum install rdo-release-newton-5.noarch.rpm -y

yum install epel-release-7-10.noarch.rpm -y

8、清理并生成缓存

yum clean all

yum makecache

9、更新操作系统,时间取决于网速,请耐心等待

yum update -y

10、重启操作系统

reboot

(二)安装数据库(控制节点)

1、安装 python-openstackclient 和 openstack-selinuxl 软件包
[root@controller ~]# yum install python-openstackclient openstack-selinux -y
2、安装mariadb数据库软件包
[root@controller ~]# yum install mariadb mariadb-server python2-PyMySQL -y
3、创建openstack数据库配置文件 /etc/my.cnf.d/mariadb_openstack.cnf,并写入下列内容
[root@controller ~]# vim /etc/my.cnf.d/mariadb_openstack.cnf

[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
bind-address = 192.168.80.151
max_connections=1500
#注意:将bind-address替换为控制器的管理IP
[root@controller ~]# vim /usr/lib/systemd/system/mariadb.service
在[Service]增加以下两行

LimitNOFILE=10000
LimitNPROC=10000

刷新系统服务

[root@controller ~]# systemctl --system daemon-reload
4、启动数据库及设置开机启动及状态查看
systemctl enable mariadb.service

systemctl start mariadb.service

systemctl status mariadb.service

systemctl list-unit-files |grep mariadb.service
5、初始化数据库,设置数据库密码
[root@controller ~]# mysql_secure_installation

注意:此处需要设置数据库密码“本文中设置的密码为dhy@opstack2017”,其他均输入y

6、安装消息队列rabbitmq-server
[root@controller ~]# yum install rabbitmq-server -y
7、启动rabbitmq消息队列及设置开机启动并查看状态
systemctl enable rabbitmq-server.service

systemctl start rabbitmq-server.service

systemctl status rabbitmq-server.service

systemctl list-unit-files |grep rabbitmq-server.service
8、创建消息队列中openstack账号,并设置自相应的密码(本文档中设置为dhy@opstack2017)
[root@controller ~]# rabbitmqctl add_user openstack dhy@opstack2017
9、将openstack用户赋予相关的权限
[root@controller ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
10、查看消息队列是否启动正常,查看5672端口是否监听
[root@controller ~]# vim /etc/rabbitmq/rabbitmq.config

{rabbit,
....
 {tcp_listeners, [{"192.168.80.151", 5672}]}
....
}
netstat -ntlp
11、查看rabbitmq所有插件
[root@controller ~]# /usr/lib/rabbitmq/bin/rabbitmq-plugins list
12、打开rabbitmq的web插件,以方便使用web浏览器查看相关数据
[root@controller ~]# /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management

启动失败解决方法:

[root@iZ28jyxu47dZ sbin]# ./rabbitmqctl start_app
Starting node rabbit@iZ28jyxu47dZ ...
[root@iZ28jyxu47dZ sbin]# ./rabbitmq-plugins enable rabbitmq_management
Plugin configuration unchanged.
13、重启rabbitmq
[root@controller ~]# systemctl restart rabbitmq-server.servicerabbitmq
14、检查rabbitmq是否可以使用浏览器正常打开
使用浏览器打开:http://192.168.80.151:15672/ 
用户名和密码都是guest
15、安装Memcached用于缓存令牌,Memcached运行在控制节点上
[root@controller ~]# yum install memcached python-memcached -y
16、启动memcached及设置开机启动
systemctl enable memcached.service

systemctl start memcached.service

systemctl status memcached.service

systemctl list-unit-files |grep memcached.service

(三)安装keystone认证服务(控制节点安装)

1、创建keystone数据库
[root@controller ~]# mysql -uroot -pdhy@opstack2017 -e "CREATE DATABASE keystone;"
2、创建数据库用户及赋予权限
[root@controller ~]# mysql -uroot -pdhy@opstack2017 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'dhy@opstack2017';" 

[root@controller ~]# mysql -uroot -pdhy@opstack2017 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'dhy@opstack2017';"
3、生成一个随机值在初始的配置中作为管理员的令牌
[root@controller ~]# openssl rand -hex 10

将生成的token记录下来,在后边的配置中需要使用

4、安装keystone相关软件包
[root@controller ~]# yum install openstack-keystone httpd mod_wsgi openstack-utils -y

文档中都是使用快速的配置方法,所以必须安装Openstack-utils

5、配置/etc/keystone/keystone.conf文件
openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token ed54174f9f7b1545a535

将ed54174f9f7b1545a535替换成自己的Token

openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:dhy@opstack2017@192.168.80.151/keystone

替换自己的数据库IP地址和相应的密码

6、初始化身份认证服务的数据库并设置toden存放的位置
su -s /bin/sh -c "keystone-manage db_sync" keystone
openstack-config --set /etc/keystone/keystone.conf token provider fernet
openstack-config --set /etc/keystone/keystone.conf token driver memcache
7、初始化Fernet keys
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
8、配置http服务
sed  -i  "s/#ServerName www.example.com:80/ServerName 192.168.80.151/" /etc/httpd/conf/httpd.conf

配置对应的IP地址,以供web进行访问

9、用下面的内容创建文件 /etc/httpd/conf.d/wsgi-keystone.conf,keystone的http配置文件
[root@controller ~]# vim /etc/httpd/conf.d/wsgi-keystone.conf

Listen 5000
Listen 35357

<VirtualHost *:5000>
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:35357>
    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-admin
    WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>
10、启动 Apache HTTP 服务并配置其随系统启动
systemctl enable httpd.service

systemctl start httpd.service

systemctl status httpd.service

systemctl list-unit-files |grep httpd.service
11、导入环境变量
export OS_TOKEN=ed54174f9f7b1545a535
export OS_URL=http://192.168.80.151:35357/v3
export OS_IDENTITY_API_VERSION=3

替换自己的Token

12、创建域‘‘default’’默认域
openstack domain create --description "Default Domain" default
13、创建admin项目
openstack project create --domain default --description "Admin Project" admin
14、创建用户输入admin密码
openstack user create --domain default admin --password admin

密码设置为:admin 根据实际情况设置相应的密码

15、创建 admin 角色
openstack role create admin
16、添加admin 角色到 admin 项目和用户上
openstack role add --project admin --user admin admin
17、创建service项目
openstack project create --domain default --description "Service Project" service
18、创建demo项目
openstack project create --domain default --description "Demo Project" demo
19、创建demo用户并设置Demo密码
openstack user create --domain default demo  --password demo

密码设置为:demo 根据实际情况设置相应的密码

20、创建user角色
openstack role create user
21、添加 user角色到demo 项目和用户
openstack role 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值