Bài 10:Cấu hình Cloud Compute trong CentOS 6(phần 1-OpenStack Havana)

1.Tìm hiểu về OpenStack  Giới thiệu về OpenStack Havana.

2. Chuẩn bị cài đặt.

để xây dựng một Cloud Computing với OpenStack Havana thì phải cài đặt các thành phần sau.

[1] cài đặt NTP (hướng dẫn cài đặt NTP)

[2]-cài đặt KVM(hướng dẫn cài đặt KVM)

[3]Cài đặt Apache HTTP Server(Cài đặt Apache HTTP Server)

[4] Cài đặt MySQL Server (Hướng dẫn cài đặt Cài đặt MySQL Server)

[5] Cài đặt Repository của OpenStack Havana và Qpid,Memcached,Avahi

[root@dlp ~]#wget http://repos.fedorapeople.org/repos/openstack/openstack-havana/epel-openstack-havana.repo -P /etc/yum.repos.d [root@dlp ~]#sed -i -e “s/enabled=1/enabled=0/g” /etc/yum.repos.d/epel-openstack-havana.repo
[root@dlp ~]#yum -y install qpid-cpp-server memcached avahi
[root@dlp ~]#vi /etc/qpidd.conf
# last line: change

auth=no

[root@dlp ~]#for service in qpidd memcached avahi-daemon; do

/etc/rc.d/init.d/$service start chkconfig $service on done

Starting Qpid AMQP daemon: [ OK ] Starting memcached: [ OK ] Starting Avahi daemon… [ OK ]

3.Cấu hình Keystone #1

[1] Cài đặt  Keystone

[root@dlp ~]#yum –enablerepo=openstack-havana,epel -y install openstack-keystone openstack-utils

[2] Cấu hình Keystone
# set database ( set any password you like for “password” section )

[root@dlp ~]#openstack-db –init –service keystone –password password Please enter the password for the ‘root’ MySQL user:

# MySQL root password

Verified connectivity to MySQL. Creating ‘keystone’ database. Updating ‘keystone’ database password in /etc/keystone/keystone.conf Initializing the keystone database, please wait… Complete!

[root@dlp ~]#vi /etc/keystone/keystone.conf
# line 3 : uncomment and change

admin_token =admintoken

# line 6 : uncomment

bind_host = 0.0.0.0

# line 9 : uncomment

public_port = 5000

# line 12 : uncomment

admin_port = 35357

# line 20 : uncomment

compute_port = 8774

# line 310 : uncomment and add

token_format =PKI

# line 312 : uncomment all and chnage to your locations like below

certfile = /etc/keystone/pki/certs/signing_cert.pem keyfile = /etc/keystone/pki/private/signing_key.pem ca_certs = /etc/keystone/pki/certs/cacert.pem ca_key = /etc/keystone/pki/private/cakey.pem key_size = 2048 valid_days = 3650 cert_subject =/C=JP/ST=Hiroshima/L=Hiroshima/O=Server_World/CN=dlp.server.world

[root@dlp ~]#keystone-manage pki_setup –keystone-user keystone –keystone-group keystone

2013-10-22 19:30:28.215 2276 INFO keystone.common.openssl [-] openssl req 
-key /etc/keystone/pki/private/signing_key.pem -new -out /etc/keystone/pki/certs/req.pem 
-config /etc/keystone/pki/certs/openssl.conf 
-subj /C=JP/ST=Hiroshima/L=Hiroshima/O=Server_World/CN=dlp.server.world
2013-10-22 19:30:28.229 2276 INFO keystone.common.openssl [-] openssl ca 
-batch -out /etc/keystone/pki/certs/signing_cert.pem 
-config /etc/keystone/pki/certs/openssl.conf 
-days 3650d -cert /etc/keystone/pki/certs/cacert.pem 
-keyfile /etc/keystone/pki/private/cakey.pem 
-infiles /etc/keystone/pki/certs/req.pem
Using configuration from /etc/keystone/pki/certs/openssl.conf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'JP'
stateOrProvinceName   :ASN.1 12:'Hiroshima'
localityName          :ASN.1 12:'Hiroshima'
organizationName      :ASN.1 12:'Server_World'
commonName            :ASN.1 12:'dlp.server.world'
Certificate is to be certified until Oct 20 10:30:28 2023 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated

