23rwd 发表于 2015-12-9 09:22:17

OpenStack - liberty CentOS 7

                      OpenStack私有云部署


Controller Node:       em1(10.6.17.11),em2()

Computer Node:         em1(10.6.17.12),em2()

Block Storage Node:    em1(10.6.17.13)

Object Storage Node:   em1(10.6.17.14)





1. Controller 修改网络配置


em1=

IPADDR=10.6.17.11
NETMASK=255.255.255.0
GATEWAY=10.6.17.1


em2=   (HWADDR与UUID 不变)

BOOTPROTO=none
ONBOOT=yes



Computer 修改网络配置


em1=

IPADDR=10.6.17.12
NETMASK=255.255.255.0
GATEWAY=10.6.17.1


em2=   (HWADDR与UUID 不变)

BOOTPROTO=none
ONBOOT=yes




2. 修改节点 主机名 方便后续查看

centos 7 使用如下命令修改:

hostnamectl --static set-hostname <主机名>

-----------------------------------------------------

3. 修改 host 文件四台主机分别修改

vi /etc/hosts

10.6.17.11 controller
10.6.17.12 computer1
10.6.17.13 block1
10.6.17.14 object1

----------------------------------------------------

修改完毕,使用 ping -c 4 openstack.org   以及    controller   computer1   block1   object1 是否可以通


4. controller 安装ntp服务!

centos 7 使用 chrony 来做时间服务器.

#yum install chrony

##修改配置文件
# vi /etc/chrony.conf

server cn.pool.ntp.org iburst


allow 10.6.17.0/24



# systemctl enable chronyd.service
# systemctl start chronyd.service
# systemctl stop firewalld.service
# systemctl disable firewalld.service

##其他节点 也分别安装 chrony

yum install chrony


##修改 配置文件

vi /etc/chrony.conf

server controller iburst


systemctl enable chronyd.service
systemctl start chronyd.service
systemctl stop firewalld.service
systemctl disable firewalld.service


##验证时间


# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* news.neu.edu.cn               2   6    17    44   -795us[ -812us] +/-   31ms




# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* controller                  3   6    17    35-1007ns[ -300us] +/-   33ms



# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* controller                  3   6    37   5   -8ns[ -385us] +/-   30ms



# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* controller                  3   6    37   6   -707ns[ -548us] +/-   31ms






5. 添加 yum ELPL 源 以及 openstack-liberty 源


# yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

# yum install centos-release-openstack-liberty


# yum upgrade

# reboot

# yum install python-openstackclient

# yum install openstack-selinux




6. controller 安装 mariadb 数据库

使用 yum 安装,或者使用 源码安装

# yum install mariadb mariadb-server MySQL-python


my.conf 中添加如下配置 以支持 utf8


...
bind-address = 10.6.17.11




...
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8



# systemctl enable mariadb.service
# systemctl start mariadb.service



7. controller 安装 rabbitMQ 消息队列

# yum install rabbitmq-server

# systemctl enable rabbitmq-server.service
# systemctl start rabbitmq-server.service

## 添加 openstack 用户 ( RABBIT_PASS 替换为 自己的密码 )

# rabbitmqctl add_user openstack RABBIT_PASS
Creating user "openstack" ...
...done.



## 授权帐号

# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...
...done.



二、 配置 Identity service 服务

## 创建 OpenStack Identity service 的 管理员 帐号

# mysql -u root -p

MariaDB [(none)]> CREATE DATABASE keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
    -> IDENTIFIED BY 'keystone';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
    -> IDENTIFIED BY 'keystone';


## 创建 管理员 token
# openssl rand -hex 10
d22ea88344b5d4fa864f


## 安装openstack-keystone 组件

# yum install openstack-keystone httpd mod_wsgi memcached python-memcached

# systemctl enable memcached.service
# systemctl start memcached.service


## 编辑 /etc/keystone/keystone.conf 文件 修改 token

# vim /etc/keystone/keystone.conf

#admin_token = ADMIN

修改为 刚才生成的 token

admin_token = d22ea88344b5d4fa864f



...
connection = mysql://keystone:keystone@controller/keystone



...
servers = localhost:11211



...
provider = uuid
driver = memcache



...
driver = sql



...
verbose = True


## 同步Identity service 数据库

# su -s /bin/sh -c "keystone-manage db_sync" keystone

提示 No handlers could be found for logger "oslo_config.cfg"   但是查看keystone.log 日志,发现已经同步完成。




## 配置 httpd 文件

# vim /etc/httpd/conf/httpd.conf            修改如下:


ServerName controller


## 创建一个 wsgi-keystone.conf 文件

# 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
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
      <IfVersion >= 2.4>
            Require all granted
      </IfVersion>
      <IfVersion < 2.4>
            Order allow,deny
            Allow from all
      </IfVersion>
    </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
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
      <IfVersion >= 2.4>
            Require all granted
      </IfVersion>
      <IfVersion < 2.4>
            Order allow,deny
            Allow from all
      </IfVersion>
    </Directory>
</VirtualHost>


------------------------------------------------------------------------------------------------------------------------------------

## 启动 httpd
# systemctl enable httpd.service
# systemctl start httpd.service




## 配置 身份验证 token:            

# export OS_TOKEN=d22ea88344b5d4fa864f
# export OS_URL=http://controller:35357/v3
# export OS_IDENTITY_API_VERSION=3


## 创建API用户

# openstack service create \
> --name keystone --description "OpenStack Identity" identity

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Identity               |
| enabled   | True                           |
| id          | 528702ea888749d8b91cdf303cbec285 |
| name      | keystone                         |
| type      | identity                         |
+-------------+----------------------------------+


