Before Installation
Add repository
root@nova:~$ apt-get install -y python-software-properties root@nova:~$ add-apt-repository ppa:openstack-ubuntu-testing/folsom-trunk-testing root@nova:~$ add-apt-repository ppa:openstack-ubuntu-testing/folsom-deps-staging root@nova:~$ apt-get update && apt-get -y dist-upgrade
Hostname Setting
最簡單的方式是在 /etc/hosts 內設定會用到的 hostname172.17.123.12 rabbitmq 172.17.123.12 mysql 172.17.123.12 cinder 172.17.123.13 keystone 172.17.123.14 swift-proxy 172.17.123.16 glance 172.17.123.17 nova
MySQL Setting
在 MySQL 內加入一個新的 database, 如果 MySQL 和 Glance 在同一台 Server 上, 記得也要設定從 localhost 登入的權限及密碼mysql> CREATE DATABASE nova; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON nova.* TO 'nova'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec)
在 Nova 這邊記得也要裝 mysql-client, 然後可以測試看看能不能連線成功
root@nova:~$ apt-get install mysql-client python-mysqldb root@nova:~$ mysql -h 172.17.123.12 -u nova -ppassword Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 236 Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Environment Variable Setting
編輯一個設定檔: novarc, 設定一些等下會用到的區域變數, 並且匯到 .bashrc 之中, 下次再進來就不需要重新設定root@glance:~$ cat novarc export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=password export OS_AUTH_URL="http://keystone:5000/v2.0/" export SERVICE_ENDPOINT="http://keystone:35357/v2.0" export SERVICE_TOKEN=password root@glance:~$ source novarc root@glance:~$ echo "source novarc">>.bashrc
Keystone Setting
把 endpoint 的網址設定好root@nova:~$ apt-get install python-keystoneclient root@nova:~$ keystone endpoint-list +----------------------------------+-----------+-----------------------------------------------+-----------------------------------------------+--------------------------------------+ | id | region | publicurl | internalurl | adminurl | +----------------------------------+-----------+-----------------------------------------------+-----------------------------------------------+--------------------------------------+ | 580b71d126804c5197b91c79fd74a330 | RegionOne | http://keystone:5000/v2.0 | http://keystone:5000/v2.0 | http://keystone:35357/v2.0 | | 5ef55e38e5c54477bd659d4185d0a776 | RegionOne | http://glance:9292/v2 | http://glance:9292/v2 | http://glance:9292/v2 | | 6c788747593d475f831b6ff128bde995 | RegionOne | http://cinder:8776/v1/$(tenant_id)s | http://cinder:8776/v1/$(tenant_id)s | http://cinder:8776/v1/$(tenant_id)s | | 95e16e71a8f04ac68ae401df5284ce3e | RegionOne | http://swift-proxy:8080/v1/AUTH_$(tenant_id)s | http://swift-proxy:8080/v1/AUTH_$(tenant_id)s | http://swift-proxy:8080/v1 | | c9659fab79454ee38bd926a2b78fa351 | RegionOne | http://nova:8774/v2/$(tenant_id)s | http://nova:8774/v2/$(tenant_id)s | http://nova:8774/v2/$(tenant_id)s | +----------------------------------+-----------+-----------------------------------------------+-----------------------------------------------+--------------------------------------+
CEPH Installation
Optional, 如果 Cinder 的設定是 LVM 就不必安裝這個, 想要看深入一點介紹的可以看這個連結http://www.sebastien-han.fr/blog/2012/06/10/introducing-ceph-to-openstack/
root@nova:~$ wget -q -O - https://raw.github.com/ceph/ceph/master/keys/release.asc | apt-key add - OK # 手動增加一個 ceph.list 在 /etc/apt/sources.list.d 下 root@nova:/etc/apt/sources.list.d$ cat ceph.list deb http://ceph.newdream.net/debian/ precise main deb-src http://ceph.newdream.net/debian/ precise main root@nova:~$ apt-get update root@nova:~$ apt-get install -y ceph python-ceph root@nova:~$ dpkg -l | grep ceph ii ceph 0.48.2argonaut-1precise distributed storage and file system ii ceph-common 0.48.2argonaut-1precise common utilities to mount and interact with a ceph storage cluster ii ceph-fs-common 0.48.2argonaut-1precise common utilities to mount and interact with a ceph file system ii ceph-fuse 0.48.2argonaut-1precise FUSE-based client for the Ceph distributed file system ii ceph-mds 0.48.2argonaut-1precise metadata server for the ceph distributed file system ii libcephfs1 0.48.2argonaut-1precise Ceph distributed file system client library ii python-ceph 0.48.2argonaut-1precise Python libraries for the Ceph distributed filesystem # 安裝好之後, 就把你的 ceph cluster 的設定檔 copy 到 /etc/ceph 下, 正常就可以使用 # 至於怎麼安裝 ceph cluster 就請到 ceph 的官網去看囉~ root@nova:~$ ceph -s health HEALTH_OK monmap e1: 3 mons at {wistor-003=172.17.123.92:6789/0,wistor-006=172.17.123.94:6789/0,wistor-007=172.17.123.95:6789/0}, election epoch 10, quorum 0,1,2 wistor-003,wistor-006,wistor-007 osdmap e24: 23 osds: 23 up, 23 in pgmap v2242: 4416 pgs: 4416 active+clean; 8362 MB data, 156 GB used, 19850 GB / 21077 GB avail mdsmap e1: 0/0/1 up
Nova Installation
Nova Package
因為是要和 Cinder 整合, 所以沒有安裝 nova-volumeroot@nova:~$ apt-get install nova-compute nova-api nova-ajax-console-proxy nova-cert nova-consoleauth nova-doc nova-scheduler nova-network nova-novncproxy novnc python-novnc root@nova:~$ ii nova-ajax-console-proxy 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - AJAX console proxy - transitional package ii nova-api 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - API frontend ii nova-cert 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - certificate management ii nova-common 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - common files ii nova-compute 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - compute node ii nova-compute-kvm 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - compute node (KVM) ii nova-consoleauth 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - Console Authenticator ii nova-doc 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - documentation ii nova-network 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - Network manager ii nova-novncproxy 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - NoVNC proxy ii nova-scheduler 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute - virtual machine scheduler ii novnc 2012.2~20120906+dfsg-0ubuntu2~precise HTML5 VNC client ii python-nova 2012.2+git201210091907~precise-0ubuntu1 OpenStack Compute Python libraries ii python-novaclient 1:2.9.0.10+git201210101300~precise-0ubuntu1 client library for OpenStack Compute API ii python-novnc 2012.2~20120906+dfsg-0ubuntu2~precise HTML5 VNC client - libraries
/etc/nova/nova.conf
內容是設定成和 Keystone, Cinder(Ceph), Glance(Ceph), 整合在一起, 中間其實用不到 iscsi server.[DEFAULT] root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf ec2_private_dns_show_ip=True # LOGS/STATE verbose=True logdir=/var/log/nova state_path=/var/lib/nova lock_path=/var/lock/nova # AUTHENTICATION auth_strategy=keystone keystone_ec2_url=http://keystone:5000/v2.0/ec2tokens # VOLUMES #volume_driver=nova.volume.driver.ISCSIDriver #volume_group=nova-volumes #volume_name_template=volume-%08x #iscsi_helper=tgtadm volume_driver=nova.volume.driver.RBDDriver volume_api_class=nova.volume.cinder.API volumes_path=/var/lib/nova/volumes # DATABASE sql_connection=mysql://nova:password@mysql/nova # COMPUTE libvirt_type=kvm compute_driver=libvirt.LibvirtDriver instance_name_template=instance-%08x api_paste_config=/etc/nova/api-paste.ini libvirt_use_virtio_for_bridges=True # RABBITMQ rabbit_host=rabbitmq rabbit_password=password # GLANCE image_service=nova.image.glance.GlanceImageService glance_api_servers=glance:9292 # NETWORK network_manager=nova.network.manager.FlatDHCPManager force_dhcp_release=True dhcpbridge_flagfile=/etc/nova/nova.conf dhcpbridge=/usr/bin/nova-dhcpbridge my_ip=172.17.123.17 public_interface=br100 vlan_interface=eth0 flat_network_bridge=br100 flat_interface=eth0 fixed_range=192.168.100.0/27 # NOVNC CONSOLE novnc_enable=true novncproxy_base_url=http://172.17.123.17:6080/vnc_auto.html vncserver_proxyclient_address=127.0.0.1 vncserver_listen=0.0.0.0
/etc/nova/api.paste.ini
要設定 keystone 的相關資訊... [filter:authtoken] paste.filter_factory = keystone.middleware.auth_token:filter_factory auth_host = keystone auth_port = 35357 auth_protocol = http #admin_tenant_name = %SERVICE_TENANT_NAME% #admin_user = %SERVICE_USER% #admin_password = %SERVICE_PASSWORD% admin_tenant_name = service admin_user = nova admin_password = password signing_dirname = /tmp/keystone-signing-nova
/etc/nova/nova_restart.sh
另外準備一個 nova_restart.sh, 方便等下使用#!/bin/bash for a in nova-network nova-compute nova-api nova-scheduler; do sudo service $a stop; done for a in nova-consoleauth nova-cert novnc libvirt-bin; do sudo service $a stop; done for a in nova-network nova-compute nova-api nova-scheduler; do sudo service $a start; done for a in nova-consoleauth nova-cert novnc libvirt-bin; do sudo service $a start; done
啟動 nova 之後, 要記得成生成 database, 完成後就可以把服務啟動
root@nova:~$ chown -R nova:nova * root@nova:~$ nova-manage db sync root@nova:~$ /etc/nova/nova_restart.sh root@nova:~$ nova-manage service list Binary Host Zone Status State Updated_At nova-cert nova nova enabled :-) 2012-10-09 02:38:29 nova-scheduler nova nova enabled :-) 2012-10-09 02:38:29 nova-consoleauth nova nova enabled :-) 2012-10-09 02:38:29 nova-compute nova nova enabled :-) 2012-10-09 02:38:31 nova-network nova nova enabled :-) 2012-10-09 02:38:30 root@nova:~$ ps aux | grep nova | grep python nova 3611 0.3 0.7 209044 58800 ? S 15:05 0:07 /usr/bin/python /usr/bin/nova-network --config-file=/etc/nova/nova.conf nova 3623 0.4 0.8 1367636 67448 ? Sl 15:05 0:10 /usr/bin/python /usr/bin/nova-compute --config-file=/etc/nova/nova.conf --config-file=/etc/nova/nova-compute.conf nova 3634 0.0 0.7 136864 58780 ? S 15:05 0:01 /usr/bin/python /usr/bin/nova-api --config-file=/etc/nova/nova.conf nova 3645 0.2 0.7 276524 61796 ? S 15:05 0:05 /usr/bin/python /usr/bin/nova-scheduler --config-file=/etc/nova/nova.conf nova 3656 0.2 0.6 202344 52512 ? S 15:05 0:04 /usr/bin/python /usr/bin/nova-consoleauth --config-file=/etc/nova/nova.conf nova 3667 0.2 0.6 202216 52248 ? S 15:05 0:05 /usr/bin/python /usr/bin/nova-cert --config-file=/etc/nova/nova.conf nova 3755 0.0 0.2 95772 22824 ? S 15:05 0:00 /usr/bin/python /usr/bin/nova-api --config-file=/etc/nova/nova.conf nova 4164 0.0 0.9 250300 79596 ? S 15:05 0:01 /usr/bin/python /usr/bin/nova-api --config-file=/etc/nova/nova.conf nova 4171 0.0 0.6 135852 54420 ? S 15:05 0:00 /usr/bin/python /usr/bin/nova-api --config-file=/etc/nova/nova.conf nova 4173 0.0 0.6 137112 55960 ? S 15:05 0:00 /usr/bin/python /usr/bin/nova-api --config-file=/etc/nova/nova.conf nova 7092 0.0 0.2 122972 24216 ? S 15:13 0:00 /usr/bin/python /usr/bin/nova-novncproxy --config-file=/etc/nova/nova.conf nova 7137 0.0 0.3 137492 25832 ? S 15:13 0:00 /usr/bin/python /usr/bin/nova-novncproxy --config-file=/etc/nova/nova.conf
Test and Verification
驗証一下和所有的 component 是否正確連結, 首先驗証一下 Cinderroot@nova:~$ nova volume-create --display-name test 1 +---------------------+--------------------------------------+ | Property | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | created_at | 2012-10-09T08:35:06.518633 | | display_description | None | | display_name | test | | id | 728832a1-32d8-44f3-ba1a-8944adbeca11 | | metadata | {} | | size | 1 | | snapshot_id | None | | status | creating | | volume_type | None | +---------------------+--------------------------------------+ root@nova:~$ nova volume-list +--------------------------------------+-----------+--------------+------+-------------+-------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +--------------------------------------+-----------+--------------+------+-------------+-------------+ | 728832a1-32d8-44f3-ba1a-8944adbeca11 | available | test | 1 | None | | +--------------------------------------+-----------+--------------+------+-------------+-------------+ root@nova:~$ cinder list +--------------------------------------+-----------+--------------+------+-------------+-------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +--------------------------------------+-----------+--------------+------+-------------+-------------+ | 728832a1-32d8-44f3-ba1a-8944adbeca11 | available | test | 1 | None | | +--------------------------------------+-----------+--------------+------+-------------+-------------+ root@nova:~$ nova volume-delete test
再來驗証一下和 Glance 的連結是否正確
root@nova:~$ nova image-list +--------------------------------------+---------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------------------+--------+--------+ | fdc49609-6047-426c-a382-75928c0deb17 | Ubuntu-Precise | ACTIVE | | | ad46b050-a03e-4d31-bc60-84f81806853b | tty-linux | ACTIVE | | | e504fcf2-fdbd-4d15-be1c-49e24dd28458 | tty-linux-kernel | ACTIVE | | | 5897d530-b625-4b7c-91eb-56313cf2741c | tty-linux-ramdisk | ACTIVE | | +--------------------------------------+---------------------+--------+--------+ root@nova:~$ wget -c https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img -O stackimages/cirros.img root@nova:~$ glance add name=cirros-0.3.0-x86_64 disk_format=qcow2 container_format=bare < cirros.img Added new image with ID: 1e4a8f0c-235f-46ce-9aef-fc7fa143f141 root@nova:~$ glance image-list +--------------------------------------+---------------------+-------------+------------------+-----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+---------------------+-------------+------------------+-----------+--------+ | 1e4a8f0c-235f-46ce-9aef-fc7fa143f141 | cirros-0.3.0-x86_64 | qcow2 | bare | 9761280 | active | | 5897d530-b625-4b7c-91eb-56313cf2741c | tty-linux-ramdisk | ari | ari | 96629 | active | | ad46b050-a03e-4d31-bc60-84f81806853b | tty-linux | ami | ami | 25165824 | active | | e504fcf2-fdbd-4d15-be1c-49e24dd28458 | tty-linux-kernel | aki | aki | 4404752 | active | | fdc49609-6047-426c-a382-75928c0deb17 | Ubuntu-Precise | qcow2 | ovf | 232718336 | active | +--------------------------------------+---------------------+-------------+------------------+-----------+--------+ root@nova:~$ nova image-list +--------------------------------------+---------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------------------+--------+--------+ | fdc49609-6047-426c-a382-75928c0deb17 | Ubuntu-Precise | ACTIVE | | | 1e4a8f0c-235f-46ce-9aef-fc7fa143f141 | cirros-0.3.0-x86_64 | ACTIVE | | | ad46b050-a03e-4d31-bc60-84f81806853b | tty-linux | ACTIVE | | | e504fcf2-fdbd-4d15-be1c-49e24dd28458 | tty-linux-kernel | ACTIVE | | | 5897d530-b625-4b7c-91eb-56313cf2741c | tty-linux-ramdisk | ACTIVE | | +--------------------------------------+---------------------+--------+--------+
Network Creation
要先成兩個網段, 一個是對內的 private ip, 一個是對外的floating iproot@nova:~$ nova-manage network create private --multi_host=T --fixed_range_v4=192.168.100.0/27 --bridge=br100 --bridge_interface=eth0 --num_networks=1 --network_size=32 root@nova:~$ nova-manage floating create --ip_range=172.17.123.192/28 root@nova:~$ nova network-list +--------------------------------------+---------+------------------+ | ID | Label | Cidr | +--------------------------------------+---------+------------------+ | 471a3258-1f30-458d-8476-262521597fbf | private | 192.168.100.0/27 | +--------------------------------------+---------+------------------+ root@nova:~$ 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 | | +-------------+-----------+---------+-----------+--------------+ root@nova:~$ 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 | | +-------------+-----------+---------+-----------+--------------+
Add Keypair
root@nova:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 8b:12:db:df:24:9e:31:05:da:8d:ed:7e:37:46:5f:9b root@nova The key's randomart image is: +--[ RSA 2048]----+ | | | | | . | | o = | | . . S + | | + . + . .| | o o = o . .+| | . o O . +E.| | + o. o . | +-----------------+ root@nova:~$ nova keypair-add --pub_key ~/.ssh/id_rsa.pub mykey root@nova:~$ nova keypair-list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 8b:12:db:df:24:9e:31:05:da:8d:ed:7e:37:46:5f:9b | +-------+-------------------------------------------------+
Boot a Virtual Machine
我們用 cirros-0.3.0-x86_64 來測試是否能成功新增一個 Virtual Machineroot@nova:~$ nova flavor-list +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | 1 | m1.tiny | 512 | 0 | 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 | {} | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ root@nova:~$ nova boot --flavor 1 --image 1e4a8f0c-235f-46ce-9aef-fc7fa143f141 --key_name mykey --security_group default vm1 +-------------------------------------+----------------------------------------------------------+ | Property | Value | +-------------------------------------+----------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-SRV-ATTR:host | nova | | OS-EXT-SRV-ATTR:hypervisor_hostname | nova | | OS-EXT-SRV-ATTR:instance_name | instance-00000004 | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | accessIPv4 | | | accessIPv6 | | | adminPass | qmmhTYWn5N8K | | config_drive | | | created | 2012-10-09T08:06:53Z | | flavor | m1.tiny | | hostId | 09574c18e8c0a491179c061b91f64d31726f3d0c19ea4cee36ee0cc7 | | id | 5c983f6f-9d94-4f97-a6fb-1bf4a3aaa487 | | image | cirros-0.3.0-x86_64 | | key_name | mykey | | metadata | {} | | name | vm1 | | progress | 0 | | security_groups | [{u'name': u'default'}] | | status | BUILD | | tenant_id | eefa301a6a424e7da3d582649ad0e59e | | updated | 2012-10-09T08:06:54Z | | user_id | fafd0583de8a4a1b93b924a6b2cb7eb5 | +-------------------------------------+----------------------------------------------------------+ root@nova:~$ nova list +--------------------------------------+------+--------+-----------------------+ | ID | Name | Status | Networks | +--------------------------------------+------+--------+-----------------------+ | 5c983f6f-9d94-4f97-a6fb-1bf4a3aaa487 | vm1 | ACTIVE | private=192.168.100.2 | +--------------------------------------+------+--------+-----------------------+ # 網路有正確的接到 br100 root@nova:~$ brctl show bridge name bridge id STP enabled interfaces br100 8000.00505682d12a no eth0 virbr0 8000.000000000000 yes # libvirt 內也有看到這個 VM root@nova:~$ virsh list Id Name State ---------------------------------- 2 instance-00000004 running # 可以透過 vnc 去看 root@nova:~$ virsh vncdisplay 2 :0 # ssh 也沒問題 root@nova:~$ ssh cirros@192.168.100.2 The authenticity of host '192.168.100.2 (192.168.100.2)' can't be established. RSA key fingerprint is 36:4c:6f:9c:40:a7:9f:07:13:6a:28:67:e2:1d:08:1c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.100.2' (RSA) to the list of known hosts. # 連外也沒問題 $ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: seq=0 ttl=52 time=10.089 ms 64 bytes from 8.8.8.8: seq=1 ttl=52 time=8.558 ms 64 bytes from 8.8.8.8: seq=2 ttl=52 time=11.982 ms 64 bytes from 8.8.8.8: seq=3 ttl=52 time=11.889 ms # 驗証完後就砍掉吧! root@nova:~$ nova delete 5c983f6f-9d94-4f97-a6fb-1bf4a3aaa487
Attach Volume
這裡我要測試透過 Cinder 產生的 volume 是否能 attach 到 vm 上root@nova:~$ nova list +--------------------------------------+------+--------+-----------------------+ | ID | Name | Status | Networks | +--------------------------------------+------+--------+-----------------------+ | 321b2521-b144-4ec4-88ac-1916ae9d8427 | vm1 | ACTIVE | private=192.168.100.2 | +--------------------------------------+------+--------+-----------------------+ root@nova:~$ nova volume-list +--------------------------------------+-----------+--------------+------+-------------+-------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +--------------------------------------+-----------+--------------+------+-------------+-------------+ | 6051f6a4-c507-4d39-91f7-be7214b8d326 | available | test | 30 | None | | +--------------------------------------+-----------+--------------+------+-------------+-------------+ root@nova:~$ nova volume-attach 321b2521-b144-4ec4-88ac-1916ae9d8427 6051f6a4-c507-4d39-91f7-be7214b8d326 auto +----------+--------------------------------------+ | Property | Value | +----------+--------------------------------------+ | device | /dev/vdb | | id | 6051f6a4-c507-4d39-91f7-be7214b8d326 | | serverId | 321b2521-b144-4ec4-88ac-1916ae9d8427 | | volumeId | 6051f6a4-c507-4d39-91f7-be7214b8d326 | +----------+--------------------------------------+ root@nova:~$ nova volume-list +--------------------------------------+--------+--------------+------+-------------+--------------------------------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +--------------------------------------+--------+--------------+------+-------------+--------------------------------------+ | 6051f6a4-c507-4d39-91f7-be7214b8d326 | in-use | test | 30 | None | 321b2521-b144-4ec4-88ac-1916ae9d8427 | +--------------------------------------+--------+--------------+------+-------------+--------------------------------------+ root@nova:~$ virsh list Id Name State ---------------------------------- 4 instance-00000006 running root@nova:~$ virsh domblklist instance-00000006 Target Source ------------------------------------------------ vda /var/lib/nova/instances/instance-00000006/disk vdb rbd/volume-6051f6a4-c507-4d39-91f7-be7214b8d326. root@nova:~$ ssh cirros@192.168.100.2 $ sudo fdisk -l Disk /dev/vda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vda1 * 16065 83875364 41929650 83 Linux Disk /dev/vdb: 32.2 GB, 32212254720 bytes 16 heads, 63 sectors/track, 62415 cylinders, total 62914560 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/vdb doesn't contain a valid partition table看起來是成功了, 再多看一下這個 VM 的 xml 設定, 透過以下這個指令 virsh dumpxml instance-00000006 可以看到他新增了一個 disk, 是透過 rbd protocol
... <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/var/lib/nova/instances/instance-00000006/disk'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source protocol='rbd' name='rbd/volume-6051f6a4-c507-4d39-91f7-be7214b8d326'/> <target dev='vdb' bus='virtio'/> <serial>6051f6a4-c507-4d39-91f7-be7214b8d326 <alias name='virtio-disk1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </disk> ...
Create Ubuntu(Precise) Virtual Machine
Ubuntu 的 image 可以到這邊下載http://uec-images.ubuntu.com/precise/current/
裡面分成兩種, 一種是把 kernel image & machine image 分開的, 另一種則是用 qcow2 包起來
拆開的: precise-server-cloudimg-amd64-root.tar.gz
包起來的: precise-server-cloudimg-amd64-disk1.img
在 Openstack Folsom - Installation of Glance with Ceph 內有紀錄怎麼第二種的上傳方式, 至於第一種就要解壓縮後, 分別上傳 aki & ami, 然後連結起來. 這邊假設已經上傳好了
root@nova:~$ nova image-list +--------------------------------------+---------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------------------+--------+--------+ | fdc49609-6047-426c-a382-75928c0deb17 | Ubuntu-Precise | ACTIVE | | | 1e4a8f0c-235f-46ce-9aef-fc7fa143f141 | cirros-0.3.0-x86_64 | ACTIVE | | | ad46b050-a03e-4d31-bc60-84f81806853b | tty-linux | ACTIVE | | | e504fcf2-fdbd-4d15-be1c-49e24dd28458 | tty-linux-kernel | ACTIVE | | | 5897d530-b625-4b7c-91eb-56313cf2741c | tty-linux-ramdisk | ACTIVE | | +--------------------------------------+---------------------+--------+--------+ root@nova:~$ nova boot --flavor 2 --image Ubuntu-Precise --key_name mykey --security_group default vm +-------------------------------------+----------------------------------------------------------+ | Property | Value | +-------------------------------------+----------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-SRV-ATTR:host | nova | | OS-EXT-SRV-ATTR:hypervisor_hostname | nova | | OS-EXT-SRV-ATTR:instance_name | instance-0000000c | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | accessIPv4 | | | accessIPv6 | | | adminPass | 5q4sWjHENyvP | | config_drive | | | created | 2012-10-10T02:52:40Z | | flavor | m1.small | | hostId | 09574c18e8c0a491179c061b91f64d31726f3d0c19ea4cee36ee0cc7 | | id | 019e2db9-cabe-4711-9b95-ceaefd97f22e | | image | Ubuntu-Precise | | key_name | mykey | | metadata | {} | | name | vm | | progress | 0 | | security_groups | [{u'name': u'default'}] | | status | BUILD | | tenant_id | eefa301a6a424e7da3d582649ad0e59e | | updated | 2012-10-10T02:52:40Z | | user_id | fafd0583de8a4a1b93b924a6b2cb7eb5 | +-------------------------------------+----------------------------------------------------------+ root@nova:~$ nova list +--------------------------------------+------+--------+-----------------------+ | ID | Name | Status | Networks | +--------------------------------------+------+--------+-----------------------+ | 019e2db9-cabe-4711-9b95-ceaefd97f22e | vm | ACTIVE | private=192.168.100.4 | +--------------------------------------+------+--------+-----------------------+ root@nova:~$ ssh ubuntu@192.168.100.4 Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-31-virtual x86_64) * Documentation: https://help.ubuntu.com/ System information as of Wed Oct 10 03:17:49 UTC 2012 System load: 0.0 Processes: 60 Usage of /: 3.3% of 19.67GB Users logged in: 0 Memory usage: 2% IP address for eth0: 192.168.100.4 Swap usage: 0% Graph this data and manage this system at https://landscape.canonical.com/ 0 packages can be updated. 0 updates are security updates. Get cloud support with Ubuntu Advantage Cloud Guest http://www.ubuntu.com/business/services/cloud Last login: Wed Oct 10 02:55:30 2012 from 192.168.100.3 To run a command as administrator (user "root"), use "sudo". See "man sudo_root" for details. ubuntu@vm:~$ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_req=1 ttl=52 time=9.96 ms 64 bytes from 8.8.8.8: icmp_req=2 ttl=52 time=7.63 ms 64 bytes from 8.8.8.8: icmp_req=3 ttl=52 time=5.18 ms
註
註1:
在執行 nova 指令時, 會不斷的叫你輸入 keyring 的 password, 目前也有人把他提報成一個 bug.https://bugs.launchpad.net/python-novaclient/+bug/1020238
http://wiki.openstack.org/KeyringSupport
如果不想要一直輸入 password, 可以在 .bashrc 內加上一行
alias nova='nova --no-cache'
註2:
在裝完 horizon 之後, 發現 vnc 起不來, 才發現 vncproxy 啟動失敗在 /var/log/upstart/nova-novncproxy.log 內
Traceback (most recent call last): File "/usr/bin/nova-novncproxy", line 29, in在網路上找了一下發現是 known issue, 只需要去下載最新的 package, 就會解掉這個問題import websockify
https://bugs.launchpad.net/ubuntu/+source/websockify/+bug/1060374
root@nova:~$ wget https://launchpad.net/ubuntu/+archive/primary/+files/websockify_0.2~20121002-0ubuntu1_amd64.deb root@nova:~$ dpkg -i websockify_0.2~20121002-0ubuntu1_amd64.deb root@nova:~$ ./nova_restart.sh
2 則留言:
您好可否請教您是否有試過floating IP也就是外部的IP是抓取區網的DHCP server分配的IP而不是nova自己分配的IP? 謝謝~~
有試過類似的, 但遇過 DHCP server 發了 ip, 但 VM 卻收不到的狀況, 後來沒有再追這個問題, 因為都從 nova 內部設定 DHCP server. 你可以試試去 forum 問問看.
張貼留言