[root@dlp ~]#/etc/rc.d/init.d/openstack-keystone start Starting keystone: [ OK ] [root@dlp ~]#chkconfig openstack-keystone on

4.Cấu hình Keystone#2 Add User hoặc Roles, Services trong Keystone

[1]Đầu tiên Load environment variables . thiết lập value cho “SERVICE_TOKEN” từ giá trị “admin_token” trong keystone.conf.
[root@dlp ~]#export SERVICE_TOKEN=admintoken [root@dlp ~]#export SERVICE_ENDPOINT=http://10.0.0.30:35357/v2.0/
[2] Add Tenants ( giống group )
# add admin tenant

[root@dlp ~]#keystone tenant-create –name admin –description “Admin Tenant” –enabled true

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |           Admin Tenant           |
|   enabled   |               True               |
|      id     | 97be94660c2043e58fee407bc9cde0d5 |
|     name    |              admin               |
+-------------+----------------------------------+

# add service tenant

[root@dlp ~]#keystone tenant-create –name service –description “Service Tenant” –enabled true

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |          Service Tenant          |
|   enabled   |               True               |
|      id     | 17867024fb23470f8005a15c6ccfed44 |
|     name    |             service              |
+-------------+----------------------------------+

# confirm settings

[root@dlp ~]#keystone tenant-list

+----------------------------------+---------+---------+
|                id                |   name  | enabled |
+----------------------------------+---------+---------+
| 97be94660c2043e58fee407bc9cde0d5 |  admin  |   True  |
| 17867024fb23470f8005a15c6ccfed44 | service |   True  |
+----------------------------------+---------+---------+
[3] Add Roles
# add admin role

[root@dlp ~]#keystone role-create –name admin

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | 51077b36f67b47e299cfc275157eb5a6 |
|   name   |              admin               |
+----------+----------------------------------+

# add Member role

[root@dlp ~]#keystone role-create –name Member

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | e67eabd9c4ff4559b3f3e09666473bc6 |
|   name   |              Member              |
+----------+----------------------------------+

# confirm settings

[root@dlp ~]#keystone role-list

+----------------------------------+----------+
|                id                |   name   |
+----------------------------------+----------+
| e67eabd9c4ff4559b3f3e09666473bc6 |  Member  |
| 9fe2ff9ee4384b1894a90878d3e92bab | _member_ |
| 51077b36f67b47e299cfc275157eb5a6 |  admin   |
+----------------------------------+----------+
[4] Add Users
# add admin user (set in admin tenant)

[root@dlp ~]#keystone user-create –tenant admin –name admin –pass adminpassword –enabled true

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | 279ade4f97014020b0e7855f2f72e40f |
|   name   |              admin               |
| tenantId | 97be94660c2043e58fee407bc9cde0d5 |
+----------+----------------------------------+

# add admin user in admin role

[root@dlp ~]#keystone user-role-add –user admin –tenant admin –role admin

# add cinder user (set in service tenant)

[root@dlp ~]#keystone user-create –tenant service –name cinder –pass servicepassword –enabled true

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | 68fb4adcb2664dcb8747be70a12173ff |
|   name   |              cinder              |
| tenantId | 17867024fb23470f8005a15c6ccfed44 |
+----------+----------------------------------+

# add cinder user in admin role

[root@dlp ~]#keystone user-role-add –user cinder –tenant service –role admin

# add glance user (set in service tenant)

[root@dlp ~]#keystone user-create –tenant service –name glance –pass servicepassword –enabled true

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | ea825d2bae8c4b27bd2fea1186c433bb |
|   name   |              glance              |
| tenantId | 17867024fb23470f8005a15c6ccfed44 |
+----------+----------------------------------+

# add glance user in admin role

[root@dlp ~]#keystone user-role-add –user glance –tenant service –role admin

# add nova user (set in service tenant))

[root@dlp ~]#keystone user-create –tenant service –name nova –pass servicepassword –enabled true

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | 66abd2503a7c40d8b3d6fe9a733787ec |
|   name   |               nova               |
| tenantId | 17867024fb23470f8005a15c6ccfed44 |
+----------+----------------------------------+

# add nova user in admin role

[root@dlp ~]#keystone user-role-add –user nova –tenant service –role admin

# confirm settings

[root@dlp ~]#keystone user-list

