星期三, 10月 29, 2014

openStack CL210課程筆記 - Day 3

20141029


Configuring Swift object storage service rings
workbook p69


磁碟分配方式
檔案進行  hash 然後除以 zone 的數量, 依照得到的餘數分配要放在那個磁碟.


[root@server5 ~]# source  /root/keystonerc_admin


[root@server5 ~(keystone_admin)]$ swift-ring-builder  /etc/swift/account.builder create  12  2 1


[root@server5 ~(keystone_admin)]$ swift-ring-builder  /etc/swift/container.builder create  12  2 1


[root@server5 ~(keystone_admin)]$ swift-ring-builder  /etc/swift/object.builder create  12  2 1


[root@server5 ~(keystone_admin)]$ for i in 1 2; do swift-ring-builder /etc/swift/container.builder add z${i}-192.168.0.105:6001/z${i}d1 100; done


WARNING: No region specified for z1-192.168.0.105:6002/z1d1. Defaulting to region 1.
Device d0r1z1-192.168.0.105:6002R192.168.0.105:6002/z1d1_"" with 100.0 weight got id 0
WARNING: No region specified for z2-192.168.0.105:6002/z2d1. Defaulting to region 1.
Device d1r1z2-192.168.0.105:6002R192.168.0.105:6002/z2d1_"" with 100.0 weight got id 1


[root@server5 ~(keystone_admin)]$ for i in 1 2; do swift-ring-builder /etc/swift/account.builder add z${i}-192.168.0.105:6002/z${i}d1 100; done
WARNING: No region specified for z1-192.168.0.105:6002/z1d1. Defaulting to region 1.
Device d0r1z1-192.168.0.105:6002R192.168.0.105:6002/z1d1_"" with 100.0 weight got id 0
WARNING: No region specified for z2-192.168.0.105:6002/z2d1. Defaulting to region 1.
Device d1r1z2-192.168.0.105:6002R192.168.0.105:6002/z2d1_"" with 100.0 weight got id 1


[root@server5 ~(keystone_admin)]$ for i in 1 2; do swift-ring-builder /etc/swift/object.builder add z${i}-192.168.0.105:6000/z${i}d1 100; done
WARNING: No region specified for z1-192.168.0.105:6002/z1d1. Defaulting to region 1.
Device d0r1z1-192.168.0.105:6002R192.168.0.105:6002/z1d1_"" with 100.0 weight got id 0
WARNING: No region specified for z2-192.168.0.105:6002/z2d1. Defaulting to region 1.
Device d1r1z2-192.168.0.105:6002R192.168.0.105:6002/z2d1_"" with 100.0 weight got id 1


[root@server5 ~(keystone_admin)]$ swift-ring-builder /etc/swift/account.builder rebalance
Reassigned 4096 (100.00%) partitions. Balance is now 0.00.


[root@server5 ~(keystone_admin)]$ swift-ring-builder /etc/swift/container.builder rebalance
Reassigned 4096 (100.00%) partitions. Balance is now 0.00.


[root@server5 ~(keystone_admin)]$ swift-ring-builder /etc/swift/object.builder rebalance
Reassigned 4096 (100.00%) partitions. Balance is now 0.00.