## 创建 API访问节点

# openstack endpoint create --region RegionOne \
> identity public http://controller:5000/v2.0

+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | 6d1d13e2a74940338337e2faeb404291 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 528702ea888749d8b91cdf303cbec285 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller:5000/v2.0      |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> identity internal http://controller:5000/v2.0
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | 1a6e4df9f7fb444f98da5274c4b45916 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 528702ea888749d8b91cdf303cbec285 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller:5000/v2.0      |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> identity admin http://controller:35357/v2.0
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | 08e839319e5143229abc893e413e0dcc |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 528702ea888749d8b91cdf303cbec285 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller:35357/v2.0   |
+--------------+----------------------------------+


## 创建 admin 项目

# openstack project create --domain default \
> --description "Admin Project" admin
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Admin Project                  |
| domain_id   | default                        |
| enabled   | True                           |
| id          | 0d1a69b17e444cb3b4884529b6bdb372 |
| is_domain   | False                            |
| name      | admin                            |
| parent_id   | None                           |
+-------------+----------------------------------+


## 创建 管理员 用户

# openstack user create --domain default \
> --password-prompt admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 28c24be804a649cb825a8349ca3e6ce3 |
| name      | admin                            |
+-----------+----------------------------------+


## 创建 管理员 role

# openstack role create admin
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | c378be38e9574421a54d90e62ee2d0aa |
| name| admin                            |
+-------+----------------------------------+


## 关联 管理员用户 到 项目与role 中

# openstack role add --project admin --user admin admin



## 创建 service 项目

# openstack project create --domain default \
> --description "Service Project" service
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Service Project                  |
| domain_id   | default                        |
| enabled   | True                           |
| id          | 90b44e1c63104b92a1fadccc2258bbd1 |
| is_domain   | False                            |
| name      | service                        |
| parent_id   | None                           |
+-------------+----------------------------------+





## 验证账户

编辑 /usr/share/keystone/keystone-dist-paste.ini 文件

# vim /usr/share/keystone/keystone-dist-paste.ini









中的

admin_token_auth   删除



## 清除环境变量
# unset OS_TOKEN OS_URL


## 以管理员身份 创建一个 token

# 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
Password:
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2015-12-03T04:03:34.754196Z      |
| id         | cba3fce8d9dc4bc7956f3b4aa566051c |
| project_id | 0d1a69b17e444cb3b4884529b6bdb372 |
| user_id    | 28c24be804a649cb825a8349ca3e6ce3 |
+------------+----------------------------------+



## 创建完成,表示验证通过



## 创建一个 客户端 脚本,方便操作

# vim 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=admin
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3



## 导入 脚本,并测试

# source admin-openrc.sh

# openstack token issue
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2015-12-03T04:07:26.391998Z      |
| id         | 24a890cc24b443dc9658a34aba8462d8 |
| project_id | 0d1a69b17e444cb3b4884529b6bdb372 |
| user_id    | 28c24be804a649cb825a8349ca3e6ce3 |
+------------+----------------------------------+


## 验证通过



三、安装配置 image server

## 创建并导入数据库

# mysql -u root -p
Enter password:

MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
    -> IDENTIFIED BY 'glance';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
    -> IDENTIFIED BY 'glance';


## 导入 脚本 创建用户

# source admin-openrc.sh


## 创建 glance用户

# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 19121c440d77403e8b66f197381c68e9 |
| name      | glance                           |
+-----------+----------------------------------+



## 关联到 项目 与 admin 用户

# openstack role add --project service --user glance admin



## 创建 glance 服务

# openstack service create --name glance \
> --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled   | True                           |
| id          | bb8f3d6386cb423eb682147cf2b5ab92 |
| name      | glance                           |
| type      | image                            |
+-------------+----------------------------------+


## 创建 image API

# openstack endpoint create --region RegionOne \
> image public http://controller:9292
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | ac858877305542679883df3afb974a95 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | bb8f3d6386cb423eb682147cf2b5ab92 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292         |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> image internal http://controller:9292
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | 290dc30efb6b45c9bb654252aaf8b878 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | bb8f3d6386cb423eb682147cf2b5ab92 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292         |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> image admin http://controller:9292
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | 04fac23ce557445d92d77ca53cf4c620 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | bb8f3d6386cb423eb682147cf2b5ab92 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292         |
+--------------+----------------------------------+



## 安装配置 glance 相关软件

# yum install openstack-glance python-glance python-glanceclient -y



## 编辑 /etc/glance/glance-api.conf 配置文件

# vim /etc/glance/glance-api.conf


...
connection = mysql://glance:glance@controller/glance



...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance


...
flavor = keystone



...
default_store = file
filesystem_store_datadir = /opt/glance/images/



...
notification_driver = noop



...
verbose = True



## 编辑 /etc/glance/glance-registry.conf 配置文件

# vim /etc/glance/glance-registry.conf



...
connection = mysql://glance:glance@controller/glance



...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance



...
flavor = keystone



...
notification_driver = noop



...
verbose = True


## 同步 glance 数据库

# su -s /bin/sh -c "glance-manage db_sync" glance



## 启动服务

# systemctl enable openstack-glance-api.service \
> openstack-glance-registry.service

# systemctl start openstack-glance-api.service \
> openstack-glance-registry.service



## 验证 glance 服务

添加一个环境变量到 脚本中

# echo "export OS_IMAGE_API_VERSION=2" \
> | tee -a admin-openrc.sh

# source admin-openrc.sh