+----------------------------------+--------+---------+-------+
|                id                |  name  | enabled | email |
+----------------------------------+--------+---------+-------+
| 279ade4f97014020b0e7855f2f72e40f | admin  |   True  |       |
| 68fb4adcb2664dcb8747be70a12173ff | cinder |   True  |       |
| ea825d2bae8c4b27bd2fea1186c433bb | glance |   True  |       |
| 66abd2503a7c40d8b3d6fe9a733787ec |  nova  |   True  |       |
+----------------------------------+--------+---------+-------+
[5] Add entries cho services
# add for keystone

[root@dlp ~]#keystone service-create –name=keystone –type=identity –description=”Keystone Identity Service”

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |    Keystone Identity Service     |
|      id     | 90e34600f87043dc95488a5cf6f30118 |
|     name    |             keystone             |
|     type    |             identity             |
+-------------+----------------------------------+

# add for cinder

[root@dlp ~]#keystone service-create –name=cinder –type=volume –description=”Cinder Service”

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |          Cinder Service          |
|      id     | 8214ec203d6e434f8a0eb2687ef7aa0c |
|     name    |              cinder              |
|     type    |              volume              |
+-------------+----------------------------------+

# add for glance

[root@dlp ~]#keystone service-create –name=glance –type=image –description=”Glance Image Service”

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |       Glance Image Service       |
|      id     | d364dd1bb04741ff86a303c36cee4a47 |
|     name    |              glance              |
|     type    |              image               |
+-------------+----------------------------------+

# add for nova

[root@dlp ~]#keystone service-create –name=nova –type=compute –description=”Nova Compute Service”

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |       Nova Compute Service       |
|      id     | 8d2ff23b12144ce3a645aeb85cbbeec3 |
|     name    |               nova               |
|     type    |             compute              |
+-------------+----------------------------------+

# confirm settings

[root@dlp ~]#keystone service-list

+----------------------------------+----------+----------+---------------------------+
|                id                |   name   |   type   |        description        |
+----------------------------------+----------+----------+---------------------------+
| 8214ec203d6e434f8a0eb2687ef7aa0c |  cinder  |  volume  |       Cinder Service      |
| d364dd1bb04741ff86a303c36cee4a47 |  glance  |  image   |    Glance Image Service   |
| 90e34600f87043dc95488a5cf6f30118 | keystone | identity | Keystone Identity Service |
| 8d2ff23b12144ce3a645aeb85cbbeec3 |   nova   | compute  |    Nova Compute Service   |
+----------------------------------+----------+----------+---------------------------+
[6] Add Endpoints
# define my host

[root@dlp ~]#export my_host=10.0.0.30

# add endpoint for keystone

[root@dlp ~]#keystone endpoint-create –region RegionOne \

–service keystone \ –publicurl “http://$my_host:\$(public_port)s/v2.0” \ –internalurl “http://$my_host:\$(public_port)s/v2.0” \ –adminurl “http://$my_host:\$(admin_port)s/v2.0”
+-------------+---------------------------------------+
|   Property  |                 Value                 |
+-------------+---------------------------------------+
|   adminurl  |  http://10.0.0.30:$(admin_port)s/v2.0 |
|      id     |    8abd184835d849c89e2853b1d5e110d5   |
| internalurl | http://10.0.0.30:$(public_port)s/v2.0 |
|  publicurl  | http://10.0.0.30:$(public_port)s/v2.0 |
|    region   |               RegionOne               |
|  service_id |    90e34600f87043dc95488a5cf6f30118   |
+-------------+---------------------------------------+

# add endpoint for cinder

[root@dlp ~]#keystone endpoint-create –region RegionOne \

–service cinder \ –publicurl “http://$my_host:8776/v1/\$(tenant_id)s” \ –internalurl “http://$my_host:8776/v1/\$(tenant_id)s” \ –adminurl “http://$my_host:8776/v1/\$(tenant_id)s”
+-------------+----------------------------------------+
|   Property  |                 Value                  |
+-------------+----------------------------------------+
|   adminurl  | http://10.0.0.30:8776/v1/$(tenant_id)s |
|      id     |    e1e864f12648435fa7ad1ed4d94729c5    |
| internalurl | http://10.0.0.30:8776/v1/$(tenant_id)s |
|  publicurl  | http://10.0.0.30:8776/v1/$(tenant_id)s |
|    region   |               RegionOne                |
|  service_id |    8214ec203d6e434f8a0eb2687ef7aa0c    |
+-------------+----------------------------------------+

