一、安装前的准备
在RHEL7/CentOS7上安装openstack liberty
两台虚拟机,安装centos7系统(准备两个网卡,一个NAT,另一个仅主机)
nat网卡设置ip,可以联网,仅主机的网卡只要我们windows可以通就行,主要是用putty远程连接的
关闭selinux
关闭iptables
systemctl stop firewalld
systemctl disable firewalld
关闭NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
二、配置密码
在部署openstack过程中会在多个地方使用到密码,为了方便管理和安全设置,我们需要提前先定义好密码,使用命令mkpasswd -s 0生成随机字符串
Database password (no variable used)Root password for the database tn1Pi6Ytm
ADMIN_PASSPassword of user admin 3qiVpzU2x
CEILOMETER_DBPASSDatabase password for the Telemetry service Czn3bF1hm
CEILOMETER_PASSPassword of Telemetry service user ceilometer abquh12GU
CINDER_DBPASSDatabase password for the Block Storage service O3bwbpoZ3
CINDER_PASSPassword of Block Storage service user cinder hf8LX9bow
DASH_DBPASSDatabase password for the dashboard 5qBZxnn1g
DEMO_PASSPassword of user demo 9TtbgaA1q
GLANCE_DBPASSDatabase password for Image service Zznky4tP0
GLANCE_PASSPassword of Image service user glance Wuyaf4cV6
HEAT_DBPASSDatabase password for the Orchestration service b7Fk5wjLg
HEAT_DOMAIN_PASSPassword of Orchestration domain 7Gotb3eoH
HEAT_PASSPassword of Orchestration service user heat eqQ2jLgz0
KEYSTONE_DBPASSDatabase password of Identity service f6zx0gURv
NEUTRON_DBPASSDatabase password for the Networking service quidyOC50
NEUTRON_PASSPassword of Networking service user neutron mdcGVl29i
NOVA_DBPASSDatabase password for computer service RYgv0rg7p
NOVA_PASSPassword of computer service user nova hsSNsqc43
RABBIT_PASSPassword of user guest of RabbitMQ o3NXovnz5
SWIFT_PASSPassword of Object Storage service user swift 6ci5xWOdk
METADATA_SECRET m8uhmQTu2
三、配置ip(一个nat模式,一个仅主机模式,仅主机的网卡只需要给xshell连接即可)
在controller上
dhclient eno16777736 (nat卡)
dhclient -r
dhclient eno 33554984 (仅主机卡)
ifconfig 查看ip
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eno16777736
UUID=6612a6a5-090b-43b8-9c87-e43545f800a9
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.163.249
PREFIX=24
GATEWAY=192.168.163.2
PEERDNS=no
在computerr上
dhclient eno16777736 (nat卡)
dhclient -r
dhclient eno 33554984 (仅主机卡)
修改dns配置文件
vim /etc/resolv.conf
nameserver 10.10.19.3
ifconfig 查看ip
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
vim /etc/resolv.conf
nameserver 10.10.19.3
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
NAME=eno16777736
UUID=a0761a5d-3a3d-420b-82b8-cd5e2919c55a
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.163.246
PREFIX=24
GATEWAY=192.168.163.2
PEERDNS=no
修改dns配置文件
vim /etc/resolv.conf
nameserver 10.10.19.3
修改后使用客户端ssh远程连接,如果连接密码跳出比较慢,修改以下配置文件
vim /etc/ssh/sshd.conf
找到#USEDNS yes
改成USEDNS no
四、两台机器,设置hostname,配置时间同步
hostnamectl set-hostname controller
hostnamectl set-hostname computerr
编辑/etc/hosts: 192.168.163.249 controller
192.168.163.246 computerr
controller上:
yum install -y chrony
vim /etc/chrony.conf
增加或更改: allow 192.168.163.0/24
保存后,执行systemctl enable chronyd.service
systemctl start chronyd.service
computer上:
yum install -y chrony;vim /etc/chrony.conf
增加或更改: server controller iburst
保存后,执行systemctl enable chronyd.service
systemctl start chronyd.service
五、配置yun源升级软件安装openstack需要的包
安装openstack的yum源(两个机器上都操作)
yum install -y centos-release-openstack-liberty
升级所有的包(两个机器上都操作)
yum upgrade
结束后重启系统
安装openstack 客户端和openstack-selinux
yum install -y python-openstackclient openstack-selinux
六、安装sql服务(controller)
yum install -y mariadb mariadb-server MySQL-python
编辑配置文件 vim /etc/my.cnf.d/mariadb_openstack.cnf #加入下面内容
[mysqld]
bind-address = 192.168.163.249
default-storage-engine = innodb
innodb_file_per_table #表示一个表对应一个文件
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
启动mariadb:systemctl enable mariadb.service
systemctl start mariadb.service
安全配置,设置root密码
mysql_secure_installation
设置root密码为 tn1Pi6Ytm #此处密码为第二步用mkpasswd生成的密码
需要确定的全部为y
使用mysql -uroot -ptn1Pi6Ytm 测试是否可以登陆
七、安装nosql(control)如果架构不需要用到可以不安装
nosql数据库被Telemetry service用到
在这里我们安装的是mongodb
yum install -y mongodb-server mongodb
编辑配置文件 vim /etc/mongod.conf #更改如下配置
bind_ip = 192.168.163.249
smallfiles = true
启动服务
systemctl enable mongod.service
systemctl start mongod.service
八、安装消息队列(controller)
rabbitmq消息队列服务在openstack中起到非常关键的作用,它好比是一个交通枢纽,各个组件之间的通信由它来完成。
yum install -y rabbitmq-server
启动rabbitmq-server服务
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
使用ps aux |grep rabbitmg 和netstat -lnp |grep 5672确定有没有启动
添加openstack用户
rabbitmqctl add_user openstack o3NXovnz5
# 密码 o3NXovnz5 用户名为openstack
为openstack用户授权
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
允许openstack用户可以配置,可以写,可以读
九、增加identity - keystone介绍(controller)
identity即keystone,它是openstack的验证中心,所有的服务都由它来认证。参考 http:#blog.csdn.net/wsfdl/article/details/20492343
在keyston中有以下角色:tenants(租户或项目)、用户、角色、服务目录和端点
如果把宾馆比作为Tenant,住宿的人就是User ,宾馆可以提供多种诸如住宿、娱乐、饮食等多种服务(Service),具体来说,住宿是一种具体的服务(Endpoint)。就住宿而言,有普通间和总统套房,如果你的VIP等级(Role)高,你可以享受到豪华的总统套房。入住前,我们需要拿×××开房(Credential),认证×××不是冒牌货后(Authenticaiton),会给你一个×××(Token),然后你拿着×××,就可以进入房间和享受各种服务。
以创建一个虚拟机(server)为例,keystone在openstack的访问流程大致如下:
1 用户Alice通过自己的户名和密码向keystone申请token,keystone认证用户名和密码后,返回token1
2 Alice通过token1发送keystone查询他所拥有的租户,keystone验证token1成功后,返回Alice的所有Tenant
3 Alice选择一个租户,通过用户名和密码申请token,keystone认证用户名、密码、tenant后,返回token2。(其实1、2步仅仅是为了查询tenant,如果已经知道tenant,可以忽略1、2步)
4 Alice通过token2发送创建server的请求,keystone验证token2(包括该token是否有效,是否有权限创建虚拟机等)成功后,然后再把请求下发到nova,最终创建虚拟机
登陆mysql,创建数据库
mysql -uroot -ptn1Pi6Ytm
>create database keystone;
>GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'f6zx0gURv';
>GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'f6zx0gURv';
说明,创建一个keystone库,并且授权给keystone用户所有权限,密码为f6zx0gURv
安装相关的包
yum install -y openstack-keystone httpd mod_wsgi memcached python-memcached
启动memcached服务
systemctl enable memcached.service
systemctl start memcached.service
编辑keystone配置文件
vim /etc/keystone/keystone.conf #修改或增加配置如下
[DEFAULT]
admin_token = 3qiVpzU2x
verbose = true #启动时记录相关日志
[database]
connection = mysql:#keystone:f6zx0gURv@controller/keystone #mysql(数据库类型)keystone(用户名)f6zx0gURv(密码)controller(登陆的服务器)keystone(进入的数据库)
[memcache]
servers = localhost:11211
[token]
provider = uuid
driver = memcache
[revoke]
driver = sql
增加identity - 导入数据(controller)
导入keystone相关的数据
su -s /bin/sh -c "keystone-manage db_sync" keystone
这里会有个提示 No handlers could be found for logger "oslo_config.cfg" 忽略它,不影响
检查有没有正常导入数据:
mysql -ukeystone -pf6zx0gURv -hcontroller -t keystone -e "show tables" 看是否有列出表来,如果是空,说明没有成功导入数据
配置apache
先编辑配置文件 /etc/httpd/conf/httpd.conf
增加或更改
ServerName controller
增加identity - 配置httpd子配置文件(controller)
编辑配置文件 vim /etc/httpd/conf.d/wsgi-keystone.conf 内容如下
Listen 5000
Listen 35357
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
Require all granted
Order allow,deny
Allow from all
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
Require all granted
Order allow,deny
Allow from all
启动apache
systemctl enable httpd.service
systemctl start httpd.service
增加identity - 创建服务实例(controller)
首先设置环境变量:
export OS_TOKEN=3qiVpzU2x
export OS_URL=http:#controller:35357/v3
export OS_IDENTITY_API_VERSION=3
然后创建服务实例
openstack service create --name keystone --description "OpenStack Identity" identity
创建端点
openstack endpoint create --region RegionOne identity public http:#controller:5000/v2.0
openstack endpoint create --region RegionOne identity internal http:#controller:5000/v2.0
openstack endpoint create --region RegionOne identity admin http:#controller:35357/v2.0
创建租户(tenants)、用户以及角色
创建admin 租户
openstack project create --domain default --description "Admin Project" admin
创建admin用户 (密码为3qiVpzU2x)
openstack user create --domain default --password-prompt admin
创建admin角色
openstack role create admin
添加admin角色到admin租户和用户
openstack role add --project admin --user admin admin
下面我们再来创建一个service 租户
openstack project create --domain default --description "Service Project" service
创建demo租户
openstack project create --domain default --description "Demo Project" demo
创建demo用户 (密码9TtbgaA1q)
openstack user create --domain default --password-prompt demo
创建user角色
openstack role create user
添加user角色到demo租户和demo用户
openstack role add --project demo --user demo user
验证admin用户和demo用户是否能正常登陆
首先做一个安全设置:
vim /usr/share/keystone/keystone-dist-paste.ini
搜索admin_token_auth, 从[pipeline:public_api], [pipeline:admin_api]和[pipeline:api_v3]中,把admin_token_auth去掉,例如把
pipeline = sizelimit url_normalize request_id build_auth_context token_auth admin_token_auth json_body ec2_extension user_crud_extension public_service
改为
pipeline = sizelimit url_normalize request_id build_auth_context token_auth json_body ec2_extension user_crud_extension public_service
取消环境变量OS_TOKEN和OS_URL
unset OS_TOKEN OS_URL
然后再登陆admin和demo用户
openstack --os-auth-url http:#controller:35357/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name admin --os-username admin --os-auth-type password token issue
openstack --os-auth-url http:#controller:5000/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name demo --os-username demo --os-auth-type password token issue
增加identity - 验证操作(controller)
创建openstack客户端脚本
vi admin-openrc.sh //内容
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=3qiVpzU2x
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
执行脚本
source admin-openrc.sh
申请认证令牌
openstack token issue
创建openstack客户端脚本
vi demo-openrc.sh //内容
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=9TtbgaA1q
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
执行脚本
source demo-openrc.sh
申请认证令牌
openstack token issue