## 下载一个测试镜像

wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img


## 上传镜像到 服务中
# glance image-create --name "cirros" \
> --file cirros-0.3.4-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --visibility public --progress

[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                              |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6   |
| container_format | bare                                 |
| created_at       | 2015-12-03T05:05:33Z               |
| disk_format      | qcow2                              |
| id               | 3846ec1a-ad85-4b4d-88d9-17f2374ed41d |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros                               |
| owner            | 0d1a69b17e444cb3b4884529b6bdb372   |
| protected      | False                              |
| size             | 13287936                           |
| status         | active                               |
| tags             | []                                 |
| updated_at       | 2015-12-03T05:05:33Z               |
| virtual_size   | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+


# glance image-list
+--------------------------------------+--------+
| ID                                 | Name   |
+--------------------------------------+--------+
| 3846ec1a-ad85-4b4d-88d9-17f2374ed41d | cirros |
+--------------------------------------+--------+





四、安装配置 Computer server


## 添加数据库 与 用户

# mysql -u root -p
Enter password:

MariaDB [(none)]> CREATE DATABASE nova;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
    -> IDENTIFIED BY 'nova';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
    -> IDENTIFIED BY 'nova';


## 创建 nova 用户

# source admin-openrc.sh

# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 05dfb9b8091b4d708455281540a030d1 |
| name      | nova                           |
+-----------+----------------------------------+

## 关联 到 role

# openstack role add --project service --user nova admin


## 创建 nova service
# openstack service create --name nova \
> --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled   | True                           |
| id          | 1f73377bd0bc4f208ca6c904a71e6279 |
| name      | nova                           |
| type      | compute                        |
+-------------+----------------------------------+


## 创建 Compute service API

# openstack endpoint create --region RegionOne \
> compute public http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | b545b7bd81ed4b64b559b905dd3b4532      |
| interface    | public                                  |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 1f73377bd0bc4f208ca6c904a71e6279      |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+


# openstack endpoint create --region RegionOne \
> compute internal http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 5b23e9f26e094f8f99a4416a085b6fc8      |
| interface    | internal                              |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 1f73377bd0bc4f208ca6c904a71e6279      |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> compute admin http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 77638cfde23049cd9bf1c06347385562      |
| interface    | admin                                 |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 1f73377bd0bc4f208ca6c904a71e6279      |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+



##controller 安装软件

# yum install openstack-nova-api openstack-nova-cert \
> openstack-nova-conductor openstack-nova-console \
> openstack-nova-novncproxy openstack-nova-scheduler \
> python-novaclient


## 编辑 /etc/nova/nova.conf配置文件



...
connection = mysql://nova:nova@controller/nova



...
rpc_backend = rabbit
my_ip = 10.6.17.11
auth_strategy = keystone
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
verbose = True



...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack



...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = nova
password = nova




...
host = controller




...
lock_path = /var/lib/nova/tmp





## 同步数据库

su -s /bin/sh -c "nova-manage db sync" nova


## 启动服务

# systemctl enable openstack-nova-api.service \
> openstack-nova-cert.service openstack-nova-consoleauth.service \
> openstack-nova-scheduler.service openstack-nova-conductor.service \
> openstack-nova-novncproxy.service


# systemctl start openstack-nova-api.service \
> openstack-nova-cert.service openstack-nova-consoleauth.service \
> openstack-nova-scheduler.service openstack-nova-conductor.service \
> openstack-nova-novncproxy.service




## 安装配置 计算机节点 Compute 节点

yum install openstack-nova-compute sysfsutils


## 编辑 /etc/nova/nova.conf 配置文件




...
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 10.6.17.12
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
verbose = True



...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack



...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = nova
password = nova



...
host = controller



...
lock_path = /var/lib/nova/tmp



## 查看否支持 虚拟化 大于0 表示支持, 大于0 不需要添加配置支持

# egrep -c '(vmx|svm)' /proc/cpuinfo
8


## 如果 硬件不支持虚拟化 则添加虚拟化支持

# vim /etc/nova/nova.conf


...
virt_type = qemu




## 启动服务

# systemctl enable libvirtd.service openstack-nova-compute.service
# systemctl start libvirtd.service openstack-nova-compute.service



## 验证 服务

# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary         | Host       | Zone   | Status| State | Updated_at               | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1| nova-consoleauth | controller | internal | enabled | up    | 2015-12-03T07:06:27.000000 | -               |
| 2| nova-conductor   | controller | internal | enabled | up    | 2015-12-03T07:06:27.000000 | -               |
| 5| nova-cert      | controller | internal | enabled | up    | 2015-12-03T07:06:27.000000 | -               |
| 6| nova-scheduler   | controller | internal | enabled | up    | 2015-12-03T07:06:27.000000 | -               |
| 7| nova-compute   | computer1| nova   | enabled | up    | 2015-12-03T07:06:31.000000 | -               |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+


# nova endpoints

+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id      | 5b23e9f26e094f8f99a4416a085b6fc8                           |
| interface | internal                                                   |
| region    | RegionOne                                                |
| region_id | RegionOne                                                |
| url       | http://controller:8774/v2/0d1a69b17e444cb3b4884529b6bdb372 |
+-----------+------------------------------------------------------------+
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id      | 77638cfde23049cd9bf1c06347385562                           |
| interface | admin                                                      |
| region    | RegionOne                                                |
| region_id | RegionOne                                                |
| url       | http://controller:8774/v2/0d1a69b17e444cb3b4884529b6bdb372 |
+-----------+------------------------------------------------------------+
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id      | b545b7bd81ed4b64b559b905dd3b4532                           |
| interface | public                                                   |
| region    | RegionOne                                                |
| region_id | RegionOne                                                |
| url       | http://controller:8774/v2/0d1a69b17e444cb3b4884529b6bdb372 |
+-----------+------------------------------------------------------------+


+-----------+----------------------------------+
| keystone| Value                            |
+-----------+----------------------------------+
| id      | 08e839319e5143229abc893e413e0dcc |
| interface | admin                            |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:35357/v2.0   |
+-----------+----------------------------------+
+-----------+----------------------------------+
| keystone| Value                            |
+-----------+----------------------------------+
| id      | 1a6e4df9f7fb444f98da5274c4b45916 |
| interface | internal                         |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:5000/v2.0      |
+-----------+----------------------------------+
+-----------+----------------------------------+
| keystone| Value                            |
+-----------+----------------------------------+
| id      | 6d1d13e2a74940338337e2faeb404291 |
| interface | public                           |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:5000/v2.0      |
+-----------+----------------------------------+


+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id      | 04fac23ce557445d92d77ca53cf4c620 |
| interface | admin                            |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292         |
+-----------+----------------------------------+
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id      | 290dc30efb6b45c9bb654252aaf8b878 |
| interface | internal                         |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292         |
+-----------+----------------------------------+
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id      | ac858877305542679883df3afb974a95 |
| interface | public                           |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292         |
+-----------+----------------------------------+


# nova image-list
+--------------------------------------+--------+--------+--------+
| ID                                 | Name   | Status | Server |
+--------------------------------------+--------+--------+--------+
| 3846ec1a-ad85-4b4d-88d9-17f2374ed41d | cirros | ACTIVE |      |
+--------------------------------------+--------+--------+--------+





五、安装配置 Network server

## 添加数据库、用户

# mysql -u root -p
Enter password:

MariaDB [(none)]> CREATE DATABASE neutron;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
    -> IDENTIFIED BY 'neutron';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
    -> IDENTIFIED BY 'neutron';


## 添加 openstack 用户

# openstack user create --domain default --password-prompt neutron
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 04b2950e0b96451494a4391c5c7bcd2e |
| name      | neutron                        |
+-----------+----------------------------------+


# openstack role add --project service --user neutron admin



## 添加 neutron service

# openstack service create --name neutron \
> --description "OpenStack Networking" network
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Networking             |
| enabled   | True                           |
| id          | b9ca3cbea4df4966bbfff153e676d404 |
| name      | neutron                        |
| type      | network                        |
+-------------+----------------------------------+


## 添加 network server API

# openstack endpoint create --region RegionOne \
> network public http://controller:9696
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | e741a15b8f4f424d8ac605083d079911 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b9ca3cbea4df4966bbfff153e676d404 |
| service_name | neutron                        |
| service_type | network                        |
| url          | http://controller:9696         |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> network internal http://controller:9696
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | ba9df6bd296f4f42bd24588b292ed54b |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b9ca3cbea4df4966bbfff153e676d404 |
| service_name | neutron                        |
| service_type | network                        |
| url          | http://controller:9696         |
+--------------+----------------------------------+


# openstack endpoint create --region RegionOne \
> network admin http://controller:9696
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | ba86430058a243da8c50ab9d42178eab |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b9ca3cbea4df4966bbfff153e676d404 |
| service_name | neutron                        |
| service_type | network                        |
| url          | http://controller:9696         |
+--------------+----------------------------------+


## 安装配置 network 软件( 我这里选择的是 Networking Option 1: Provider networks这种网络方式 )


# yum install openstack-neutron openstack-neutron-ml2 \
> openstack-neutron-linuxbridge python-neutronclient ebtables ipset


## 修改配置文件 /etc/neutron/neutron.conf



...
connection = mysql://neutron:neutron@controller/neutron




...
core_plugin = ml2
service_plugins =
rpc_backend = rabbit
auth_strategy = keystone
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://controller:8774/v2
verbose = True



...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack



## 检查 下面配置,注释掉其他所有的选项只使用下面


...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = neutron





...
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = nova
password = nova




...
lock_path = /var/lib/neutron/tmp



##配置 Layer 2 (ML2) 插件

编辑 /etc/neutron/plugins/ml2/ml2_conf.ini配置文件

# vim /etc/neutron/plugins/ml2/ml2_conf.ini



...
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security



...
flat_networks = public




...
enable_ipset = True



## 配置Linux bridge

编辑 /etc/neutron/plugins/ml2/linuxbridge_agent.ini配置文件




physical_interface_mappings = public:em2




enable_vxlan = False




...
prevent_arp_spoofing = True




...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver



## 配置 DHCP 服务

编辑 /etc/neutron/dhcp_agent.ini 配置文件



...
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
verbose = True



## 配置 metadata 服务

编辑 /etc/neutron/metadata_agent.ini 配置文件注释掉 下面的选项,添加如下选项



...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_region = RegionOne
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = neutron
nova_metadata_ip = controller
metadata_proxy_shared_secret = metadata
verbose = True



## 配置 Networking 服务

编辑 /etc/nova/nova.conf 配置文件




...
url = http://controller:9696
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron

service_metadata_proxy = True
metadata_proxy_shared_secret = metadata



## 创建一些链接

# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini


## 同步数据库

# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
> --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron


INFO Context impl MySQLImpl.
........
OK



## 重启 api 服务

# systemctl restart openstack-nova-api.service


## 启动 network 服务


# systemctl enable neutron-server.service \
> neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
> neutron-metadata-agent.service


# systemctl start neutron-server.service \
> neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
> neutron-metadata-agent.service



## 配置 Compute 节点的 network 服务

## 安装 network 软件

# yum install openstack-neutron openstack-neutron-linuxbridge ebtables ipset



## 编辑 /etc/neutron/neutron.conf 配置文件

注释掉 部分的所有选项,计算节点 不连接 数据库



...
rpc_backend = rabbit
auth_strategy = keystone
verbose = True



...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack




...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = neutron


注释掉 其他部分的选项。



...
lock_path = /var/lib/neutron/tmp



##安装 network 服务

## 配置 Linux bridge 服务

编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini 配置文件



physical_interface_mappings = public:em2



enable_vxlan = False



...
prevent_arp_spoofing = True



...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver



## 配置 Networking 服务

## 编辑 /etc/nova/nova.conf 配置文件



...
url = http://controller:9696
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron




## 配置链接, 并启动服务

# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
# systemctl restart openstack-nova-compute.service
# systemctl enable neutron-linuxbridge-agent.service
# systemctl start neutron-linuxbridge-agent.service



## 最后 验证服务

# source admin-openrc.sh

# neutron ext-list
+-----------------------+--------------------------+
| alias               | name                     |
+-----------------------+--------------------------+
| flavors               | Neutron Service Flavors|
| security-group      | security-group         |
| dns-integration       | DNS Integration          |
| net-mtu               | Network MTU            |
| port-security         | Port Security            |
| binding               | Port Binding             |
| provider            | Provider Network         |
| agent               | agent                  |
| quotas                | Quota management support |
| subnet_allocation   | Subnet Allocation      |
| dhcp_agent_scheduler| DHCP Agent Scheduler   |
| rbac-policies         | RBAC Policies            |
| external-net          | Neutron external network |
| multi-provider      | Multi Provider Network   |
| allowed-address-pairs | Allowed Address Pairs    |
| extra_dhcp_opt      | Neutron Extra DHCP opts|
+-----------------------+--------------------------+


# neutron agent-list
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+
| id                                 | agent_type         | host       | alive | admin_state_up | binary                  |
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+
| 3083cb45-f248-4de5-828e-38d9bc961814 | Linux bridge agent | controller | :-)   | True         | neutron-linuxbridge-agent |
| 3b2564c7-e797-4e20-a257-166ade425655 | Linux bridge agent | computer1| :-)   | True         | neutron-linuxbridge-agent |
| b61a8667-416d-4ed5-b14d-87d568bab59f | Metadata agent   | controller | :-)   | True         | neutron-metadata-agent    |
| f87d6cc0-4277-4259-96ed-638294503236 | DHCP agent         | controller | :-)   | True         | neutron-dhcp-agent      |
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+