# add endpoint for glance

[root@dlp ~]#keystone endpoint-create –region RegionOne \

–service glance \ –publicurl “http://$my_host:9292/v1” \ –internalurl “http://$my_host:9292/v1” \ –adminurl “http://$my_host:9292/v1”
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |     http://10.0.0.30:9292/v1     |
|      id     | 99a80cd8a9f3495a88bdb9d446735663 |
| internalurl |     http://10.0.0.30:9292/v1     |
|  publicurl  |     http://10.0.0.30:9292/v1     |
|    region   |            RegionOne             |
|  service_id | d364dd1bb04741ff86a303c36cee4a47 |
+-------------+----------------------------------+

# add endpoint for nova

[root@dlp ~]#keystone endpoint-create –region RegionOne \

–service nova \ –publicurl “http://$my_host:\$(compute_port)s/v1.1/\$(tenant_id)s” \ –internalurl “http://$my_host:\$(compute_port)s/v1.1/\$(tenant_id)s” \ –adminurl “http://$my_host:\$(compute_port)s/v1.1/\$(tenant_id)s”
+-------------+------------------------------------------------------+
|   Property  |                        Value                         |
+-------------+------------------------------------------------------+
|   adminurl  | http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|      id     |           a7358113abe64724a52877ab45dab0f5           |
| internalurl | http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|  publicurl  | http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|    region   |                      RegionOne                       |
|  service_id |           8d2ff23b12144ce3a645aeb85cbbeec3           |
+-------------+------------------------------------------------------+

# confirm settings

[root@dlp ~]#keystone endpoint-list

+----------------------------------+-----------+
|                id                |   region  |
+----------------------------------+-----------+
| 8abd184835d849c89e2853b1d5e110d5 | RegionOne |
| 99a80cd8a9f3495a88bdb9d446735663 | RegionOne |
| a7358113abe64724a52877ab45dab0f5 | RegionOne |
| e1e864f12648435fa7ad1ed4d94729c5 | RegionOne |
+----------------------------------+-----------+
+------------------------------------------------------+
|                      publicurl                       |
+------------------------------------------------------+
|        http://10.0.0.30:$(public_port)s/v2.0         |
|               http://10.0.0.30:9292/v1               |
| http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|        http://10.0.0.30:8776/v1/$(tenant_id)s        |
+------------------------------------------------------+
+------------------------------------------------------+
|                     internalurl                      |
+------------------------------------------------------+
|        http://10.0.0.30:$(public_port)s/v2.0         |
|               http://10.0.0.30:9292/v1               |
| http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|        http://10.0.0.30:8776/v1/$(tenant_id)s        |
+------------------------------------------------------+
+------------------------------------------------------+
|                       adminurl                       |
+------------------------------------------------------+
|         http://10.0.0.30:$(admin_port)s/v2.0         |
|               http://10.0.0.30:9292/v1               |
| http://10.0.0.30:$(compute_port)s/v1.1/$(tenant_id)s |
|        http://10.0.0.30:8776/v1/$(tenant_id)s        |
+------------------------------------------------------+
+----------------------------------+
|            service_id            |
+----------------------------------+
| 90e34600f87043dc95488a5cf6f30118 |
| d364dd1bb04741ff86a303c36cee4a47 |
| 8d2ff23b12144ce3a645aeb85cbbeec3 |
| 8214ec203d6e434f8a0eb2687ef7aa0c |
+----------------------------------+

5. Cài đặt và cấu hình OpenStack Image Service(Glance).

[1] Cài đặt Glance
# install from EPEL OpenStack, EPEL

[root@dlp ~]#yum –enablerepo=openstack-havana,epel -y install openstack-glance

[2] Cấu hình Glance
# set database ( set any password you like for “password” section )

[root@dlp ~]#openstack-db –init –service glance –password password

Please enter the password for the ‘root’ MySQL user:

# MySQL root password

Verified connectivity to MySQL.
Creating ‘glance’ database.
Updating ‘glance’ database password in /etc/glance/glance-registry.conf /etc/glance/glance-api.conf
Initializing the glance database, please wait…
Complete!

[root@dlp ~]#vi /etc/glance/glance-registry.conf