[root@server5 ~(keystone_admin)]$ ls /etc/swift/*.gz
/etc/swift/account.ring.gz  /etc/swift/container.ring.gz  /etc/swift/object.ring.gz


[root@server5 ~(keystone_admin)]$ chown -R root:swift  /etc/swift/


Lab: Deploying the Swift object storage proxy
workbook p72


[root@server5 ~(keystone_admin)]$ cp  /etc/swift/proxy-server.conf  /etc/swift/proxy-server.conf.orig


[root@server5 ~(keystone_admin)]$ openstack-config  --set /etc/swift/proxy-server.conf  filter:authtoken admin_tenant_name services


[root@server5 ~(keystone_admin)]$ openstack-config  --set /etc/swift/proxy-server.conf  filter:authtoken auth_host 192.168.0.105


[root@server5 ~(keystone_admin)]$ openstack-config  --set /etc/swift/proxy-server.conf  filter:authtoken admin_user swift


[root@server5 ~(keystone_admin)]$ openstack-config  --set /etc/swift/proxy-server.conf  filter:authtoken admin_password redhat


[root@server5 ~(keystone_admin)]$ service  memcached  start
Starting memcached:                                     [  OK  ]


[root@server5 ~(keystone_admin)]$ service  openstack-swift-proxy  start
Starting openstack-swift-proxy:                         [  OK  ]


[root@server5 ~(keystone_admin)]$ tail  /var/log/messages
Oct 28 18:28:30 server5 proxy-server Configuring auth_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
Oct 28 18:28:30 server5 proxy-server Using /tmp/keystone-signing-swift as cache directory for signing certificate
Oct 28 18:28:30 server5 proxy-server Configuring auth_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
Oct 28 18:28:30 server5 proxy-server Using /tmp/keystone-signing-swift as cache directory for signing certificate
Oct 28 18:28:30 server5 proxy-server Starting keystone auth_token middleware
Oct 28 18:28:30 server5 proxy-server Configuring auth_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
Oct 28 18:28:30 server5 proxy-server Using /tmp/keystone-signing-swift as cache directory for signing certificate
Oct 28 18:28:30 server5 proxy-server Starting keystone auth_token middleware
Oct 28 18:28:30 server5 proxy-server Configuring auth_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
Oct 28 18:28:30 server5 proxy-server Using /tmp/keystone-signing-swift as cache directory for signing certificate


[root@server5 ~(keystone_admin)]$ chkconfig  memcached  on
[root@server5 ~(keystone_admin)]$ chkconfig  memcached  --list
memcached 0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_admin)]$ chkconfig  openstack-swift-proxy  on
[root@server5 ~(keystone_admin)]$ chkconfig  openstack-swift-proxy  --list
openstack-swift-proxy    0:off    1:off    2:on    3:on    4:on    5:on    6:off

Lab:  Validating Swift object storage
workbook p74


還沒做之前檢查一下
[root@server5 ~(keystone_admin)]$ swift list


[ Lab 未完成 ]


* Chapter  6 Implementing the Glance image service


Lab:  Deploying the Glance image service
workbook p82


[root@server5 ~]# yum  install -y openstack-glance


[root@server5 ~]# cp /etc/glance/glance-registry.conf  /etc/glance/glance-registry.conf.orig


[root@server5 ~]# cp /etc/glance/glance-api.conf   /etc/glance/glance-api.conf.orig


[root@server5 ~]# cp /usr/share/glance/glance-registry-dist.conf /etc/glance/glance-registry.conf
cp: overwrite `/etc/glance/glance-registry.conf'? y


[root@server5 ~(keystone_admin)]$ openstack-db --init --service glance --password redhat --rootpw redhat


[root@server5 ~(keystone_admin)]$ keystone user-create --name glance --pass redhat
+----------+----------------------------------+
| Property |           Value            |
+----------+----------------------------------+
|  email   |                               |
| enabled  |            True            |
| id | 3a924d24c2b84b2c95e35230ede33c9b |
|   name   |           glance           |
+----------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone user-role-add --user glance --role admin --tenant services


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name services


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password redhat
[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf DEFAULT qpid_username qpidauth


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf DEFAULT qpid_password redhat


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf DEFAULT qpid_protocol ssl


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-api.conf DEFAULT qpid_port 5671


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name services


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password redhat

[root@server5 ~(keystone_admin)]$ service  openstack-glance-registry start
Starting openstack-glance-registry:                     [  OK  ]


[root@server5 ~(keystone_admin)]$ service openstack-glance-api start
Starting openstack-glance-api:                          [  OK  ]


[root@server5 ~(keystone_admin)]$ chkconfig openstack-glance-registry on
[root@server5 ~(keystone_admin)]$ chkconfig openstack-glance-registry --list
openstack-glance-registry    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_admin)]$ chkconfig  openstack-glance-api on
[root@server5 ~(keystone_admin)]$ chkconfig  openstack-glance-api --list
openstack-glance-api    0:off    1:off    2:on    3:on    4:on    5:on    6:off

[root@server5 ~(keystone_admin)]$ egrep 'ERROR|CRITICAL' /var/log/glance/*
/var/log/glance/api.log:2014-10-28 19:44:16.861 3973 ERROR glance.store.sheepdog [-] Error in store configuration: Unexpected error while running command.
[root@server5 ~(keystone_admin)]$ keystone service-create --name glance --type image --description "openStack Image Service"
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
| description | openStack Image Service   |
|   id | e6b34babc2d34918a3003aa9c9005d3f |
| name |           glance           |
| type |           image            |
+-------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone endpoint-create --service-id e6b34babc2d34918a3003aa9c9005d3f --publicurl http://server5.example.com:9292 --adminurl  http://server5.example.com:9292 --internalurl http://server5.example.com:9292
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
|   adminurl  | http://server5.example.com:9292  |
|   id | 3fab15f5cd0747cfba284d2d648bf71e |
| internalurl | http://server5.example.com:9292  |
|  publicurl  | http://server5.example.com:9292  |
| region   |         regionOne          |
|  service_id | e6b34babc2d34918a3003aa9c9005d3f |
+-------------+----------------------------------+

Notes:
建立範本套用修改事項
  • 修改 網卡設定中, 將 HWADDR 設定移除
  • 將 HOSTNAME 設定改成 localhost.localdomain
  • 刪除 /etc/udev/rules.d/70-persistent-net.rules
  • 刪除 /etc/ssh/ssh_host_*
  • 刪除 /etc/pki/tls/certs/localhost.crt
  • 刪除 /etc/pki/tls/private/localhost.key


Virtio for windows


顯卡的  virtio
  • Video 請選  qxl
  • Graphics 請選  Spice


==== 中午休息 ====


Lab: Using Glance to upload a system image
workbook p85


透過指令上傳  image 到 glance
[root@server5 ~(keystone_admin)]$ glance image-create --name "test" --is-public True --disk-format qcow2 --container-format bare --copy-from http://instructor.example.com/pub/materials/small.img
+------------------+--------------------------------------+
| Property      | Value                             |
+------------------+--------------------------------------+
| checksum      | None                              |
| container_format | bare                              |
| created_at    | 2014-10-28T13:42:13               |
| deleted       | False                             |
| deleted_at    | None                              |
| disk_format   | qcow2                             |
| id            | f8379597-981b-4105-bb4a-7b596b529156 |
| is_public     | True                              |
| min_disk      | 0                                 |
| min_ram       | 0                                 |
| name          | test                              |
| owner         | 0fa2ca1bd34c4a4b88ce36272038574d |
| protected     | False                             |
| size          | 92909568                          |
| status        | queued                            |
| updated_at    | 2014-10-28T13:42:13               |
+------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ glance image-list
+--------------------------------------+------+-------------+------------------+----------+--------+
| ID                                | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+------+-------------+------------------+----------+--------+
| f8379597-981b-4105-bb4a-7b596b529156 | test | qcow2    | bare          | 92909568 | active |
+--------------------------------------+------+-------------+------------------+----------+--------+

上傳的影像檔案  /var/lib/glance/images


[root@server5 ~(keystone_admin)]$ ls -hl /var/lib/glance/images/
total 89M
-rw-r-----. 1 glance glance 89M Oct 28 21:42 f8379597-981b-4105-bb4a-7b596b529156


[root@server5 ~(keystone_admin)]$ glance image-show  test
+------------------+--------------------------------------+
| Property      | Value                             |
+------------------+--------------------------------------+
| checksum      | cf3345a6131ee413e8f41457ab57e8c8 |
| container_format | bare                              |
| created_at    | 2014-10-28T13:42:13               |
| deleted       | False                             |
| disk_format   | qcow2                             |
| id            | f8379597-981b-4105-bb4a-7b596b529156 |
| is_public     | True                              |
| min_disk      | 0                                 |
| min_ram       | 0                                 |
| name          | test                              |
| owner         | 0fa2ca1bd34c4a4b88ce36272038574d |
| protected     | False                             |
| size          | 92909568                          |
| status        | active                            |
| updated_at    | 2014-10-28T13:42:14               |
+------------------+--------------------------------------+

Glance 有獨立的 log


[root@server5 ~(keystone_admin)]$ ls /var/log/glance/
api.log  registry.log


* Chapter 7 Implementing the Cinder block storage service


Lab: Install the Cinder block storage service and managing volumes
workbook p98

[root@server5 ~]# yum  install -y openstack-cinder


[root@server5 ~]# cp  /etc/cinder/cinder.conf   /etc/cinder/cinder.conf.orig


[root@server5 ~]# cp /usr/share/cinder/cinder-dist.conf /etc/cinder/cinder.conf
cp: overwrite `/etc/cinder/cinder.conf'? y


[root@server5 ~]# source /root/keystonerc_admin


[root@server5 ~(keystone_admin)]$ openstack-db --init --service cinder --password redhat --rootpw redhat
Verified connectivity to MySQL.
Creating 'cinder' database.
Updating 'cinder' database password in /etc/cinder/cinder.conf
Initializing the cinder database, please wait...


[root@server5 ~(keystone_admin)]$ keystone user-create --name cinder --pass redhat
+----------+----------------------------------+
| Property |           Value            |
+----------+----------------------------------+
|  email   |                               |
| enabled  |            True            |
| id | 2323a6d898994cf79bb2187e560531f4 |
|   name   |           cinder           |
+----------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone user-role-add --user cinder --role admin --tenant services


[root@server5 ~(keystone_admin)]$ keystone service-create --name cinder --type volume --description "OpenStack Block Storage Service"
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
| description | OpenStack Block Storage Service  |
|   id | 79d96c900a174132a328a1ed078c8687 |
| name |           cinder           |
| type |           volume           |
+-------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone endpoint-create --service-id 79d96c900a174132a328a1ed078c8687 --publicurl "http://server5.example.com:8776/v1/%(tenant_id)s" --adminurl  "http://server5.example.com:8776/v1/%(tenant_id)s" --internalurl "http://server5.example.com:8776/v1/%(tenant_id)s"
+-------------+--------------------------------------------------+
|   Property  |                   Value                    |
+-------------+--------------------------------------------------+
|   adminurl  | http://server5.example.com:8776/v1/%(tenant_id)s |
|   id |      5aa848c8833a4afb8ddc6bb302e81834      |
| internalurl | http://server5.example.com:8776/v1/%(tenant_id)s |
|  publicurl  | http://server5.example.com:8776/v1/%(tenant_id)s |
| region   |                 regionOne                  |
|  service_id |      79d96c900a174132a328a1ed078c8687      |
+-------------+--------------------------------------------------+


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name services


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password redhat


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf DEFAULT verbose true


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_username qpidauth


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_password redhat


[root@server5 ~(keystone_admin)]$  openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_protocol ssl


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_port 5671


[root@server5 ~(keystone_admin)]$ chkconfig openstack-cinder-scheduler on
[root@server5 ~(keystone_admin)]$ chkconfig openstack-cinder-api on
[root@server5 ~(keystone_admin)]$ chkconfig openstack-cinder-volume on
[root@server5 ~(keystone_admin)]$ service openstack-cinder-api start
Starting openstack-cinder-api:                          [  OK  ]
[root@server5 ~(keystone_admin)]$ service openstack-cinder-scheduler start
Starting openstack-cinder-scheduler:                    [  OK  ]
[root@server5 ~(keystone_admin)]$ service openstack-cinder-volume start
Starting openstack-cinder-volume:                       [  OK  ]


[root@server5 ~(keystone_admin)]$ tail /var/log/cinder/*


[root@server5 ~(keystone_admin)]$ echo "include /etc/cinder/volumes/*" >> /etc/tgt/targets.conf
[root@server5 ~(keystone_admin)]$ tail -n 3 /etc/tgt/targets.conf
# </direct-store>
#</target>
include /etc/cinder/volumes/*


[root@server5 ~(keystone_admin)]$ service tgtd start
Starting SCSI target daemon:                            [  OK  ]
[root@server5 ~(keystone_admin)]$ chkconfig tgtd on
[root@server5 ~(keystone_admin)]$ chkconfig tgtd --list
tgtd       0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_admin)]$ tail /var/log/messages
Oct 29 13:50:59 server5 yum[1795]: Installed: scsi-target-utils-1.0.24-10.el6.x86_64
Oct 29 13:51:02 server5 yum[1795]: Installed: openstack-cinder-2013.2.1-1.el6ost.noarch
Oct 29 13:56:44 server5 ntpd[1299]: 0.0.0.0 c612 02 freq_set kernel 0.330 PPM
Oct 29 13:56:44 server5 ntpd[1299]: 0.0.0.0 c615 05 clock_sync
Oct 29 14:36:10 server5 rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.
Oct 29 14:43:43 server5 tgtd: semkey 0x6101003d
Oct 29 14:43:43 server5 tgtd: tgtd daemon started, pid:2913
Oct 29 14:43:43 server5 tgtd: tgtd logger started, pid:2916 debug:0
Oct 29 14:43:43 server5 tgtd: work_timer_start(146) use timer_fd based scheduler
Oct 29 14:43:43 server5 tgtd: bs_init(313) use signalfd notification


[root@server5 ~(keystone_admin)]$ openstack-status
== Glance services ==
openstack-glance-api:                active
openstack-glance-registry:           active
== Keystone service ==
openstack-keystone:                  active
== Swift services ==
openstack-swift-proxy:               dead   (disabled on boot)
openstack-swift-account:             active
openstack-swift-container:           active
openstack-swift-object:              active
== Cinder services ==
openstack-cinder-api:                active
openstack-cinder-scheduler:          active
openstack-cinder-volume:             active
== Support services ==
mysqld:                              active
messagebus:                          active
tgtd:                                active
qpidd:                               active
memcached:                           active
== Keystone users ==
+----------------------------------+--------+---------+-------+
|             id             |  name  | enabled | email |
+----------------------------------+--------+---------+-------+
| 864fef71904746feaad1c75e0ba3a911 | admin  |   True  |    |
| 2323a6d898994cf79bb2187e560531f4 | cinder |   True  |    |
| 3a924d24c2b84b2c95e35230ede33c9b | glance |   True  |    |
| 11468bea059d4955b976c4c1753a1fdc | swift  |   True  |    |
+----------------------------------+--------+---------+-------+
== Glance images ==
+--------------------------------------+------+-------------+------------------+----------+--------+
| ID                                | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+------+-------------+------------------+----------+--------+
| f8379597-981b-4105-bb4a-7b596b529156 | test | qcow2    | bare          | 92909568 | active |
+--------------------------------------+------+-------------+------------------+----------+--------+


還沒做之前先觀察
[root@server5 ~(keystone_admin)]$ ls  /etc/cinder/volumes/


[root@server5 ~(keystone_admin)]$ cinder create --display-name vol1 2
+---------------------+--------------------------------------+
|    Property   |             Value              |
+---------------------+--------------------------------------+
| attachments |               []               |
|  availability_zone  |              nova              |
|    bootable   |             false              |
|   created_at |   2014-10-29T06:46:07.962597   |
| display_description |              None              |
| display_name |              vol1              |
|       id      | 51ea44ec-3fe1-4b52-ae7b-26c2979085bf |
|    metadata   |               {}               |
|      size     |               2                |
| snapshot_id |              None              |
| source_volid |              None              |
|     status    |            creating            |
| volume_type |              None              |
+---------------------+--------------------------------------+


建立完的 volumes 會存放在 /etc/cinder/volumes
[root@server5 ~(keystone_admin)]$ ls  /etc/cinder/volumes/
volume-51ea44ec-3fe1-4b52-ae7b-26c2979085bf


[root@server5 ~(keystone_admin)]$ vgs
 VG          #PV #LV #SN Attr   VSize  VFree
 cinder-volumes   1   1   0 wz--n-  4.97g 2.97g
 vol0          1   2   0 wz--n- 29.97g 0
[root@server5 ~(keystone_admin)]$ lvs
 LV                                       VG          Attr    LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
 volume-51ea44ec-3fe1-4b52-ae7b-26c2979085bf cinder-volumes -wi-ao----  2.00g                                        
 root                                     vol0        -wi-ao----  4.00g                                        
 var                                      vol0        -wi-ao---- 25.97g          


[root@server5 ~(keystone_admin)]$ cinder delete vol1


[root@server5 ~(keystone_admin)]$ cinder list
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
|               ID               |  Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
| 51ea44ec-3fe1-4b52-ae7b-26c2979085bf | deleting | vol1 |  2   | None |  false   |          |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+


Notes:
  • Cinder 的做法是在本機上建立一個 VG, 然後建立 LV, 然後當成 iscsi  共享出去

Lab:  Adding a Red Hat storage volume to Cinder
workbook p104


[root@server5 ~(keystone_admin)]$ yum -y install glusterfs-fuse


[root@server5 ~(keystone_admin)]$ cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.orig2


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends glusterfs,lvm


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMISCSIDriver


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf lvm volume_backend_name LVM


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf glusterfs volume_driver cinder.volume.drivers.glusterfs.GlusterfsDriver


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf glusterfs glusterfs_shares_config /etc/cinder/shares.conf


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf glusterfs glusterfs_sparsed_volumes false


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/cinder/cinder.conf glusterfs volume_backend_name RHS


[root@server5 ~(keystone_admin)]$ echo "rhs.example.com:volume5" >> /etc/cinder/shares.conf


[root@server5 ~(keystone_admin)]$ for svc in scheduler volume; do service openstack-cinder-${svc} restart; done
Stopping openstack-cinder-scheduler:                    [  OK  ]
Starting openstack-cinder-scheduler:                    [  OK  ]
Stopping openstack-cinder-volume:                       [  OK  ]
Starting openstack-cinder-volume:                       [  OK  ]


[root@server5 ~(keystone_admin)]$ tail /var/log/cinder/volume.log
2014-10-29 15:23:12.779 3532 INFO cinder.service [-] Started child 3543
2014-10-29 15:23:12.789 3543 AUDIT cinder.service [-] Starting cinder-volume node (version 2013.2.1)
2014-10-29 15:23:18.452 3543 INFO cinder.openstack.common.rpc.impl_qpid [req-7f5c5f29-ccac-4916-87ab-0b1f640734b5 None None] Connected to AMQP server on localhost:5671
2014-10-29 15:23:18.467 3543 INFO cinder.volume.manager [req-7f5c5f29-ccac-4916-87ab-0b1f640734b5 None None] Starting volume driver LVMISCSIDriver (2.0.0)
2014-10-29 15:23:19.087 3542 INFO cinder.openstack.common.rpc.impl_qpid [req-fdaa0e13-64af-4943-8188-019fb5b0a629 None None] Connected to AMQP server on localhost:5671
2014-10-29 15:23:19.117 3542 INFO cinder.volume.manager [req-fdaa0e13-64af-4943-8188-019fb5b0a629 None None] Starting volume driver GlusterfsDriver (1.1.0)
2014-10-29 15:23:20.903 3542 INFO cinder.volume.manager [req-fdaa0e13-64af-4943-8188-019fb5b0a629 None None] Updating volume status
2014-10-29 15:23:20.985 3543 INFO cinder.volume.manager [req-7f5c5f29-ccac-4916-87ab-0b1f640734b5 None None] Updating volume status
2014-10-29 15:23:21.367 3542 INFO cinder.openstack.common.rpc.impl_qpid [req-fdaa0e13-64af-4943-8188-019fb5b0a629 None None] Connected to AMQP server on localhost:5671
2014-10-29 15:23:21.437 3543 INFO cinder.openstack.common.rpc.impl_qpid [req-7f5c5f29-ccac-4916-87ab-0b1f640734b5 None None] Connected to AMQP server on localhost:5671


[root@server5 ~(keystone_admin)]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vol0-root 4.0G  1.2G  2.6G  31% /
tmpfs                 1.9G 0  1.9G   0% /dev/shm
/dev/vda1             248M   34M  202M  15% /boot
/dev/mapper/vol0-var   26G  353M   24G   2% /var
/dev/vdb1              93M  5.6M   83M   7% /srv/node/z1d1
/dev/vdc1              93M  5.6M   83M   7% /srv/node/z2d1
rhs.example.com:volume5  1.3G   33M  1.3G   3% /var/lib/cinder/mnt/bd5297560573d0b99c0db6110059b92f


[root@server5 ~(keystone_admin)]$ cinder type-create lvm
+--------------------------------------+------+
|               ID               | Name |
+--------------------------------------+------+
| 918f5038-7051-4a08-bcd4-0254b2777f27 | lvm  |
+--------------------------------------+------+


[root@server5 ~(keystone_admin)]$ cinder type-key 918f5038-7051-4a08-bcd4-0254b2777f27 set volume_backend_name=LVM


[root@server5 ~(keystone_admin)]$ cinder type-create glusterfs
+--------------------------------------+-----------+
|               ID               | Name   |
+--------------------------------------+-----------+
| 8433f17b-c279-40c5-a0f7-a8ae80720f00 | glusterfs |
+--------------------------------------+-----------+


[root@server5 ~(keystone_admin)]$ cinder type-key 8433f17b-c279-40c5-a0f7-a8ae80720f00 set volume_backend_name=RHS


[root@server5 ~(keystone_admin)]$ cinder type-list
+--------------------------------------+-----------+
|               ID               | Name   |
+--------------------------------------+-----------+
| 8433f17b-c279-40c5-a0f7-a8ae80720f00 | glusterfs |
| 918f5038-7051-4a08-bcd4-0254b2777f27 | lvm |
+--------------------------------------+-----------+


[root@server5 ~(keystone_admin)]$ cinder create --volume-type lvm --display-name vol2 1
+---------------------+--------------------------------------+
|    Property   |             Value              |
+---------------------+--------------------------------------+
| attachments |               []               |
|  availability_zone  |              nova              |
|    bootable   |             false              |
|   created_at |   2014-10-29T07:37:41.554652   |
| display_description |              None              |
| display_name |              vol2              |
|       id      | 445e58d0-5a7b-4940-a23f-545c062d2102 |
|    metadata   |               {}               |
|      size     |               1                |
| snapshot_id |              None              |
| source_volid |              None              |
|     status    |            creating            |
| volume_type |              lvm               |
+---------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|               ID               |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 445e58d0-5a7b-4940-a23f-545c062d2102 | available | vol2 |  1   | lvm |  false   |          |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+


[root@server5 ~(keystone_admin)]$ cinder create --volume-type glusterfs --display-name vol3 1
+---------------------+--------------------------------------+
|    Property   |             Value              |
+---------------------+--------------------------------------+
| attachments |               []               |
|  availability_zone  |              nova              |
|    bootable   |             false              |
|   created_at |   2014-10-29T07:38:51.478776   |
| display_description |              None              |
| display_name |              vol3              |
|       id      | edd10aec-efb5-4634-a123-1c8ffe31a669 |
|    metadata   |               {}               |
|      size     |               1                |
| snapshot_id |              None              |
| source_volid |              None              |
|     status    |            creating            |
| volume_type |           glusterfs            |
+---------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|               ID               |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 445e58d0-5a7b-4940-a23f-545c062d2102 | available | vol2 |  1   | lvm |  false   |          |
| edd10aec-efb5-4634-a123-1c8ffe31a669 |  creating | vol3 |  1   |  glusterfs  |  false   |          |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+


[root@server5 ~(keystone_admin)]$ cinder create --volume-type glusterfs --display-name vol4 1
+---------------------+--------------------------------------+
|    Property   |             Value              |
+---------------------+--------------------------------------+
| attachments |               []               |
|  availability_zone  |              nova              |
|    bootable   |             false              |
|   created_at |   2014-10-29T07:39:42.471966   |
| display_description |              None              |
| display_name |              vol4              |
|       id      | 7e126005-4187-4b98-b5db-e5d3431b9c36 |
|    metadata   |               {}               |
|      size     |               1                |
| snapshot_id |              None              |
| source_volid |              None              |
|     status    |            creating            |
| volume_type |           glusterfs            |
+---------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|               ID               |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 445e58d0-5a7b-4940-a23f-545c062d2102 | available | vol2 |  1   | lvm |  false   |          |
| 7e126005-4187-4b98-b5db-e5d3431b9c36 |   error   | vol4 |  1   |  glusterfs  |  false   |          |
| edd10aec-efb5-4634-a123-1c8ffe31a669 | available | vol3 |  1   |  glusterfs  |  false   |          |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+


[root@server5 ~(keystone_admin)]$ cinder create --volume-type lvm --display-name vol5 1
+---------------------+--------------------------------------+
|    Property   |             Value              |
+---------------------+--------------------------------------+
| attachments |               []               |
|  availability_zone  |              nova              |
|    bootable   |             false              |
|   created_at |   2014-10-29T07:40:51.148736   |
| display_description |              None              |
| display_name |              vol5              |
|       id      | e310cbec-48a6-4217-af86-cd4c3710c40f |
|    metadata   |               {}               |
|      size     |               1                |
| snapshot_id |              None              |
| source_volid |              None              |
|     status    |            creating            |
| volume_type |              lvm               |
+---------------------+--------------------------------------+

[root@server5 ~(keystone_admin)]$ cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|               ID               |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 445e58d0-5a7b-4940-a23f-545c062d2102 | available | vol2 |  1   | lvm |  false   |          |
| 7e126005-4187-4b98-b5db-e5d3431b9c36 |   error   | vol4 |  1   |  glusterfs  |  false   |          |
| e310cbec-48a6-4217-af86-cd4c3710c40f | available | vol5 |  1   | lvm |  false   |          |
| edd10aec-efb5-4634-a123-1c8ffe31a669 | available | vol3 |  1   |  glusterfs  |  false   |          |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+


[root@server5 ~(keystone_admin)]$ cinder delete vol2
[root@server5 ~(keystone_admin)]$ cinder delete vol3
[root@server5 ~(keystone_admin)]$ cinder delete vol4
[root@server5 ~(keystone_admin)]$ cinder delete vol5


[root@server5 ~(keystone_admin)]$ cinder type-list
+--------------------------------------+-----------+
|               ID               | Name   |
+--------------------------------------+-----------+
| 8433f17b-c279-40c5-a0f7-a8ae80720f00 | glusterfs |
| 918f5038-7051-4a08-bcd4-0254b2777f27 | lvm |
+--------------------------------------+-----------+


[root@server5 ~(keystone_admin)]$ cinder type-delete 8433f17b-c279-40c5-a0f7-a8ae80720f00


[root@server5 ~(keystone_admin)]$ cinder type-delete 918f5038-7051-4a08-bcd4-0254b2777f27


[root@server5 ~(keystone_admin)]$ cinder type-list


還原相關設定
[root@server5 ~(keystone_admin)]$ cp /etc/cinder/cinder.conf.orig2 /etc/cinder/cinder.conf
cp: overwrite `/etc/cinder/cinder.conf'? y


[root@server5 ~(keystone_admin)]$ chown cinder:cinder /etc/cinder/cinder.conf
[root@server5 ~(keystone_admin)]$ chmod 600 /etc/cinder/cinder.conf
[root@server5 ~(keystone_admin)]$ restorecon -v /etc/cinder/cinder.conf


[root@server5 ~(keystone_admin)]$ for svc in scheduler volume; do service openstack-cinder-${svc} restart; done
Stopping openstack-cinder-scheduler:                    [  OK  ]
Starting openstack-cinder-scheduler:                    [  OK  ]
Stopping openstack-cinder-volume:                       [  OK  ]
Starting openstack-cinder-volume:                       [  OK  ]


Notes
glusterfs 是 file base, 所以會建立檔案來模擬

* Chapter 8 Implementing the openStack netowrking service


Lab:  Installing openStack networking
workbook p114


[root@server5 ~]# source  /root/keystonerc_admin


[root@server5 ~(keystone_admin)]$ keystone service-create --name neutron --type network --description "OpenStack Networking Service"
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
| description |   OpenStack Networking Service   |
|   id | a15abe8a14b942fc981a2a0f50d1e6be |
| name |          neutron           |
| type |          network           |
+-------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone endpoint-create --service-id a15abe8a14b942fc981a2a0f50d1e6be --publicurl "http://server5.example.com:9696" --adminurl  "http://server5.example.com:9696" --internalurl "http://server5.example.com:9696"
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
|   adminurl  | http://server5.example.com:9696  |
|   id | a5ae8d2814aa415a8ee26fbdc864e9e5 |
| internalurl | http://server5.example.com:9696  |
|  publicurl  | http://server5.example.com:9696  |
| region   |         regionOne          |
|  service_id | a15abe8a14b942fc981a2a0f50d1e6be |
+-------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone catalog
Service: volume
+-------------+---------------------------------------------------------------------+
|   Property  |                             Value                             |
+-------------+---------------------------------------------------------------------+
|   adminURL  | http://server5.example.com:8776/v1/0fa2ca1bd34c4a4b88ce36272038574d |
|   id |                60d06be459c94a778711bf6856d0b59b               |
| internalURL | http://server5.example.com:8776/v1/0fa2ca1bd34c4a4b88ce36272038574d |
|  publicURL  | http://server5.example.com:8776/v1/0fa2ca1bd34c4a4b88ce36272038574d |
| region   |                           regionOne                           |
+-------------+---------------------------------------------------------------------+
Service: object-store
+-------------+--------------------------------------------------------------------------+
|   Property  |                               Value                                |
+-------------+--------------------------------------------------------------------------+
|   adminURL  | http://server5.example.com:8080/v1/AUTH_0fa2ca1bd34c4a4b88ce36272038574d |
|   id |                  9a71a157dea348ba92d5d67d1a42bf92                  |
| internalURL | http://server5.example.com:8080/v1/AUTH_0fa2ca1bd34c4a4b88ce36272038574d |
|  publicURL  | http://server5.example.com:8080/v1/AUTH_0fa2ca1bd34c4a4b88ce36272038574d |
| region   |                             regionOne                              |
+-------------+--------------------------------------------------------------------------+
Service: image
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
|   adminURL  | http://server5.example.com:9292  |
|   id | 32567d94b08f4de0bf83f437a49cec2f |
| internalURL | http://server5.example.com:9292  |
|  publicURL  | http://server5.example.com:9292  |
| region   |         regionOne          |
+-------------+----------------------------------+
Service: network
+-------------+----------------------------------+
|   Property  |           Value            |
+-------------+----------------------------------+
|   adminURL  | http://server5.example.com:9696  |
|   id | 10ed087ee3d14319808ff4856ec4adb4 |
| internalURL | http://server5.example.com:9696  |
|  publicURL  | http://server5.example.com:9696  |
| region   |         regionOne          |
+-------------+----------------------------------+
Service: identity
+-------------+---------------------------------------+
|   Property  |              Value              |
+-------------+---------------------------------------+
|   adminURL  | http://server5.example.com:35357/v2.0 |
|   id | 778fca3b408242598aa5428d3f7fff70   |
| internalURL |  http://server5.example.com:5000/v2.0 |
|  publicURL  |  http://server5.example.com:5000/v2.0 |
| region   |            regionOne            |
+-------------+---------------------------------------+


[root@server5 ~(keystone_admin)]$ keystone user-create --name neutron --pass redhat
+----------+----------------------------------+
| Property |           Value            |
+----------+----------------------------------+
|  email   |                               |
| enabled  |            True            |
| id | 0805aea2c48947bbb56b72d437f68aa7 |
|   name   |          neutron           |
+----------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone user-role-add --user neutron --role admin --tenant services


[root@server5 ~(keystone_admin)]$ keystone user-role-list
+----------------------------------+-------+----------------------------------+----------------------------------+
|             id             |  name |          user_id           |         tenant_id          |
+----------------------------------+-------+----------------------------------+----------------------------------+
| db5b551d50dc4d97a7bd89cc65edf149 | admin | 864fef71904746feaad1c75e0ba3a911 | 0fa2ca1bd34c4a4b88ce36272038574d |
+----------------------------------+-------+----------------------------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ keystone --os-username neutron --os-password redhat --os-tenant-name services user-role-list
+----------------------------------+-------+----------------------------------+----------------------------------+
|             id             |  name |          user_id           |         tenant_id          |
+----------------------------------+-------+----------------------------------+----------------------------------+
| db5b551d50dc4d97a7bd89cc65edf149 | admin | 0805aea2c48947bbb56b72d437f68aa7 | 047e809fc22e4ff687cfecbe15e728a0 |
+----------------------------------+-------+----------------------------------+----------------------------------+


[root@server5 ~(keystone_admin)]$ yum -y install openstack-neutron openstack-neutron-openvswitch


[root@server5 ~(keystone_admin)]$ service qpidd status
qpidd (pid  1562) is running...


[root@server5 ~(keystone_admin)]$ cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.org


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT qpid_hostname 192.168.0.105


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT qpid_username qpidauth


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT qpid_password redhat


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT qpid_protocol ssl


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf DEFAULT qpid_port 5671


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_tenant_name services


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_user neutron


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf keystone_authtoken admin_password redhat


[root@server5 ~(keystone_admin)]$ openstack-config --set /etc/neutron/neutron.conf agent root_helper "sudo neutron-rootwrap /etc/neutron/rootwrap.conf"


[root@server5 ~(keystone_admin)]$ vi  /root/keystonerc_neutron
新增內容
export OS_USERNAME=neutron
export OS_TENANT_NAME=services
export OS_PASSWORD=redhat
export OS_AUTH_URL=http://server5.example.com:35357/v2.0/
export PS1='[\u@\h \W(keystone_neutron)]\$'


[root@server5 ~(keystone_admin)]$ source /root/keystonerc_neutron


[root@server5 ~(keystone_neutron)]#yum -y install openstack-nova-common


[root@server5 ~(keystone_neutron)]#neutron-server-setup --yes --rootpw redhat --plugin openvswitch
Neutron plugin: openvswitch
Plugin: openvswitch => Database: ovs_neutron
Verified connectivity to MySQL.
Configuration updates complete!


[root@server5 ~(keystone_neutron)]#neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini stamp head
No handlers could be found for logger "neutron.common.legacy"
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.


[root@server5 ~(keystone_neutron)]#service neutron-server start
Starting neutron:                                       [  OK  ]


[root@server5 ~(keystone_neutron)]#egrep 'ERROR|CRITICAL' /var/log/neutron/server.log
2014-10-29 16:15:21.949 5242 ERROR neutron.common.legacy [-] Skipping unknown group key: firewall_driver


[root@server5 ~(keystone_neutron)]#chkconfig neutron-server on
[root@server5 ~(keystone_neutron)]#chkconfig neutron-server --list
neutron-server     0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#openstack-status


== neutron services ==
neutron-server:                      active
neutron-dhcp-agent:                  inactive  (disabled on boot)
neutron-l3-agent:                    inactive  (disabled on boot)
neutron-metadata-agent:              inactive  (disabled on boot)
neutron-lbaas-agent:                 inactive  (disabled on boot)
neutron-openvswitch-agent:           inactive  (disabled on boot)


[root@server5 ~(keystone_neutron)]#neutron-node-setup --plugin openvswitch --qhost 192.168.0.105
Neutron plugin: openvswitch
Would you like to update the nova configuration files? (y/n):
y
Configuration updates complete!


[root@server5 ~(keystone_neutron)]#service openvswitch start
/etc/openvswitch/conf.db does not exist ... (warning).
Creating empty database /etc/openvswitch/conf.db        [  OK  ]
Starting ovsdb-server                                   [  OK  ]
Configuring Open vSwitch system IDs                     [  OK  ]
Inserting openvswitch module                            [  OK  ]
Starting ovs-vswitchd                                   [  OK  ]
Enabling remote OVSDB managers                          [  OK  ]


[root@server5 ~(keystone_neutron)]#egrep 'ERROR|CRITICAL' /var/log/openvswitch/*


[root@server5 ~(keystone_neutron)]#chkconfig openvswitch on
[root@server5 ~(keystone_neutron)]#chkconfig openvswitch --list
openvswitch    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#ovs-vsctl add-br br-int
[root@server5 ~(keystone_neutron)]#ovs-vsctl show
666a6415-7ab8-4ebe-980b-181cf5567c7d
Bridge br-int
    Port br-int
        Interface br-int
            type: internal
ovs_version: "1.11.0"


[root@server5 ~(keystone_neutron)]#cp /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini.orig


[root@server5 ~(keystone_neutron)]#openstack-config --set /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini OVS integration_bridge br-int


[root@server5 ~(keystone_neutron)]#service neutron-openvswitch-agent start
Starting neutron-openvswitch-agent:                     [  OK  ]


[root@server5 ~(keystone_neutron)]#egrep 'ERROR|CRITICAL' /var/log/neutron/openvswitch-agent.log


[root@server5 ~(keystone_neutron)]#chkconfig neutron-openvswitch-agent on
[root@server5 ~(keystone_neutron)]#chkconfig neutron-openvswitch-agent --list
neutron-openvswitch-agent    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#chkconfig neutron-ovs-cleanup on
[root@server5 ~(keystone_neutron)]#chkconfig neutron-ovs-cleanup --list
neutron-ovs-cleanup    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#neutron-dhcp-setup --plugin openvswitch --qhost 192.168.0.105
Neutron plugin: openvswitch
Configuration updates complete!


[root@server5 ~(keystone_neutron)]#service neutron-dhcp-agent start
Starting neutron-dhcp-agent:                            [  OK  ]


[root@server5 ~(keystone_neutron)]#egrep 'ERROR|CRITICAL' /var/log/neutron/dhcp-agent.log
2014-10-29 16:30:40.599 6913 ERROR neutron.common.legacy [-] Skipping unknown group key: firewall_driver


[root@server5 ~(keystone_neutron)]#chkconfig neutron-dhcp-agent on
[root@server5 ~(keystone_neutron)]#chkconfig neutron-dhcp-agent --list
neutron-dhcp-agent    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#ovs-vsctl add-br br-ex
[root@server5 ~(keystone_neutron)]#ovs-vsctl show
666a6415-7ab8-4ebe-980b-181cf5567c7d
Bridge br-ex
    Port br-ex
        Interface br-ex
            type: internal
Bridge br-int
    Port br-int
        Interface br-int
            type: internal
ovs_version: "1.11.0"


[root@server5 ~(keystone_neutron)]#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/
[root@server5 ~(keystone_neutron)]#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br-ex


[root@server5 ~(keystone_neutron)]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
只剩下下列設定
DEVICE=eth0
HWADDR=52:54:00:00:00:05
ONBOOT=yes


[root@server5 ~(keystone_neutron)]#vi /etc/sysconfig/network-scripts/ifcfg-br-ex
修改 DEVICE 移除 HWADDR
DEVICE=br-ex
IPADDR=192.168.0.105
PREFIX=24
GATEWAY=192.168.0.254
DNS1=192.168.0.254
SEARCH1=example.com
ONBOOT=yes


[root@server5 ~(keystone_neutron)]#ovs-vsctl show
666a6415-7ab8-4ebe-980b-181cf5567c7d
Bridge br-ex
    Port br-ex
        Interface br-ex
            type: internal
Bridge br-int
    Port br-int
        Interface br-int
            type: internal
ovs_version: "1.11.0"


[root@server5 ~(keystone_neutron)]#ovs-vsctl add-port br-ex eth0 ; service network restart
Shutting down interface br-ex:                          [  OK  ]
Shutting down interface eth0:                           [  OK  ]
Shutting down interface eth1:                           [  OK  ]
Shutting down loopback interface:                       [  OK  ]
Bringing up loopback interface:                         [  OK  ]
Bringing up interface br-ex:  Determining if ip address 192.168.0.105 is already in use for device br-ex...
                                                       [  OK  ]
Bringing up interface eth0:                             [  OK  ]
Bringing up interface eth1:                             [  OK  ]


[root@server5 ~(keystone_neutron)]#ovs-vsctl show
666a6415-7ab8-4ebe-980b-181cf5567c7d
Bridge br-ex
    Port br-ex
        Interface br-ex
            type: internal
    Port "eth0"
        Interface "eth0"
Bridge br-int
    Port br-int
        Interface br-int
            type: internal
ovs_version: "1.11.0"


[root@server5 ~(keystone_neutron)]#neutron-l3-setup --plugin openvswitch --qhost 192.168.0.105
Neutron plugin: openvswitch
Configuration updates complete!


[root@server5 ~(keystone_neutron)]#service neutron-l3-agent start
Starting neutron-l3-agent:                              [  OK  ]


[root@server5 ~(keystone_neutron)]#egrep 'ERROR|CRITICAL' /var/log/neutron/l3-agent.log
2014-10-29 16:43:50.503 10008 ERROR neutron.common.legacy [-] Skipping unknown group key: firewall_driver


[root@server5 ~(keystone_neutron)]#chkconfig neutron-l3-agent on
[root@server5 ~(keystone_neutron)]#chkconfig neutron-l3-agent --list
neutron-l3-agent    0:off    1:off    2:on    3:on    4:on    5:on    6:off


[root@server5 ~(keystone_neutron)]#openstack-status


== neutron services ==
neutron-server:                      active
neutron-dhcp-agent:                  active
neutron-l3-agent:                    active
neutron-metadata-agent:              inactive  (disabled on boot)
neutron-lbaas-agent:                 inactive  (disabled on boot)
neutron-openvswitch-agent:           active

Lab: Configuring openStack networking
workbook p123



[root@server5 ~(keystone_neutron)]#source /root/keystonerc_myuser
[root@server5 ~(keystone_neutron)]#neutron router-create router1
Created a new router:
+-----------------------+--------------------------------------+
| Field              | Value                             |
+-----------------------+--------------------------------------+
| admin_state_up     | True                              |
| external_gateway_info |                                   |
| id                 | 9efbb27d-0b79-4efb-b4a2-3e0e82cd9d1a |
| name               | router1                           |
| status             | ACTIVE                            |
| tenant_id          | 047e809fc22e4ff687cfecbe15e728a0 |
+-----------------------+--------------------------------------+
[root@server5 ~(keystone_neutron)]#neutron net-create private
Created a new network:
+---------------------------+--------------------------------------+
| Field                  | Value                             |
+---------------------------+--------------------------------------+
| admin_state_up         | True                              |
| id                     | ececab49-b4c7-4dac-a661-8d3b0c48309e |
| name                   | private                           |
| provider:network_type | local                             |
| provider:physical_network |                                   |
| provider:segmentation_id  |                                   |
| shared                 | False                             |
| status                 | ACTIVE                            |
| subnets                |                                   |
| tenant_id              | 047e809fc22e4ff687cfecbe15e728a0 |
+---------------------------+--------------------------------------+


[root@server5 ~(keystone_neutron)]#neutron subnet-create --name subpriv private 192.168.32.0/24
Created a new subnet:
+------------------+----------------------------------------------------+
| Field         | Value                                           |
+------------------+----------------------------------------------------+
| allocation_pools | {"start": "192.168.32.2", "end": "192.168.32.254"} |
| cidr          | 192.168.32.0/24                                 |
| dns_nameservers  |                                                 |
| enable_dhcp   | True                                            |
| gateway_ip    | 192.168.32.1                                    |
| host_routes   |                                                 |
| id            | ddb7a99b-9d05-49cd-8a3f-b56d55bfa8fd            |
| ip_version    | 4                                               |
| name          | subpriv                                         |
| network_id    | ececab49-b4c7-4dac-a661-8d3b0c48309e            |
| tenant_id     | 047e809fc22e4ff687cfecbe15e728a0                |
+------------------+----------------------------------------------------+

[root@server5 ~(keystone_neutron)]#neutron router-interface-add router1 subpriv
Added interface 3e55916a-de77-4468-a02c-ebc6086a6444 to router router1.


[root@server5 ~(keystone_neutron)]#neutron port-list
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id                                | name | mac_address    | fixed_ips                                                                        |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| 3e55916a-de77-4468-a02c-ebc6086a6444 |   | fa:16:3e:06:8c:11 | {"subnet_id": "ddb7a99b-9d05-49cd-8a3f-b56d55bfa8fd", "ip_address": "192.168.32.1"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+


因為要更動底層網路所以需要 admin權限故切換身份
[root@server5 ~(keystone_neutron)]#source /root/keystonerc_admin


[root@server5 ~(keystone_admin)]$ neutron net-create --tenant-id services public --router:external=True
Created a new network:
+---------------------------+--------------------------------------+
| Field                  | Value                             |
+---------------------------+--------------------------------------+
| admin_state_up         | True                              |
| id                     | 52903fd8-05ff-4aa2-b2fe-e9da2c84d516 |
| name                   | public                            |
| provider:network_type | local                             |
| provider:physical_network |                                   |
| provider:segmentation_id  |                                   |
| router:external        | True                              |
| shared                 | False                             |
| status                 | ACTIVE                            |
| subnets                |                                   |
| tenant_id              | services                          |
+---------------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ neutron subnet-create --tenant-id services --allocation-pool start=172.24.5.1,end=172.24.5.100 --gateway 172.24.5.254 --disable-dhcp --name subpub public 172.24.5.0/24
Created a new subnet:
+------------------+------------------------------------------------+
| Field         | Value                                       |
+------------------+------------------------------------------------+
| allocation_pools | {"start": "172.24.5.1", "end": "172.24.5.100"} |
| cidr          | 172.24.5.0/24                               |
| dns_nameservers  |                                             |
| enable_dhcp   | False                                       |
| gateway_ip    | 172.24.5.254                                |
| host_routes   |                                             |
| id            | d5cfb7d6-2ed7-4f5a-bb4b-dbe50e780323        |
| ip_version    | 4                                           |
| name          | subpub                                      |
| network_id    | 52903fd8-05ff-4aa2-b2fe-e9da2c84d516        |
| tenant_id     | services                                    |
+------------------+------------------------------------------------+


[root@server5 ~(keystone_admin)]$ neutron router-gateway-set router1 public
Set gateway for router router1


[root@server5 ~(keystone_admin)]$ neutron port-list
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id                                | name | mac_address    | fixed_ips                                                                        |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| 3e55916a-de77-4468-a02c-ebc6086a6444 |   | fa:16:3e:06:8c:11 | {"subnet_id": "ddb7a99b-9d05-49cd-8a3f-b56d55bfa8fd", "ip_address": "192.168.32.1"} |
| 81b922ce-1544-42b6-a60e-4d899618f34c |   | fa:16:3e:3f:52:5f | {"subnet_id": "d5cfb7d6-2ed7-4f5a-bb4b-dbe50e780323", "ip_address": "172.24.5.1"}   |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+


[root@server5 ~(keystone_admin)]$ neutron floatingip-list


[root@server5 ~(keystone_admin)]$ neutron floatingip-create public
Created a new floatingip:
+---------------------+--------------------------------------+
| Field            | Value                             |
+---------------------+--------------------------------------+
| fixed_ip_address |                                   |
| floating_ip_address | 172.24.5.2                        |
| floating_network_id | 52903fd8-05ff-4aa2-b2fe-e9da2c84d516 |
| id               | b1db8c2a-09d9-4c5b-8e50-096e15af019c |
| port_id          |                                   |
| router_id        |                                   |
| tenant_id        | 0fa2ca1bd34c4a4b88ce36272038574d |
+---------------------+--------------------------------------+


[root@server5 ~(keystone_admin)]$ neutron floatingip-list
+--------------------------------------+------------------+---------------------+---------+
| id                                | fixed_ip_address | floating_ip_address | port_id |
+--------------------------------------+------------------+---------------------+---------+
| b1db8c2a-09d9-4c5b-8e50-096e15af019c |               | 172.24.5.2       |      |
+--------------------------------------+------------------+---------------------+---------+