六、安装配置 dashboard

# yum install openstack-dashboard -y

## 编辑/etc/openstack-dashboard/local_settings 配置文件

# vim /etc/openstack-dashboard/local_settings

OPENSTACK_HOST = "controller"

ALLOWED_HOSTS = ['*', ]

CACHES = {
    'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': '127.0.0.1:11211',
    }
}


OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"

TIME_ZONE = "Asia/Shanghai"


## 启动服务
# systemctl enable httpd.service memcached.service

# systemctl restart httpd.service memcached.service


## 验证服务

浏览器 访问 http://controller/dashboard

帐号密码为 admin




七、 安装配置 Block Storage service

控制端

## 添加数据库

# mysql -u root -p
Enter password:

MariaDB [(none)]> CREATE DATABASE cinder;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
    -> IDENTIFIED BY 'cinder';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
    -> IDENTIFIED BY 'cinder';


## 添加 openstackcinder用户

# source admin-openrc.sh

# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 212ced82b0a844f099a80a712786740c |
| name      | cinder                           |
+-----------+----------------------------------+


# openstack role add --project service --user cinder admin


## 添加 cinder v2 service 服务

# openstack service create --name cinder \
> --description "OpenStack Block Storage" volume
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled   | True                           |
| id          | 6af1b2a1843f42058b03368960ae6b09 |
| name      | cinder                           |
| type      | volume                           |
+-------------+----------------------------------+