# line 84 : uncomment all and change to the value set in Keystone

[keystone_authtoken]
auth_host =10.0.0.30

auth_port = 35357
auth_protocol = http
admin_tenant_name =service

admin_user =glance

admin_password =servicepassword

# add at the last
flavor = keystone

[root@dlp ~]#vi /etc/glance/glance-api.conf

# line 429 : uncomment all and change to the value set in Keystone

[keystone_authtoken]
auth_host =10.0.0.30

auth_port = 35357
auth_protocol = http
admin_tenant_name =service

admin_user =glance

admin_password =servicepassword

# add at the last
flavor = keystone

[root@dlp ~]#for service in api registry; do

/etc/rc.d/init.d/openstack-glance-$service start
chkconfig openstack-glance-$service on
done

Starting openstack-glance-api: [ OK ]
Starting openstack-glance-registry: [ OK ]

 

6.Cài đặt và cấu hình OpenStack Compute Service(Nova)

[1] Cài đặt Nova
# install from EPEL OpenStack, EPEL

[root@dlp ~]#yum –enablerepo=openstack-havana,epel -y install openstack-nova

[2] Cấu hình Nova
# set database ( set any password you like for “password” section )

[root@dlp ~]#openstack-db –init –service nova –password password

Please enter the password for the ‘root’ MySQL user:

# MySQL root password

Verified connectivity to MySQL.
Creating ‘nova’ database.
Updating ‘nova’ database password in /etc/nova/nova.conf
Initializing the nova database, please wait…
Complete!

[root@dlp ~]#vi /etc/nova/nova.conf

# line 59 : uncomment and change to the own IP

my_ip=10.0.0.30

# line 65 : uncomment and change to the own hostname)

host=dlp.server.world

# line 68 : uncomment if not need

use_ipv6=false

# line 100 : uncomment

state_path=/var/lib/nova

# line 191 : uncomment

enabled_apis=ec2,osapi_compute,metadata

# line 197 : uncomment

ec2_listen=0.0.0.0

# line 200 : uncomment

ec2_listen_port=8773

# line 206 : uncomment

osapi_compute_listen=0.0.0.0

# line 209 : uncomment

osapi_compute_listen_port=8774

# line 237 : uncomment

network_manager=nova.network.manager.FlatDHCPManager

# line 274 : uncomment

rootwrap_config=/etc/nova/rootwrap.conf

# line 287 : uncomment

api_paste_config=api-paste.ini

# line 320 : uncomment and change

auth_strategy=keystone

# line 909 : uncomment

glance_host=$my_ip

# line 912 : uncomment

glance_port=9292

# line 916 : uncomment

glance_protocol=http

# line 921 : uncomment

glance_api_servers=$glance_host:$glance_port

# line 980 : uncomment

network_api_class=nova.network.api.API

# line 988 : uncomment

network_driver=nova.network.linux_net

# line 1060 : uncomment

dhcpbridge_flagfile=/etc/nova/nova.conf

# line 1066 : uncomment and specify nic for public

public_interface=eth0

# line 1072 : uncomment

dhcpbridge=/usr/bin/nova-dhcpbridge

# line 1101 : uncomment

linuxnet_interface_driver=nova.network.linux_net.LinuxBridgeInterfaceDriver

# line 1146 : uncomment and specify any name you like for bridge

flat_network_bridge=br100

# line 1157 : uncomment and specify nic for flat DHCP bridge

flat_interface=lo

# line 1308 : uncomment

security_group_api=nova

# line 1434 : uncomment

log_dir=/var/log/nova

# line 1457 : uncomment and add

notification_driver=nova.openstack.common.notifier.rpc_notifier

# line 1491 : uncomment

rpc_backend=nova.openstack.common.rpc.impl_qpid

# line 1596 : uncomment and specify Qpid server

qpid_hostname=10.0.0.30

# line 1599 : uncomment

qpid_port=5672

# line 1801 : uncomment

scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,
ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter

# line 1919 : uncomment

compute_driver=libvirt.LibvirtDriver

# line 1940 : uncomment

firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver

# line 1970 : uncomment

libvirt_type=kvm

# line 2011 : uncomment

libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtGenericVIFDriver

# line 2147 : uncomment

libvirt_use_virtio_for_bridges=true