# openstack service create --name cinderv2 \
> --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled   | True                           |
| id          | 3e42f0d7868745579ce658d88eef4c67 |
| name      | cinderv2                         |
| type      | volumev2                         |
+-------------+----------------------------------+


## 添加 Block Storage service API

# openstack endpoint create --region RegionOne \
> volume public http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 14ee6bd40f08489bb314e5cc5fa39a80      |
| interface    | public                                  |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 6af1b2a1843f42058b03368960ae6b09      |
| service_name | cinder                                  |
| service_type | volume                                  |
| url          | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> volume internal http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 5895f13f971a4ee390ef104ddbe7422b      |
| interface    | internal                              |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 6af1b2a1843f42058b03368960ae6b09      |
| service_name | cinder                                  |
| service_type | volume                                  |
| url          | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> volume admin http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | e4993535c6504f95862cab4f7ab7cccb      |
| interface    | admin                                 |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 6af1b2a1843f42058b03368960ae6b09      |
| service_name | cinder                                  |
| service_type | volume                                  |
| url          | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> volumev2 public http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 8696e7142c17488e973c653713c14379      |
| interface    | public                                  |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 3e42f0d7868745579ce658d88eef4c67      |
| service_name | cinderv2                              |
| service_type | volumev2                              |
| url          | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | da6b9e902a4d413dadd951ec751b1082      |
| interface    | internal                              |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 3e42f0d7868745579ce658d88eef4c67      |
| service_name | cinderv2                              |
| service_type | volumev2                              |
| url          | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+



# openstack endpoint create --region RegionOne \
> volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field      | Value                                 |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id         | 0cfa27d0a5b946e8b35901d242ac165f      |
| interface    | admin                                 |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 3e42f0d7868745579ce658d88eef4c67      |
| service_name | cinderv2                              |
| service_type | volumev2                              |
| url          | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+



## 安装以及配置

# yum install openstack-cinder python-cinderclient -y


## 编辑 /etc/cinder/cinder.conf 配置文件

# vim /etc/cinder/cinder.conf




...
connection = mysql://cinder:cinder@controller/cinder




...
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 10.6.17.11
verbose = True




...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack



注释掉 其他部分的选项。添加如下内容:


...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = cinder




...
lock_path = /var/lib/cinder/tmp





## 同步数据库

# su -s /bin/sh -c "cinder-manage db sync" cinder



## 编辑/etc/nova/nova.conf 配置文件


os_region_name = RegionOne



## 启动服务

# systemctl restart openstack-nova-api.service


# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service




## Storage 节点操作

## 安装软件
# yum install lvm2



## 启动 LVM2 服务
# systemctl enable lvm2-lvmetad.service
# systemctl start lvm2-lvmetad.service


## 创建分区

# fdisk -l

磁盘 /dev/sda:599.6 GB, 599550590976 字节,1170997248 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000e0185

   设备 Boot      Start         End      Blocks   IdSystem
/dev/sda1   *      2048   2099199   1048576   83Linux
/dev/sda2         2099200   211814399   104857600   83Linux
/dev/sda3       211814400   211830783      8192   82Linux swap / Solaris