# line 3377 : uncomment and specify tenant name

admin_tenant_name=service

# line 3380 : uncomment and specify admin user

admin_user=nova

# line 3383 : uncomment and specify admin password

admin_password=servicepassword

# line 3386 : uncomment and specify Keystone server

auth_host=10.0.0.30

# line 3389 : uncomment

auth_port=35357

# line 3392 : uncomment

auth_protocol=http

# line 3395 : uncomment

auth_version=v2.0

# line 3400 : uncomment

signing_dir=/var/lib/nova/keystone-signing

[root@dlp ~]#for service in api objectstore compute conductor network scheduler cert consoleauth; do

/etc/rc.d/init.d/openstack-nova-$service start
chkconfig openstack-nova-$service on
done
Starting openstack-nova-api:                               [  OK  ]
Starting openstack-nova-objectstore:                       [  OK  ]
Starting openstack-nova-compute:                           [  OK  ]
Starting openstack-nova-conductor:                         [  OK  ]
Starting openstack-nova-network:                           [  OK  ]
Starting openstack-nova-scheduler:                         [  OK  ]
Starting openstack-nova-cert:                              [  OK  ]
Starting openstack-nova-consoleauth:                       [  OK  ]

# start cert again because it is down at first booting

[root@dlp ~]#/etc/rc.d/init.d/openstack-nova-cert start

Starting openstack-nova-cert: [ OK ]

# confirm status

[root@dlp ~]#nova-manage service list

Binary           Host                    Zone            Status     State Updated_At
nova-scheduler   dlp.server.world        internal        enabled    :-)   2013-10-22 13:54:12
nova-network     dlp.server.world        internal        enabled    :-)   2013-10-22 13:54:13
nova-cert        dlp.server.world        internal        enabled    :-)   2013-10-22 13:54:12
nova-consoleauth dlp.server.world        internal        enabled    :-)   2013-10-22 13:54:12
nova-conductor   dlp.server.world        internal        enabled    :-)   2013-10-22 13:54:12
nova-compute     dlp.server.world        nova            enabled    :-)   2013-10-22 13:54:13

 

7. Add Virtual Machine images trong Glance.

[1] Load environment variables đầu tiên.
[root@dlp ~]#unset SERVICE_TOKEN[root@dlp ~]#unset SERVICE_ENDPOINT

[root@dlp ~]#vi ~/keystonerc

export OS_USERNAME=admin
export OS_PASSWORD=adminpassword
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/
export PS1='[\u@\h \W(keystone)]\$ ‘

[root@dlp ~]#chmod 600 ~/keystonerc

[root@dlp ~]#source ~/keystonerc

[root@dlp ~(keystone)]#echo “source ~/keystonerc ” >> ~/.bash_profile

# confirm status (it’s OK if no errors are shown)

[root@dlp ~(keystone)]#glance image-list

[2] Ví dụ tạo Virtual Machine image CentOS 6 cho việc adding.
# create a directory for disk image

[root@dlp ~]#mkdir -p /var/kvm/images

# create a disk image

[root@dlp ~]#qemu-img create -f qcow2 /var/kvm/images/centos6.img 10G

# install

[root@dlp ~]#virt-install \

-n centos6 \
-r 2048 \
–disk path=/var/kvm/images/centos6.img,format=qcow2 \
–vcpus=2 \
–os-type linux \
–os-variant=rhel6 \
–nographics \
–location=’http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.4/os/x86_64/’ \
–extra-args=’console=tty0 console=ttyS0,115200n8 serial’

Starting install…

# installation starts
[3] Sau khi cài đặt, thay đổi cấu hình virtual machine như bên dưới và shutdown nó.
* delete hoặc comment ngoài line “HWADDR” and “UUID” in /etc/sysconfig/network-scripts/ifcfg-eth0
* thiết lập “dhcp” for “BOOTPROTO” in /etc/sysconfig/network-scripts/ifcfg-eth0
* delete file “/etc/udev/rules.d/70-persistent-net.rules”
[4] Add virtual image tới Glance.
[root@dlp ~(keystone)]#glance image-create –name=”CentOS6″ –is-public=true –disk-format=qcow2 –container-format=bare < /var/kvm/images/centos6.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 8794d92243f25b712a834992e731eccd     |
| container_format | bare                                 |
| created_at       | 2013-10-22T12:43:42                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 46042f47-c307-4fce-af0d-a1b2c14d6d78 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CentOS6                              |
| owner            | 97be94660c2043e58fee407bc9cde0d5     |
| protected        | False                                |
| size             | 976420864                            |
| status           | active                               |
| updated_at       | 2013-10-22T12:43:49                  |
+------------------+--------------------------------------+