## 使用 parted 软件,查看分区
# parted /dev/sda
GNU Parted 3.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                               
Model: Dell Virtual Disk (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

NumberStart   End   Size    Type   File system   标志
1      1049kB1075MB1074MBprimaryxfs             启动
2      1075MB108GB   107GB   primaryxfs
3      108GB   108GB   8389kBprimarylinux-swap(v1)


## 使用 parted 软件, 创建分区

(parted) mkpart primary 108GB 208GB                                       
(parted) p                                                               
Model: Dell Virtual Disk (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

NumberStart   End   Size    Type   File system   标志
1      1049kB1075MB1074MBprimaryxfs             启动
2      1075MB108GB   107GB   primaryxfs
3      108GB   108GB   8389kBprimarylinux-swap(v1)
4      108GB   208GB   99.5GBprimary


# fdisk -l

磁盘 /dev/sda:599.6 GB, 599550590976 字节,1170997248 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000e0185

   设备 Boot      Start         End      Blocks   IdSystem
/dev/sda1   *      2048   2099199   1048576   83Linux
/dev/sda2         2099200   211814399   104857600   83Linux
/dev/sda3       211814400   211830783      8192   82Linux swap / Solaris
/dev/sda4       211830784   406249471    97209344   83Linux


# pvcreate /dev/sda4
Physical volume "/dev/sda4" successfully created


# vgcreate cinder-volumes /dev/sda4
Volume group "cinder-volumes" successfully created


## 编辑 /etc/lvm/lvm.conf配置文件,添加分区

devices {
...
filter = [ "a/sda4/", "r/.*/"]





## 安装 openstack 软件

# yum install openstack-cinder targetcli python-oslo-policy -y



## 编辑 /etc/cinder/cinder.conf 配置文件




...
connection = mysql://cinder:cinder@controller/cinder



...
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 10.6.17.13
enabled_backends = lvm
glance_host = controller
verbose = True
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm



...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack



# 注释掉下其他所有的选项 只使用下面


...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = cinder





...
lock_path = /var/lib/cinder/tmp




## 启动 服务

# systemctl enable openstack-cinder-volume.service target.service

# systemctl start openstack-cinder-volume.service target.service



## 验证服务

# source admin-openrc.sh

# cinder service-list
+------------------+------------+------+---------+-------+----------------------------+-----------------+
|      Binary      |    Host    | Zone |Status | State |         Updated_at         | Disabled Reason |
+------------------+------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller | nova | enabled |   up| 2015-12-04T07:35:57.000000 |      -      |
|cinder-volume   | block1@lvm | nova | enabled |   up| 2015-12-04T07:36:03.000000 |      -      |
+------------------+------------+------+---------+-------+----------------------------+-----------------+



八、 安装配置 Object Storage 服务


## 创建 openstack 帐号

# openstack user create --domain default --password-prompt swift
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 7a2915af03464268ab80ef732aa5ba93 |
| name      | swift                            |
+-----------+----------------------------------+


# openstack role add --project service --user swift admin


## 创建 swift service

# openstack service create --name swift \
> --description "OpenStack Object Storage" object-store
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Object Storage         |
| enabled   | True                           |
| id          | f7b97bc04bd24d67b12694bb3004843b |
| name      | swift                            |
| type      | object-store                     |
+-------------+----------------------------------+


## 创建 Object Storage service API

# openstack endpoint create --region RegionOne \
> object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s
+--------------+----------------------------------------------+
| Field      | Value                                        |
+--------------+----------------------------------------------+
| enabled      | True                                       |
| id         | f8d7a017753947d981e0f42aa5fe4bde             |
| interface    | public                                       |
| region       | RegionOne                                    |
| region_id    | RegionOne                                    |
| service_id   | f7b97bc04bd24d67b12694bb3004843b             |
| service_name | swift                                        |
| service_type | object-store                                 |
| url          | http://controller:8080/v1/AUTH_%(tenant_id)s |
+--------------+----------------------------------------------+



# openstack endpoint create --region RegionOne \
> object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s
+--------------+----------------------------------------------+
| Field      | Value                                        |
+--------------+----------------------------------------------+
| enabled      | True                                       |
| id         | 6d125e48860b4f948300b412f744b23f             |
| interface    | internal                                     |
| region       | RegionOne                                    |
| region_id    | RegionOne                                    |
| service_id   | f7b97bc04bd24d67b12694bb3004843b             |
| service_name | swift                                        |
| service_type | object-store                                 |
| url          | http://controller:8080/v1/AUTH_%(tenant_id)s |
+--------------+----------------------------------------------+



# openstack endpoint create --region RegionOne \
> object-store admin http://controller:8080/v1
+--------------+----------------------------------+
| Field      | Value                            |
+--------------+----------------------------------+
| enabled      | True                           |
| id         | cdbea58743c946cca41c98682ea98793 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f7b97bc04bd24d67b12694bb3004843b |
| service_name | swift                            |
| service_type | object-store                     |
| url          | http://controller:8080/v1      |
+--------------+----------------------------------+



## 安装配置软件

# yum install openstack-swift-proxy python-swiftclient \
> python-keystoneclient python-keystonemiddleware \
> memcached



## 下载swift配置文件

# curl -o /etc/swift/proxy-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/liberty


##编辑 /etc/swift/proxy-server.conf 配置文件



...
bind_port = 8080
user = swift
swift_dir = /etc/swift



pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server



use = egg:swift#proxy
...
account_autocreate = true



use = egg:swift#keystoneauth
...
operator_roles = admin,user


#注释掉 其他所有的选项只使用下面


paste.filter_factory = keystonemiddleware.auth_token:filter_factory
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = swift
password = swift
delay_auth_decision = true




use = egg:swift#memcache
...
memcache_servers = 127.0.0.1:11211



## Object storage 节点配置

## 安装配置软件

# yum install xfsprogs rsync -y


# fdisk -l

磁盘 /dev/sda:599.6 GB, 599550590976 字节,1170997248 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000bbc86

   设备 Boot      Start         End      Blocks   IdSystem
/dev/sda1   *      2048   204802047   102400000   83Linux
/dev/sda2       204802048   221186047   8192000   82Linux swap / Solaris
/dev/sda3       221186048   611327999   195070976   83Linux
/dev/sda4       6113280001170997247   279834624   83Linux


# mkfs.xfs -f /dev/sda3
# mkfs.xfs -f /dev/sda4

# mkdir -p /opt/node/sda3
# mkdir -p /opt/node/sda4


## 编辑 /etc/fstab让系统启动自动加载

/dev/sda3 /opt/node/sda3 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sda4 /opt/node/sda4 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2


## 挂载硬盘
# mount -a



# df -h
文件系统      容量已用可用 已用% 挂载点
/dev/sda1      98G1.2G   97G    2% /
devtmpfs      7.8G   07.8G    0% /dev
tmpfs         7.8G   07.8G    0% /dev/shm
tmpfs         7.8G8.4M7.8G    1% /run
tmpfs         7.8G   07.8G    0% /sys/fs/cgroup
/dev/sda3       186G   33M186G    1% /opt/node/sda3
/dev/sda4       267G   33M267G    1% /opt/node/sda4




## 编辑 /etc/rsyncd.conf 配置文件

# vim /etc/rsyncd.conf

--------------------------------------------------------
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 10.6.17.14


max connections = 2
path = /opt/node/
read only = false
lock file = /var/lock/account.lock


max connections = 2
path = /opt/node/
read only = false
lock file = /var/lock/container.lock


max connections = 2
path = /opt/node/
read only = false
lock file = /var/lock/object.lock

--------------------------------------------------------




## 启动服务

# systemctl enable rsyncd.service
# systemctl start rsyncd.service



## 安装配置软件
# yum install openstack-swift-account openstack-swift-container \
> openstack-swift-object


## 下载配置文件
# curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/liberty

# curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/liberty

# curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/liberty


## 编辑/etc/swift/account-server.conf 配置文件



...
bind_ip = 10.6.17.14
bind_port = 6002
user = swift
swift_dir = /etc/swift
devices = /opt/node
mount_check = true



pipeline = healthcheck recon account-server



use = egg:swift#recon
...
recon_cache_path = /var/cache/swift




## 编辑/etc/swift/container-server.conf 配置文件



...
bind_ip = 10.6.17.14
bind_port = 6001
user = swift
swift_dir = /etc/swift
devices = /opt/node
mount_check = true




pipeline = healthcheck recon container-server




use = egg:swift#recon
...
recon_cache_path = /var/cache/swift





## 编辑/etc/swift/object-server.conf 配置文件



...
bind_ip = 10.6.17.14
bind_port = 6000
user = swift
swift_dir = /etc/swift
devices = /opt/node
mount_check = true



pipeline = healthcheck recon object-server



use = egg:swift#recon
...
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock



## 授权目录

# chown -R swift:swift /opt/node



## 创建 swift 缓存 目录 cache/swift

# mkdir -p /var/cache/swift
# chown -R swift:swift /var/cache/swift



## 在controller 上创建 ring 帐号


## 创建 account.builder 文件

# cd /etc/swift/

# swift-ring-builder account.builder create 10 2 1





## 添加 object 节点

# swift-ring-builder account.builder add \
> --region 1 --zone 1 --ip 10.6.17.14 --port 6002 --device sda3 --weight 100

输出:
Device d0r1z1-10.6.17.14:6002R10.6.17.14:6002/sda3_"" with 100.0 weight got id 0


# swift-ring-builder account.builder add \
> --region 1 --zone 2 --ip 10.6.17.14 --port 6002 --device sda4 --weight 100

输出:
Device d1r1z2-10.6.17.14:6002R10.6.17.14:6002/sda4_"" with 100.0 weight got id 1



## 验证ring

# swift-ring-builder account.builder

account.builder, build version 2
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 2 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    idregionzone      ip addressportreplication ipreplication port      name weight partitions balance meta
             0       1   1      10.6.17.146002      10.6.17.14            6002      sda3 100.00          0 -100.00
             1       1   2      10.6.17.146002      10.6.17.14            6002      sda4 100.00          0 -100.00


# 平衡 ring
# swift-ring-builder account.builder rebalance

.......
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.Dispersion is now 0.00




## 创建容器 ring


# cd /etc/swift/

# swift-ring-builder container.builder create 10 2 1



## 创建存储节点ring

# swift-ring-builder container.builder add \
> --region 1 --zone 1 --ip 10.6.17.14 --port 6001 --device sda3 --weight 100

输出:
Device d0r1z1-10.6.17.14:6001R10.6.17.14:6001/sda3_"" with 100.0 weight got id 0





# swift-ring-builder container.builder add \
> --region 1 --zone 2 --ip 10.6.17.14 --port 6001 --device sda4 --weight 100

输出:
Device d1r1z2-10.6.17.14:6001R10.6.17.14:6001/sda4_"" with 100.0 weight got id 1



## 验证容器 ring

# swift-ring-builder container.builder

container.builder, build version 2
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 2 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    idregionzone      ip addressportreplication ipreplication port      name weight partitions balance meta
             0       1   1      10.6.17.146001      10.6.17.14            6001      sda3 100.00          0 -100.00
             1       1   2      10.6.17.146001      10.6.17.14            6001      sda4 100.00          0 -100.00


# 平衡 容器 ring
# swift-ring-builder container.builder rebalance

....
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.Dispersion is now 0.00




## 创建 object ring

# cd /etc/swift/

# swift-ring-builder object.builder create 10 2 1

# swift-ring-builder object.builder add \
> --region 1 --zone 1 --ip 10.6.17.14 --port 6001 --device sda3 --weight 100


输出:
Device d0r1z1-10.6.17.14:6001R10.6.17.14:6001/sda3_"" with 100.0 weight got id 0





# swift-ring-builder object.builder add \
> --region 1 --zone 2 --ip 10.6.17.14 --port 6001 --device sda4 --weight 100


输出:
Device d1r1z2-10.6.17.14:6001R10.6.17.14:6001/sda4_"" with 100.0 weight got id 1




## 验证 object ring

# swift-ring-builder object.builder

object.builder, build version 2
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 2 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    idregionzone      ip addressportreplication ipreplication port      name weight partitions balance meta
             0       1   1      10.6.17.146001      10.6.17.14            6001      sda3 100.00          0 -100.00
             1       1   2      10.6.17.146001      10.6.17.14            6001      sda4 100.00          0 -100.00





## 平衡 object ring

# swift-ring-builder object.builder rebalance

...
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.Dispersion is now 0.00



## 查看生成的文件

# ls
account.builderbackups            container-reconciler.confcontainer-server       object.builder       object.ring.gzproxy-server.conf
account.ring.gzcontainer.buildercontainer.ring.gz          container-server.confobject-expirer.confproxy-server    swift.conf



## 复制 account.ring.gzcontainer.ring.gz    object.ring.gz到 其他 运行 代理服务 的节点/etc/swift 目录中,然后启动 openstack-swift-proxy.service 服务





## Object Storage 下载 swift.conf 配置文件

# curl -o /etc/swift/swift.conf \
> https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/liberty



## 编辑 /etc/swift/swift.conf 配置文件

# vim /etc/swift/swift.conf




...
swift_hash_path_suffix = changeme
swift_hash_path_prefix = changeme



...
name = Policy-0
default = yes




## 授权 目录

# chown -R root:swift /etc/swift




## 在controller 以及 其他代理节点中 启动 代理服务


# systemctl enable openstack-swift-proxy.service memcached.service

# systemctl start openstack-swift-proxy.service memcached.service



## 在 Object Storage 节点中 启动服务

# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service \
> openstack-swift-account-reaper.service openstack-swift-account-replicator.service


# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service \
> openstack-swift-account-reaper.service openstack-swift-account-replicator.service


# systemctl enable openstack-swift-container.service \
> openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
> openstack-swift-container-updater.service


# systemctl start openstack-swift-container.service \
> openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
> openstack-swift-container-updater.service



# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service \
> openstack-swift-object-replicator.service openstack-swift-object-updater.service

# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service \
> openstack-swift-object-replicator.service openstack-swift-object-updater.service




## 验证服务

# echo "export OS_AUTH_VERSION=3" \
> | tee -a admin-openrc.sh

# source admin-openrc.sh


## 查看 swift 状态

# swift stat


      Account: AUTH_0d1a69b17e444cb3b4884529b6bdb372
   Containers: 0
      Objects: 0
          Bytes: 0
X-Put-Timestamp: 1449222121.42343
    X-Timestamp: 1449222121.42343
   X-Trans-Id: tx20d0064672a74cd88723f-0056615fe9
   Content-Type: text/plain; charset=utf-8




## 测试 上传 文件

# touch FILE


# swift upload container1 FILE

                   

页: [1]
查看完整版本: OpenStack - liberty CentOS 7