[root@dlp ~(keystone)]#glance image-list

+-------------+---------+-------------+------------------+-----------+--------+
| ID          | Name    | Disk Format | Container Format | Size      | Status |
+-------------+---------+-------------+------------------+-----------+--------+
| 46042f47-c3 | CentOS6 | qcow2       | bare             | 976420864 | active |
+-------------+---------+-------------+------------------+-----------+--------+
[5] Ví dụ hướng dẫn download image từ internet và add nó.

[root@dlp ~]#wget http://cloud-images.ubuntu.com/releases/13.10/release/ubuntu-13.10-server-cloudimg-amd64-disk1.img -P /var/kvm/images

[root@dlp ~]#glance image-create –name=”Ubuntu1310″ –is-public=true –disk-format=qcow2 –container-format=bare < /var/kvm/images/ubuntu-13.10-server-cloudimg-amd64-disk1.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 567c81fee02aa4d6d97a41d10c7daaf4     |
| container_format | bare                                 |
| created_at       | 2013-10-22T16:28:23                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | d6dbbd44-7f71-409e-ac89-8181d9c2bca4 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1310                           |
| owner            | 97be94660c2043e58fee407bc9cde0d5     |
| protected        | False                                |
| size             | 241762304                            |
| status           | active                               |
| updated_at       | 2013-10-22T16:28:24                  |
+------------------+--------------------------------------+

[root@dlp ~(keystone)]#glance image-list

+-------------+------------+-------------+------------------+-----------+--------+
| ID          | Name       | Disk Format | Container Format | Size      | Status |
+-------------+------------+-------------+------------------+-----------+--------+
| 46042f47-c3 | CentOS6    | qcow2       | bare             | 976420864 | active |
| d6dbbd44-7f | Ubuntu1310 | qcow2       | bare             | 241762304 | active |
+-------------+------------+-------------+------------------+-----------+--------+

8.Tạo và Chạy Virtual Machine Instance.

[1] Tạo network trong OpenStack internal system.
# nova-manage network create –label (any name) –dns1 (DNS server) –fixed_range_v4=(internal range)

[root@dlp ~(keystone)]#nova-manage network create –label network01 –dns1 10.0.0.10 –fixed_range_v4=10.1.0.0/24

[root@dlp ~(keystone)]#nova-manage network list

id   IPv4           IPv6   start address   DNS1        DNS2    VlanID   project   uuid
1    10.1.0.0/24    None   10.1.0.2        10.0.0.10   None    None     None      a02b7b6d-1fb1-
[2]Thay đổi security rules mặc định để truy cập với SSH.
# permit SSH

[root@dlp ~(keystone)]#nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

# permit ICMP

[root@dlp ~(keystone)]#nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

[root@dlp ~(keystone)]#nova secgroup-list-rules default

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+
[3] Specify flavor (memory or disk) and create an instance and boot it.
# default flavor list

[root@dlp ~(keystone)]#nova flavor-list

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

# confirm virtual image

[root@dlp ~(keystone)]#nova image-list

+--------------------------------------+---------+--------+--------+
| ID                                   | Name    | Status | Server |
+--------------------------------------+---------+--------+--------+
| 46042f47-c307-4fce-af0d-a1b2c14d6d78 | CentOS6 | ACTIVE |        |
+--------------------------------------+---------+--------+--------+

# create and boot an instance

[root@dlp ~(keystone)]#nova boot –flavor 2 –image CentOS6 –security_group default CentOS_64

+--------------------------------------+--------------------------------------+
| Property                             | Value                                |
+--------------------------------------+--------------------------------------+
| OS-EXT-STS:task_state                | scheduling                           |
| image                                | CentOS6                              |
| OS-EXT-STS:vm_state                  | building                             |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000003                    |
| OS-SRV-USG:launched_at               | None                                 |
| flavor                               | m1.small                             |
| id                                   | 081bba5e-0a88-4ae5-9757-645f682d172b |
| security_groups                      | [{u'name': u'default'}]              |
| user_id                              | 279ade4f97014020b0e7855f2f72e40f     |
| OS-DCF:diskConfig                    | MANUAL                               |
| accessIPv4                           |                                      |
| accessIPv6                           |                                      |
| progress                             | 0                                    |
| OS-EXT-STS:power_state               | 0                                    |
| OS-EXT-AZ:availability_zone          | nova                                 |
| config_drive                         |                                      |
| status                               | BUILD                                |
| updated                              | 2013-10-22T13:55:47Z                 |
| hostId                               |                                      |
| OS-EXT-SRV-ATTR:host                 | None                                 |
| OS-SRV-USG:terminated_at             | None                                 |
| key_name                             | None                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |
| name                                 | CentOS_64                            |
| adminPass                            | sC68kbDrrCgE                         |
| tenant_id                            | 97be94660c2043e58fee407bc9cde0d5     |
| created                              | 2013-10-22T13:55:47Z                 |
| os-extended-volumes:volumes_attached | []                                   |
| metadata                             | {}                                   |
+--------------------------------------+--------------------------------------+

# confirm status

[root@dlp ~(keystone)]#nova list

+------------+-----------+--------+------------+-------------+--------------------+
| ID         | Name      | Status | Task State | Power State | Networks           |
+------------+-----------+--------+------------+-------------+--------------------+
| 081bba5e-0 | CentOS_64 | BUILD  | spawning   | NOSTATE     | network01=10.1.0.2 |
+------------+-----------+--------+------------+-------------+--------------------+
[4] Login Instance đẵ được khởi động.
# after few minutes later, the Status turns “ACTIVE” like follows

[root@dlp ~(keystone)]#nova list

+------------+-----------+--------+------------+-------------+--------------------+
| ID         | Name      | Status | Task State | Power State | Networks           |
+------------+-----------+--------+------------+-------------+--------------------+
| 081bba5e-0 | CentOS_64 | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+-----------+--------+------------+-------------+--------------------+

# it’s OK if answer replys like follows

[root@dlp ~(keystone)]#ping 10.1.0.2

PING 10.1.0.2 (10.1.0.2) 56(84) bytes of data.
64 bytes from 10.1.0.2: icmp_seq=1 ttl=64 time=0.278 ms
64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.433 ms
^C
--- 10.1.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1652ms
rtt min/avg/max/mdev = 0.278/0.355/0.433/0.079 ms

# login with SSH

[root@dlp ~(keystone)]#ssh 10.1.0.2

The authenticity of host ‘10.1.0.2 (10.1.0.2)’ can’t be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:6b:9e:a6.
Are you sure you want to continue connecting (yes/no)?

yes

Warning: Permanently added ‘10.1.0.2’ (RSA) to the list of known hosts.
root@10.1.0.2’s password:

# the root password you set during virtual machine installation

Last login: Tue Oct 22 12:42:21 2013
[root@centos-64 ~]#

# just logined normally
[5] có thể shutdown trong instance với shutdown command , Nhưng cũng có thế được điều khiển với nova command như bên dưới.
[root@dlp ~(keystone)]#nova list

+------------+-----------+--------+------------+-------------+--------------------+
| ID         | Name      | Status | Task State | Power State | Networks           |
+------------+-----------+--------+------------+-------------+--------------------+
| 081bba5e-0 | CentOS_64 | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+-----------+--------+------------+-------------+--------------------+

# stop instance

[root@dlp ~(keystone)]#nova stop CentOS_64

[root@dlp ~(keystone)]#nova list

+------------+-----------+---------+------------+-------------+--------------------+
| ID         | Name      | Status  | Task State | Power State | Networks           |
+------------+-----------+---------+------------+-------------+--------------------+
| 081bba5e-0 | CentOS_64 | SHUTOFF | None       | Shutdown    | network01=10.1.0.2 |
+------------+-----------+---------+------------+-------------+--------------------+

# start instance again

[root@dlp ~(keystone)]#nova start CentOS_64

[root@dlp ~(keystone)]#nova list

+------------+-----------+--------+------------+-------------+--------------------+
| ID         | Name      | Status | Task State | Power State | Networks           |
+------------+-----------+--------+------------+-------------+--------------------+
| 081bba5e-0 | CentOS_64 | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+-----------+--------+------------+-------------+--------------------+