您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么在Ubuntu16單節點上安裝OpenStack”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么在Ubuntu16單節點上安裝OpenStack”吧!
參考文檔:
“OpenStack Installation Tutorial for Ubuntu”
配置IP地址:
ipaddr : 192.168.195.160 netmask : 255.255.255.0 gateway : 192.168.195.2 dns : 114.114.114.114
配置主機名:
$ vi /etc/hostname UbuntuStack
配置本機DNS解析:
$ vi /etc/hosts 127.0.0.1 ubuntustack
配置網卡:
$ vi /etc/network/interfaces # The provider network interface auto ens33 iface ens33 inet manual up ip link set dev $IFACE up down ip link set dev $IFACE down
安裝chrony服務:
$ apt-get install chrony
配置NTP服務器地址,這里選擇NTP在亞洲的服務器,且允許所有“192.168/16”網段從這里獲取NTP服務。
$ vi /etc/chrony/chrony.conf server 0.asia.pool.ntp.org iburst server 1.asia.pool.ntp.org iburst server 2.asia.pool.ntp.org iburst allow 192.168/16
重啟chrony服務:
$ service chrony restart
驗證NTP服務,帶有“*”的說明最近進行過同步。
$ chronyc sources 210 Number of sources = 10 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^- 27.114.150.12 2 6 35 9 +104ms[ +104ms] +/- 336ms ^- x.ns.gin.ntt.net 2 6 33 8 -44ms[ -44ms] +/- 209ms ^- ntp.tums.ac.ir 3 6 123 3 +577us[ +577us] +/- 410ms ^- 120.25.115.19 2 6 17 14 +2132us[+2132us] +/- 74ms ^- 59.46.44.253 2 6 33 11 +734us[ +734us] +/- 78ms ^* news.neu.edu.cn 2 6 17 14 +647us[+4083us] +/- 21ms ^? 2001:da8:9000::130 0 6 0 10y +0ns[ +0ns] +/- 0ns ^? 2400:a480:f:420:d2::bd 0 6 0 10y +0ns[ +0ns] +/- 0ns ^? 2001:da8:9000::81 0 6 0 10y +0ns[ +0ns] +/- 0ns ^? 2001:da8:202:10::61 0 6 0 10y +0ns[ +0ns] +/- 0ns
$ apt-get install software-properties-common $ add-apt-repository cloud-archive:newton $ apt-get update && apt dist-upgrade $ apt-get install python-openstackclient
安裝MariaDB軟件包:
$ apt install mariadb-server python-pymysql
配置MariaDB參數:
$ vi /etc/mysql/mariadb.conf.d/99-openstack.cnf [mysqld] bind-address = 192.168.195.160 default-storage-engine = innodb innodb_file_per_table max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8
重啟MariaDB:
$ service mysql restart
配置數據庫:
$ mysql_secure_installation Enter current password for root (enter for none): > <enter> Set root password? [Y/n] > y New password: > openstack Re-enter new password: > openstack Remove anonymous users? [Y/n] > n Disallow root login remotely? [Y/n] > n Remove test database and access to it? [Y/n] > n Reload privilege tables now? [Y/n] > y
驗證數據庫服務:
$ mysql -uroot -p Enter password: > openstack > quit
安裝RabbitMQ:
$ apt install rabbitmq-server
配置用戶名和密碼:
$ rabbitmqctl add_user openstack openstack Creating user "openstack" ... $ rabbitmqctl set_permissions openstack ".*" ".*" ".*" Setting permissions for user "openstack" in vhost "/" ...
安裝Memcached軟件包:
$ apt install memcached python-memcache
基本配置:
$ vi /etc/memcached.conf -l 192.168.195.160
重啟服務:
$ service memcached restart
創建KeyStore數據庫:
$ mysql -u root -p > openstack > CREATE DATABASE keystone; > GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'openstack'; > quit
配置數據庫URL:
$ vi /etc/keystone/keystone.conf ... [database] ... connection = mysql+pymysql://keystone:openstack@ubuntustack/keystone ...
配置Fernet Key倉庫Token:
$ vi /etc/keystone/keystone.conf ... [token] ... provider = fernet ...
同步數據庫:
$ su -s /bin/sh -c "keystone-manage db_sync" keystone
$ keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone $ keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
初始化KeyStore服務:
$ keystone-manage bootstrap --bootstrap-password openstack \ --bootstrap-admin-url http://ubuntustack:35357/v3/ \ --bootstrap-internal-url http://ubuntustack:35357/v3/ \ --bootstrap-public-url http://ubuntustack:5000/v3/ \ --bootstrap-region-id RegionOne
配置Apache2服務名:
$ vi /etc/apache2/apache2.conf ... ServerName ubuntustack ...
重啟Apache2服務:
$ service apache2 restart $ rm -fv /var/lib/keystone/keystone.db
設置管理員環境變量:
$ export OS_USERNAME=admin $ export OS_PASSWORD=openstack $ export OS_PROJECT_NAME=admin $ export OS_USER_DOMAIN_NAME=default $ export OS_PROJECT_DOMAIN_NAME=default $ export OS_AUTH_URL=http://ubuntustack:35357/v3 $ export OS_IDENTITY_API_VERSION=3
創建Project:
$ openstack project create --domain default \ --description "Service Project" service +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Service Project | | domain_id | default | | enabled | True | | id | 2493d51774e64be1ae97041768b73d98 | | is_domain | False | | name | service | | parent_id | default | +-------------+----------------------------------+ $ openstack project create --domain default \ --description "Demo Project" demo +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Demo Project | | domain_id | default | | enabled | True | | id | c7ddc0ecab64419486df0d7f66e8174c | | is_domain | False | | name | demo | | parent_id | default | +-------------+----------------------------------+
創建User:
$ openstack user create --domain default \ --password-prompt demo User Password: > openstack Repeat User Password: > openstack +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | ffff52bbf1da4c86a3d2b57e977f6b82 | | name | demo | | password_expires_at | None | +---------------------+----------------------------------+
創建Role:
$ openstack role create user +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | None | | id | 314d4ba677ef4f6d92c53f00e470be1b | | name | user | +-----------+----------------------------------+
為Project添加Role:
$ openstack role add --project demo --user demo user
編輯“/etc/keystone/keystone-paste.ini”文件,從“[pipeline:public_api]”,“[pipeline:admin_api]”和“[pipeline:api_v3]”小節中移除“admin_token_auth”。
取消“OS_AUTH_URL”和“OS_PASSWORD”環境變量設置:
$ unset OS_AUTH_URL OS_PASSWORD
請求一個admin認證Token:
$ openstack --os-auth-url http://ubuntustack:35357/v3 \ --os-project-domain-name default --os-user-domain-name default \ --os-project-name admin --os-username admin token issue Password: > openstack +------------+----------------------------------+ | Field | Value | +------------+----------------------------------+ | expires | 2016-11-28 09:55:28+00:00 | | id | ab3f069806b24fd29869eac1d6ccbbc8 | | project_id | c77f9d27e4f5496092357ff991d1639b | | user_id | 5524cbf52bf440deb5e3e8ccd074a267 | +------------+----------------------------------+
請求一個demo認證Token:
$ openstack --os-auth-url http://ubuntustack:5000/v3 \ --os-project-domain-name default --os-user-domain-name default \ --os-project-name demo --os-username demo token issue Password: > openstack +------------+----------------------------------+ | Field | Value | +------------+----------------------------------+ | expires | 2016-11-28 09:56:25+00:00 | | id | 628a27e1ae1847ea968186122d158ee6 | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | user_id | ffff52bbf1da4c86a3d2b57e977f6b82 | +------------+----------------------------------+
創建admin用戶環境變量腳本:
$ vi admin-openrc export OS_PROJECT_DOMAIN_NAME=default export OS_USER_DOMAIN_NAME=default export OS_PROJECT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=http://ubuntustack:35357/v3 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2
創建demo用戶環境變量腳本:
$ vi demo-openrc export OS_PROJECT_DOMAIN_NAME=default export OS_USER_DOMAIN_NAME=default export OS_PROJECT_NAME=demo export OS_USERNAME=demo export OS_PASSWORD=openstack export OS_AUTH_URL=http://ubuntustack:5000/v3 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2
驗證admin用戶環境變量腳本:
$ . admin-openrc $ openstack token issue +------------+----------------------------------+ | Field | Value | +------------+----------------------------------+ | expires | 2016-11-28 09:59:18+00:00 | | id | 5192190f959545288ed4095b7cc2af1f | | project_id | c77f9d27e4f5496092357ff991d1639b | | user_id | 5524cbf52bf440deb5e3e8ccd074a267 | +------------+----------------------------------+
創建Glance數據庫:
$ mysql -u root -p > openstack > CREATE DATABASE glance; > GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'openstack'; > quit
設置admin環境變量:
$ . admin-openrc
創建Glance用戶:
$ openstack user create --domain default --password-prompt glance User Password: > openstack Repeat User Password: > openstack +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 0333d28a75824b81a73d9c99ed0d6a09 | | name | glance | | password_expires_at | None | +---------------------+----------------------------------+
把Glance用戶添加進服務的管理員角色:
$ openstack role add --project service --user glance admin
創建Glance服務:
$ openstack service create --name glance \ --description "OpenStack Image" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 64e1b1473cba4c3395c1aef20ae1b5d9 | | name | glance | | type | image | +-------------+----------------------------------+
創建Glance服務的公共EndPoint:
$ openstack endpoint create --region RegionOne image public http://ubuntustack:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 6ba33ab89e2b4d8bb4c8583add6aaeee | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 64e1b1473cba4c3395c1aef20ae1b5d9 | | service_name | glance | | service_type | image | | url | http://ubuntustack:9292 | +--------------+----------------------------------+
創建Glance服務的內部EndPoint:
$ openstack endpoint create --region RegionOne image internal http://ubuntustack:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 2bbde57b9ddb4ae78ed825258c1b1e5e | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 64e1b1473cba4c3395c1aef20ae1b5d9 | | service_name | glance | | service_type | image | | url | http://ubuntustack:9292 | +--------------+----------------------------------+
創建Glance服務的管理EndPoint:
$ openstack endpoint create --region RegionOne image admin http://ubuntustack:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | b09eb627b221453e8ffdd99d7df7e67a | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 64e1b1473cba4c3395c1aef20ae1b5d9 | | service_name | glance | | service_type | image | | url | http://ubuntustack:9292 | +--------------+----------------------------------+
安裝Glance軟件包
$ apt-get install glance
配置Glance API服務:
$ vi /etc/glance/glance-api.conf [database] ... connection = mysql+pymysql://glance:openstack@ubuntustack/glance [keystone_authtoken] ... auth_uri = http://ubuntustack:5000 auth_url = http://ubuntustack:35357 memcached_servers = ubuntustack:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = openstack [paste_deploy] ... flavor = keystone [glance_store] ... stores = file,http default_store = file filesystem_store_datadir = /opt/stack/images/
配置Glance Registery服務:
$ vi /etc/glance/glance-registry.conf [database] ... connection = mysql+pymysql://glance:openstack@ubuntustack/glance [keystone_authtoken] ... auth_uri = http://ubuntustack:5000 auth_url = http://ubuntustack:35357 memcached_servers = ubuntustack:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = openstack [paste_deploy] ... flavor = keystone
同步Glance數據庫:
$ su -s /bin/sh -c "glance-manage db_sync" glance
創建鏡像保存目錄:
$ mkdir -pv /opt/stack/images $ chown glance:glance /opt/stack/images $ chmod 744 /opt/stack/images
重啟Glance服務:
$ service glance-registry restart $ service glance-api restart
設置管理員環境變量:
$ . admin-openrc
下載測試鏡像:
$ wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
添加測試鏡像到Glance倉庫:
$ openstack image create "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2016-11-28T21:14:49Z | | disk_format | qcow2 | | file | /v2/images/e345e8b0-71b7-44e0-b1a1-e168f85a19f6/file | | id | e345e8b0-71b7-44e0-b1a1-e168f85a19f6 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | c77f9d27e4f5496092357ff991d1639b | | protected | False | | schema | /v2/schemas/image | | size | 13287936 | | status | active | | tags | | | updated_at | 2016-11-28T21:14:49Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+
查看已加入的鏡像:
$ openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | e345e8b0-71b7-44e0-b1a1-e168f85a19f6 | cirros | active | +--------------------------------------+--------+--------+
創建Nova數據庫:
$ mysql -u root -p Enter password: > openstack > CREATE DATABASE nova_api; > GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'openstack'; > CREATE DATABASE nova; > GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'openstack'; > quit
設置管理員環境變量:
$ . admin-openrc
創建Nova用戶:
$ openstack user create --domain default --password-prompt nova User Password: > openstack Repeat User Password: > openstack +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | e69cc08aab424e32b890b25621eef471 | | name | nova | | password_expires_at | None | +---------------------+----------------------------------+
添加Nova用戶到服務的管理員角色:
$ openstack role add --project service --user nova admin
創建Nova服務:
$ openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 472934388a194c36a80295c267e5252f | | name | nova | | type | compute | +-------------+----------------------------------+
創建Nova服務的公共EndPoint:
$ openstack endpoint create --region RegionOne compute public http://ubuntustack:8774/v2.1/%\(tenant_id\)s +--------------+--------------------------------------------+ | Field | Value | +--------------+--------------------------------------------+ | enabled | True | | id | 74f5e21c114a48d68782a886ff6c4ca7 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 472934388a194c36a80295c267e5252f | | service_name | nova | | service_type | compute | | url | http://ubuntustack:8774/v2.1/%(tenant_id)s | +--------------+--------------------------------------------+
創建Nova服務的內部EndPoint:
$ openstack endpoint create --region RegionOne compute internal http://ubuntustack:8774/v2.1/%\(tenant_id\)s +--------------+--------------------------------------------+ | Field | Value | +--------------+--------------------------------------------+ | enabled | True | | id | 2cdc0c65e9e04136bf08e1ec913eaadb | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 472934388a194c36a80295c267e5252f | | service_name | nova | | service_type | compute | | url | http://ubuntustack:8774/v2.1/%(tenant_id)s | +--------------+--------------------------------------------+
創建Nova服務的管理EndPoint:
$ openstack endpoint create --region RegionOne compute admin http://ubuntustack:8774/v2.1/%\(tenant_id\)s +--------------+--------------------------------------------+ | Field | Value | +--------------+--------------------------------------------+ | enabled | True | | id | 47ace5dab56940cbbac20b43abedadb9 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 472934388a194c36a80295c267e5252f | | service_name | nova | | service_type | compute | | url | http://ubuntustack:8774/v2.1/%(tenant_id)s | +--------------+--------------------------------------------+
安裝Nova軟件包:
$ apt-get install nova-api nova-conductor nova-consoleauth nova-novncproxy nova-scheduler nova-compute
配置Nova服務:
$ vi /etc/nova/nova.conf [DEFAULT] ... transport_url = rabbit://openstack:openstack@ubuntustack auth_strategy = keystone my_ip = 192.168.195.160 use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver [api_database] ... connection = mysql+pymysql://nova:openstack@ubuntustack/nova_api [database] ... connection = mysql+pymysql://nova:openstack@ubuntustack/nova [keystone_authtoken] ... auth_uri = http://ubuntustack:5000 auth_url = http://ubuntustack:35357 memcached_servers = ubuntustack:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = openstack [vnc] ... vncserver_listen = $my_ip vncserver_proxyclient_address = $my_ip enabled = True novncproxy_base_url = http://ubuntustack:6080/vnc_auto.html [glance] ... api_servers = http://ubuntustack:9292 [oslo_concurrency] ... lock_path = /var/lib/nova/tmp
配置Nova虛擬機類型:
$ vi /etc/nova/nova-compute.conf [libvirt] ... virt_type = qemu
同步Nova數據庫:
$ su -s /bin/sh -c "nova-manage api_db sync" nova $ su -s /bin/sh -c "nova-manage db sync" nova
重啟Nova服務:
$ service nova-api restart && service nova-consoleauth restart && service nova-scheduler restart && \ service nova-conductor restart && service nova-novncproxy restart && service nova-compute restart
設置管理員環境變量:
$ . admin-openrc
查看計算服務狀態:
$ openstack compute service list +----+------------------+-------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+-------------+----------+---------+-------+----------------------------+ | 4 | nova-consoleauth | UbuntuStack | internal | enabled | up | 2016-11-28T21:51:28.000000 | | 5 | nova-scheduler | UbuntuStack | internal | enabled | up | 2016-11-28T21:51:32.000000 | | 6 | nova-conductor | UbuntuStack | internal | enabled | up | 2016-11-28T21:51:32.000000 | | 8 | nova-compute | UbuntuStack | nova | enabled | up | 2016-11-28T21:51:28.000000 | +----+------------------+-------------+----------+---------+-------+----------------------------+
查看Nova日志:
$ vi /var/log/nova/nova-compute.log
創建Neutron數據庫:
$ mysql -u root -p > openstack > CREATE DATABASE neutron; > GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'openstack'; > quit
設置管理員環境變量:
$ . admin-openrc
創建Neutron用戶:
$ openstack user create --domain default --password-prompt neutron User Password: > openstack Repeat User Password: > openstack +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | da9bf75b6a4041d1b9aba7b236026a2d | | name | neutron | | password_expires_at | None | +---------------------+----------------------------------+
把Neutorn加入服務的管理角色:
$ openstack role add --project service --user neutron admin
創建Neutron服務:
$ openstack service create --name neutron --description "OpenStack Networking" network +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Networking | | enabled | True | | id | 7d3567ffbc4941dd800f445eab76ded9 | | name | neutron | | type | network | +-------------+----------------------------------+
創建Neutron服務的公共EndPoint:
$ openstack endpoint create --region RegionOne network public http://ubuntustack:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | b55696fa3198466a9def11bda1263caf | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 7d3567ffbc4941dd800f445eab76ded9 | | service_name | neutron | | service_type | network | | url | http://ubuntustack:9696 | +--------------+----------------------------------+
創建Neutron服務的內部EndPoint:
$ openstack endpoint create --region RegionOne network internal http://ubuntustack:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 26f5c0b68e134e87bd95a3ae8aa676f1 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 7d3567ffbc4941dd800f445eab76ded9 | | service_name | neutron | | service_type | network | | url | http://ubuntustack:9696 | +--------------+----------------------------------+
創建Neutron服務的管理EndPoint:
$ openstack endpoint create --region RegionOne network admin http://ubuntustack:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 8149bf9a36ce4e53884bd3a766dfb116 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 7d3567ffbc4941dd800f445eab76ded9 | | service_name | neutron | | service_type | network | | url | http://ubuntustack:9696 | +--------------+----------------------------------+
安裝Neutron軟件包:
$ apt-get install neutron-server neutron-plugin-ml2 neutron-linuxbridge-agent neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent
配置Neutron服務:
$ vi /etc/neutron/neutron.conf [database] ... connection = mysql+pymysql://neutron:openstack@ubuntustack/neutron [DEFAULT] ... core_plugin = ml2 service_plugins = router allow_overlapping_ips = True transport_url = rabbit://openstack:openstack@ubuntustack auth_strategy = keystone notify_nova_on_port_status_changes = True notify_nova_on_port_data_changes = True [keystone_authtoken] ... auth_uri = http://ubuntustack:5000 auth_url = http://ubuntustack:35357 memcached_servers = ubuntustack:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = openstack [nova] ... auth_url = http://ubuntustack:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = nova password = openstack
配置“Self-Service”網絡
# Configure the Modular Layer 2 (ML2) plug-in $ vi /etc/neutron/plugins/ml2/ml2_conf.ini [ml2] ... type_drivers = flat,vlan,vxlan tenant_network_types = vxlan mechanism_drivers = linuxbridge,l2population extension_drivers = port_security [ml2_type_flat] ... flat_networks = provider [ml2_type_vxlan] ... vni_ranges = 1:1000 [securitygroup] ... enable_ipset = True
配置Linux網橋代理:
$ vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini [linux_bridge] physical_interface_mappings = provider:ens33 [vxlan] enable_vxlan = True local_ip = 192.168.195.160 l2_population = True [securitygroup] ... enable_security_group = True firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
配置Layer 3代理:
$ vi /etc/neutron/l3_agent.ini [DEFAULT] ... interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
配置DHCP代理:
$ vi /etc/neutron/dhcp_agent.ini [DEFAULT] ... interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq enable_isolated_metadata = True
配置元數據代理:
$ vi /etc/neutron/metadata_agent.ini [DEFAULT] ... nova_metadata_ip = ubuntustack metadata_proxy_shared_secret = openstack
配置Nova服務使用Neutron服務:
$ vi /etc/nova/nova.conf [neutron] ... url = http://ubuntustack:9696 auth_url = http://ubuntustack:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = openstack service_metadata_proxy = True metadata_proxy_shared_secret = openstack
同步Neutron數據庫:
$ su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \ --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
重啟Nova和Neutron服務:
$ service nova-api restart $ service neutron-server restart && service neutron-linuxbridge-agent restart && \ service neutron-dhcp-agent restart && service neutron-metadata-agent restart $ service neutron-l3-agent restart $ service nova-compute restart
設置管理員環境變量
$ . admin-openrc
查看Neutron擴展:
$ neutron ext-list +---------------------------+-----------------------------------------------+ | alias | name | +---------------------------+-----------------------------------------------+ | default-subnetpools | Default Subnetpools | | network-ip-availability | Network IP Availability | | network_availability_zone | Network Availability Zone | | auto-allocated-topology | Auto Allocated Topology Services | | ext-gw-mode | Neutron L3 Configurable external gateway mode | | binding | Port Binding | | agent | agent | | subnet_allocation | Subnet Allocation | | l3_agent_scheduler | L3 Agent Scheduler | | tag | Tag support | | external-net | Neutron external network | | flavors | Neutron Service Flavors | | net-mtu | Network MTU | | availability_zone | Availability Zone | | quotas | Quota management support | | l3-ha | HA Router extension | | provider | Provider Network | | multi-provider | Multi Provider Network | | address-scope | Address scope | | extraroute | Neutron Extra Route | | subnet-service-types | Subnet service types | | standard-attr-timestamp | Resource timestamps | | service-type | Neutron Service Type Management | | l3-flavors | Router Flavor Extension | | port-security | Port Security | | extra_dhcp_opt | Neutron Extra DHCP opts | | standard-attr-revisions | Resource revision numbers | | pagination | Pagination support | | sorting | Sorting support | | security-group | security-group | | dhcp_agent_scheduler | DHCP Agent Scheduler | | router_availability_zone | Router Availability Zone | | rbac-policies | RBAC Policies | | standard-attr-description | standard-attr-description | | router | Neutron L3 Router | | allowed-address-pairs | Allowed Address Pairs | | project-id | project_id field enabled | | dvr | Distributed Virtual Router | +---------------------------+-----------------------------------------------+
查看網絡代理:
$ openstack network agent list +--------------------------------------+--------------------+-------------+-------------------+-------+-------+---------------------------+ | ID | Agent Type | Host | Availability Zone | Alive | State | Binary | +--------------------------------------+--------------------+-------------+-------------------+-------+-------+---------------------------+ | 3d9ec505-1ec9-48a9-9f2f-a5b769fbd77e | L3 agent | UbuntuStack | nova | True | UP | neutron-l3-agent | | 3ee2203d-d462-453a-990c-d6646a1262b7 | Linux bridge agent | UbuntuStack | None | True | UP | neutron-linuxbridge-agent | | 87ccc0a5-e686-4e04-ad75-b066be2771e9 | Metadata agent | UbuntuStack | None | True | UP | neutron-metadata-agent | | deaf9d1b-d2b0-4706-be37-5fbdc0d16abf | DHCP agent | UbuntuStack | nova | True | UP | neutron-dhcp-agent | +--------------------------------------+--------------------+-------------+-------------------+-------+-------+---------------------------+
設置管理員環境變量:
$ . admin-openrc
創建“Provider”網絡:
$ openstack network create --share --provider-physical-network provider --provider-network-type flat provider +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2016-11-28T23:15:05Z | | description | | | headers | | | id | 716eaea1-3b1b-459a-a601-4b9a0d3266e3 | | ipv4_address_scope | None | | ipv6_address_scope | None | | mtu | 1500 | | name | provider | | port_security_enabled | True | | project_id | c77f9d27e4f5496092357ff991d1639b | | project_id | c77f9d27e4f5496092357ff991d1639b | | provider:network_type | flat | | provider:physical_network | provider | | provider:segmentation_id | None | | revision_number | 3 | | router:external | Internal | | shared | True | | status | ACTIVE | | subnets | | | tags | [] | | updated_at | 2016-11-28T23:15:05Z | +---------------------------+--------------------------------------+
為“Provider”網絡創建一個子網:
$ openstack subnet create --network provider \ --allocation-pool start=192.168.195.200,end=192.168.195.230 \ --dns-nameserver 114.114.114.114 --gateway 192.168.195.2 \ --subnet-range 192.168.195.0/24 provider +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | allocation_pools | 192.168.195.200-192.168.195.230 | | cidr | 192.168.195.0/24 | | created_at | 2016-11-28T23:19:49Z | | description | | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 192.168.195.2 | | headers | | | host_routes | | | id | b8d66c38-2770-46f0-bbc1-6010b995d5af | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | provider | | network_id | 716eaea1-3b1b-459a-a601-4b9a0d3266e3 | | project_id | c77f9d27e4f5496092357ff991d1639b | | project_id | c77f9d27e4f5496092357ff991d1639b | | revision_number | 2 | | service_types | [] | | subnetpool_id | None | | updated_at | 2016-11-28T23:19:49Z | +-------------------+--------------------------------------+
設置測試用戶環境變量:
$ . demo-openrc
創建“Self-Service”網絡:
$ openstack network create selfservice +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2016-11-29T09:47:39Z | | description | | | headers | | | id | eb2f08c3-dbc4-423e-8206-6b0fb07d94b7 | | ipv4_address_scope | None | | ipv6_address_scope | None | | mtu | 1450 | | name | selfservice | | port_security_enabled | True | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | revision_number | 3 | | router:external | Internal | | shared | False | | status | ACTIVE | | subnets | | | tags | [] | | updated_at | 2016-11-29T09:47:39Z | +-------------------------+--------------------------------------+
設置“Self-Service”網絡子網:
$ openstack subnet create --network selfservice \ --dns-nameserver 114.114.114.114 --gateway 192.168.196.1 \ --subnet-range 192.168.196.0/24 selfservice +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | allocation_pools | 192.168.196.2-192.168.196.254 | | cidr | 192.168.196.0/24 | | created_at | 2016-11-28T23:23:23Z | | description | | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 192.168.196.1 | | headers | | | host_routes | | | id | e7aed07e-0d4c-4b8f-9210-1ec658a92f33 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | selfservice | | network_id | 18d0b6d3-b78a-4703-a24e-ec5dc9b73bd7 | | project_id | c77f9d27e4f5496092357ff991d1639b | | project_id | c77f9d27e4f5496092357ff991d1639b | | revision_number | 2 | | service_types | [] | | subnetpool_id | None | | updated_at | 2016-11-28T23:23:24Z | +-------------------+--------------------------------------+
查看已經創建的網絡:
$ openstack subnet list +--------------------------------------+-------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+-------------+--------------------------------------+------------------+ | b8d66c38-2770-46f0-bbc1-6010b995d5af | provider | 716eaea1-3b1b-459a-a601-4b9a0d3266e3 | 192.168.195.0/24 | | ee9382f0-3ce2-4451-931e-402da6441a35 | selfservice | eb2f08c3-dbc4-423e-8206-6b0fb07d94b7 | 192.168.196.0/24 | +--------------------------------------+-------------+--------------------------------------+------------------+
設置測試用戶環境變量:
$ . demo-openrc
更新“Provider”網絡路由:
$ neutron net-update provider --router:external Updated network: provider
創建一個路由:
$ openstack router create router +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2016-11-29T09:50:56Z | | description | | | external_gateway_info | null | | flavor_id | None | | headers | | | id | 2b84f7f4-9bef-427f-afad-19a9f53b4b2d | | name | router | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | revision_number | 2 | | routes | | | status | ACTIVE | | updated_at | 2016-11-29T09:50:56Z | +-------------------------+--------------------------------------+
把“Self-Service”網絡添加進路由端口:
$ neutron router-interface-add router selfservice Added interface ba82e6d7-117d-42cd-8c51-adde92aeb14b to router router. # neutron router-interface-delete router selfservice
設置“Provider”網絡的網關:
$ neutron router-gateway-set router provider Set gateway for router router # neutron router-gateway-clear router provider
設置管理員用戶環境變量:
$ . admin-openrc
查看網絡命名空間:
$ ip netns qrouter-2b84f7f4-9bef-427f-afad-19a9f53b4b2d (id: 2) qdhcp-eb2f08c3-dbc4-423e-8206-6b0fb07d94b7 (id: 1) qdhcp-716eaea1-3b1b-459a-a601-4b9a0d3266e3 (id: 0)
查看路由端口:
$ neutron router-port-list router +--------------------------------------+------+-------------------+---------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+---------------------------------------------------+ | 1b867faf-2602-4a2b-a626-a80be2dbb8a4 | | fa:16:3e:48:b3:dd | {"subnet_id": | | | | | "b8d66c38-2770-46f0-bbc1-6010b995d5af", | | | | | "ip_address": "192.168.195.201"} | | ba82e6d7-117d-42cd-8c51-adde92aeb14b | | fa:16:3e:19:ac:de | {"subnet_id": "ee9382f0-3ce2-4451-931e- | | | | | 402da6441a35", "ip_address": "192.168.196.1"} | +--------------------------------------+------+-------------------+---------------------------------------------------+
使用ping命令測試“Provider”網絡:
$ ping -c 4 192.168.195.201 PING 192.168.195.201 (192.168.195.201) 56(84) bytes of data. 64 bytes from 192.168.195.201: icmp_seq=1 ttl=64 time=0.131 ms 64 bytes from 192.168.195.201: icmp_seq=2 ttl=64 time=0.057 ms 64 bytes from 192.168.195.201: icmp_seq=3 ttl=64 time=0.054 ms 64 bytes from 192.168.195.201: icmp_seq=4 ttl=64 time=0.051 ms --- 192.168.195.201 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 2997ms rtt min/avg/max/mdev = 0.051/0.073/0.131/0.033 ms
設置管理員用戶環境變量:
$ . admin-openrc
創建“m1.nano”虛擬機模板:
$ openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano +----------------------------+---------+ | Field | Value | +----------------------------+---------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 1 | | id | 0 | | name | m1.nano | | os-flavor-access:is_public | True | | properties | | | ram | 64 | | rxtx_factor | 1.0 | | swap | | | vcpus | 1 | +----------------------------+---------+
設置測試用戶環境變量:
$ . demo-openrc
生成ssh鑰匙對:
# Alternatively, you can skip the ssh-keygen command and use an existing public key. $ ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa):
添加鑰匙對:
$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | 92:f3:2f:58:fa:6b:32:c7:b2:df:66:46:5f:28:43:d4 | | name | mykey | | user_id | ffff52bbf1da4c86a3d2b57e977f6b82 | +-------------+-------------------------------------------------+
查看鑰匙對:
$ openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 92:f3:2f:58:fa:6b:32:c7:b2:df:66:46:5f:28:43:d4 | +-------+-------------------------------------------------+
允許ICMP協議(可以ping):
$ openstack security group rule create --proto icmp default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2016-11-28T23:33:13Z | | description | | | direction | ingress | | ethertype | IPv4 | | headers | | | id | 7f5a28ec-2523-4922-aaad-92bd4c1583c5 | | port_range_max | None | | port_range_min | None | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | 42794c97-bdfb-4f02-aa5c-c34df255f620 | | updated_at | 2016-11-28T23:33:13Z | +-------------------+--------------------------------------+
允許SSH協議:
$ openstack security group rule create --proto tcp --dst-port 22 default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2016-11-28T23:34:05Z | | description | | | direction | ingress | | ethertype | IPv4 | | headers | | | id | bfe104f7-e15c-4216-bf12-79c36247a308 | | port_range_max | 22 | | port_range_min | 22 | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | 42794c97-bdfb-4f02-aa5c-c34df255f620 | | updated_at | 2016-11-28T23:34:05Z | +-------------------+--------------------------------------+
設置測試用戶環境變量:
$ . demo-openrc
查看已創建的虛擬機模板:
$ openstack flavor list +----+---------+-----+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+---------+-----+------+-----------+-------+-----------+ | 0 | m1.nano | 64 | 1 | 0 | 1 | True | +----+---------+-----+------+-----------+-------+-----------+
查看已添加的虛擬機鏡像:
$ openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | e345e8b0-71b7-44e0-b1a1-e168f85a19f6 | cirros | active | +--------------------------------------+--------+--------+
查看已創建的虛擬機網絡:
$ openstack network list +--------------------------------------+-------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+-------------+--------------------------------------+ | 716eaea1-3b1b-459a-a601-4b9a0d3266e3 | provider | b8d66c38-2770-46f0-bbc1-6010b995d5af | | eb2f08c3-dbc4-423e-8206-6b0fb07d94b7 | selfservice | ee9382f0-3ce2-4451-931e-402da6441a35 | +--------------------------------------+-------------+--------------------------------------+
查看已添加的安全組:
$ openstack security group list +--------------------------------------+---------+------------------------+----------------------------------+ | ID | Name | Description | Project | +--------------------------------------+---------+------------------------+----------------------------------+ | 42794c97-bdfb-4f02-aa5c-c34df255f620 | default | Default security group | c7ddc0ecab64419486df0d7f66e8174c | +--------------------------------------+---------+------------------------+----------------------------------+
創建并啟動虛擬機:
$ openstack server create --flavor m1.nano --image cirros \ --nic net-id=eb2f08c3-dbc4-423e-8206-6b0fb07d94b7 --security-group default \ --key-name mykey selfservice-instance +--------------------------------------+-----------------------------------------------+ | Field | Value | +--------------------------------------+-----------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-STS:power_state | NOSTATE | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | None | | OS-SRV-USG:terminated_at | None | | accessIPv4 | | | accessIPv6 | | | addresses | | | adminPass | RtZAyPrB426N | | config_drive | | | created | 2016-11-29T09:59:42Z | | flavor | m1.nano (0) | | hostId | | | id | aef838f5-8f9d-4ff2-8a34-17bd5ac05a8a | | image | cirros (e345e8b0-71b7-44e0-b1a1-e168f85a19f6) | | key_name | mykey | | name | selfservice-instance | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | properties | | | security_groups | [{u'name': u'default'}] | | status | BUILD | | updated | 2016-11-29T09:59:42Z | | user_id | ffff52bbf1da4c86a3d2b57e977f6b82 | +--------------------------------------+-----------------------------------------------+
查看虛擬機狀態:
$ openstack server list +--------------------------------------+----------------------+--------+----------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------------------+--------+----------+------------+ | aef838f5-8f9d-4ff2-8a34-17bd5ac05a8a | selfservice-instance | BUILD | | cirros | +--------------------------------------+----------------------+--------+----------+------------+
如果虛擬機沒有啟動,可以使用如下命令:
$ openstack server start selfservice-instance
查看虛擬機控制臺URL,并使用Web瀏覽器打開(用戶名:“cirros”,密碼:“cubswin:)”):
$ openstack console url show selfservice-instance +-------+----------------------------------------------------------------------------------+ | Field | Value | +-------+----------------------------------------------------------------------------------+ | type | novnc | | url | http://ubuntustack:6080/vnc_auto.html?token=749d78c1-33f1-4843-a5f6-1f0920773941 | +-------+----------------------------------------------------------------------------------+
重新設置虛擬機密碼:
$ sudo passwd root > 123456 > 123456
ping內網網關和公網網址:
$ ping -c 4 192.168.196.1 $ ping www.163.com
在“Provider”網絡上創建浮動IP:
$ openstack floating ip create provider +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2016-11-29T10:04:06Z | | description | | | fixed_ip_address | None | | floating_ip_address | 192.168.195.206 | | floating_network_id | 716eaea1-3b1b-459a-a601-4b9a0d3266e3 | | headers | | | id | a037740a-eb2a-4b78-9b9a-39a5c1b00ac7 | | port_id | None | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | project_id | c7ddc0ecab64419486df0d7f66e8174c | | revision_number | 1 | | router_id | None | | status | DOWN | | updated_at | 2016-11-29T10:04:06Z | +---------------------+--------------------------------------+ # openstack floating ip delete d30f7916-a9c7-42ee-aaec-f60bb1ae732a
為剛才創建的“selfservice-instance”虛擬機添加一個浮動IP:
$ openstack server add floating ip selfservice-instance 192.168.195.206 # openstack server remove floating ip selfservice-instance 192.168.195.211
查看虛擬機狀態:
$ openstack server list +--------------------------------------+----------------------+--------+--------------------------------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------------------+--------+--------------------------------------------+------------+ | aef838f5-8f9d-4ff2-8a34-17bd5ac05a8a | selfservice-instance | ACTIVE | selfservice=192.168.196.9, 192.168.195.206 | cirros | +--------------------------------------+----------------------+--------+--------------------------------------------+------------+
ping虛擬機浮動IP:
$ ping -c 4 192.168.195.206 PING 192.168.195.206 (192.168.195.206) 56(84) bytes of data. 64 bytes from 192.168.195.206: icmp_seq=1 ttl=63 time=0.955 ms 64 bytes from 192.168.195.206: icmp_seq=2 ttl=63 time=0.350 ms 64 bytes from 192.168.195.206: icmp_seq=3 ttl=63 time=0.445 ms 64 bytes from 192.168.195.206: icmp_seq=4 ttl=63 time=0.711 ms --- 192.168.195.206 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms rtt min/avg/max/mdev = 0.350/0.615/0.955/0.237 ms
使用ssh訪問虛擬機:
$ ssh cirros@192.168.195.206 $ cat /etc/issue login as 'cirros' user. default password: 'cubswin:)'. use 'sudo' for root.
創建Cinder數據庫:
$ mysql -u root -p > openstack > CREATE DATABASE cinder; > GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'openstack'; > GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'openstack'; > quit
設置管理員用戶環境變量:
$ . admin-openrc
創建Cinder用戶:
$ openstack user create --domain default --password-prompt cinder User Password: > openstack Repeat User Password: > openstack +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 16912fdd1eed410a8a76720b0a38a334 | | name | cinder | | password_expires_at | None | +---------------------+----------------------------------+
把Cinder用戶添加進服務的管理員角色:
$ openstack role add --project service --user cinder admin
創建Cinder服務:
$ openstack service create --name cinder --description "OpenStack Block Storage" volume +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | 0b2ccf8379a345748773027492a28c8c | | name | cinder | | type | volume | +-------------+----------------------------------+
創建Cinder V2服務:
$ openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | 4c9f38fec5e7419a96faeb615d9459c6 | | name | cinderv2 | | type | volumev2 | +-------------+----------------------------------+
創建Cinder服務的公共EndPoint:
$ openstack endpoint create --region RegionOne volume public http://ubuntustack:8776/v1/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 606c64305e0b49bb968d39aaec25b37a | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 0b2ccf8379a345748773027492a28c8c | | service_name | cinder | | service_type | volume | | url | http://ubuntustack:8776/v1/%(tenant_id)s | +--------------+------------------------------------------+
創建Cinder服務的內部EndPoint:
$ openstack endpoint create --region RegionOne volume internal http://ubuntustack:8776/v1/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 315ba5dbbb9944abaa9d3bbe391b6b67 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 0b2ccf8379a345748773027492a28c8c | | service_name | cinder | | service_type | volume | | url | http://ubuntustack:8776/v1/%(tenant_id)s | +--------------+------------------------------------------
創建Cinder服務的管理EndPoint:
$ openstack endpoint create --region RegionOne volume admin http://ubuntustack:8776/v1/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 7f1c360d846c45f3ba00ab9f1924eda3 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 0b2ccf8379a345748773027492a28c8c | | service_name | cinder | | service_type | volume | | url | http://ubuntustack:8776/v1/%(tenant_id)s | +--------------+------------------------------------------+
創建Cinder V2服務的公共EndPoint:
$ openstack endpoint create --region RegionOne volumev2 public http://ubuntustack:8776/v2/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | b0d39b4917ce440dae198c89313c2034 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 4c9f38fec5e7419a96faeb615d9459c6 | | service_name | cinderv2 | | service_type | volumev2 | | url | http://ubuntustack:8776/v2/%(tenant_id)s | +--------------+------------------------------------------+
創建Cinder V2服務的內部EndPoint:
$ openstack endpoint create --region RegionOne volumev2 internal http://ubuntustack:8776/v2/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 508541b13b1b4d4ebb860891c0ccffbd | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 4c9f38fec5e7419a96faeb615d9459c6 | | service_name | cinderv2 | | service_type | volumev2 | | url | http://ubuntustack:8776/v2/%(tenant_id)s | +--------------+------------------------------------------
創建Cinder V2服務的管理EndPoint:
$ openstack endpoint create --region RegionOne volumev2 admin http://ubuntustack:8776/v2/%\(tenant_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 283c9c773a194b61aca19b3cfcdb14a6 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 4c9f38fec5e7419a96faeb615d9459c6 | | service_name | cinderv2 | | service_type | volumev2 | | url | http://ubuntustack:8776/v2/%(tenant_id)s | +--------------+------------------------------------------+
安裝Cinder軟件包:
$ apt-get install cinder-api cinder-scheduler cinder-volume
$ vi /etc/cinder/cinder.conf [database] connection = mysql+pymysql://cinder:openstack@ubuntustack/cinder [DEFAULT] ... transport_url = rabbit://openstack:openstack@ubuntustack auth_strategy = keystone my_ip = 192.168.195.160 [keystone_authtoken] auth_uri = http://ubuntustack:5000 auth_url = http://ubuntustack:35357 memcached_servers = ubuntustack:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = openstack [oslo_concurrency] lock_path = /var/lib/cinder/tmp
配置Nova使用Cinder服務:
$ vi /etc/nova/nova.conf [cinder] os_region_name = RegionOne
同步Cinder數據庫:
$ su -s /bin/sh -c "cinder-manage db sync" cinder
重啟Nova和Cinder服務:
$ service nova-api restart && service cinder-scheduler restart && service cinder-api restart
安裝LVM軟件包:
$ apt-get install lvm2
啟動LVM元數據服務:
$ service lvm2-lvmetad start
創建一個PV:
$ pvcreate /dev/sdd1 Physical volume "/dev/sdd1" successfully created
創建一個VG:
$ vgcreate cinder-volumes /dev/sdd1 Volume group "cinder-volumes" successfully created
配置Cinder使用LVM:
$ vi /etc/cinder/cinder.conf [DEFAULT] ... enabled_backends = lvm glance_api_servers = http://ubuntustack:9292 [lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes iscsi_protocol = iscsi iscsi_helper = tgtadm
重啟Cinder卷服務:
$ service cinder-volume restart
$ . admin-openrc
$ openstack volume service list +------------------+-----------------+------+---------+-------+----------------------------+ | Binary | Host | Zone | Status | State | Updated At | +------------------+-----------------+------+---------+-------+----------------------------+ | cinder-scheduler | UbuntuStack | nova | enabled | up | 2016-11-29T00:35:14.000000 | | cinder-volume | UbuntuStack | nova | enabled | up | 2016-11-29T00:34:33.000000 | | cinder-volume | UbuntuStack@lvm | nova | enabled | up | 2016-11-29T00:35:17.000000 | +------------------+-----------------+------+---------+-------+----------------------------+
設置測試用戶環境變量:
$ . demo-openrc
創建一個1G的卷:
$ openstack volume create --size 1 volume1 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2016-11-29T10:21:46.494577 | | description | None | | encrypted | False | | id | 5e291162-0cbb-4077-bb07-c2a217b28c1e | | multiattach | False | | name | volume1 | | properties | | | replication_status | disabled | | size | 1 | | snapshot_id | None | | source_volid | None | | status | creating | | type | None | | updated_at | None | | user_id | ffff52bbf1da4c86a3d2b57e977f6b82 | +---------------------+--------------------------------------+ # openstack volume delete volume1
查看已創建的卷:
$ openstack volume list +--------------------------------------+--------------+----------+------+-------------+ | ID | Display Name | Status | Size | Attached to | +--------------------------------------+--------------+----------+------+-------------+ | 5e291162-0cbb-4077-bb07-c2a217b28c1e | volume1 | creating | 1 | | +--------------------------------------+--------------+----------+------+-------------+
為虛擬機增加一個卷:
$ openstack server add volume selfservice-instance volume1
查看虛擬機狀態:
$ openstack volume list +--------------------------------------+--------------+--------+------+-----------------------------------------------+ | ID | Display Name | Status | Size | Attached to | +--------------------------------------+--------------+--------+------+-----------------------------------------------+ | 5e291162-0cbb-4077-bb07-c2a217b28c1e | volume1 | in-use | 1 | Attached to selfservice-instance on /dev/vdb | +--------------------------------------+--------------+--------+------+-----------------------------------------------+
$ 查看附加到虛擬機的卷:
$ ssh cirros@192.168.195.206 $ sudo fdisk -l Disk /dev/vda: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 2088449 1036192+ 83 Linux Disk /dev/vdb: 1073 MB, 1073741824 bytes 16 heads, 63 sectors/track, 2080 cylinders, total 2097152 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
安裝Horizon軟件包:
$ apt install openstack-dashboard
配置Horizon服務:
$ vi /etc/openstack-dashboard/local_settings.py # Configure the dashboard to use OpenStack services on the ubuntustack node OPENSTACK_HOST = "ubuntustack" # Allow all hosts to access the dashboard ALLOWED_HOSTS = ['*', ] # Configure the memcached session storage service SESSION_ENGINE = 'django.contrib.sessions.backends.cache' CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': 'ubuntustack:11211', } } # Enable the Identity API version 3 OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST # Enable support for domains: OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True # Configure API versions: OPENSTACK_API_VERSIONS = { "identity": 3, "image": 2, "volume": 2, } # Configure default as the default domain for users that you create via the dashboard: OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "default" # Configure user as the default role for users that you create via the dashboard: OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user" # Optionally, configure the time zone: TIME_ZONE = "Asia/Shanghai"
重啟Web服務器:
$ service apache2 reload
使用瀏覽器打開 http://ubuntustack/horizon ,使用如下用戶名和密碼登錄查看:
Domain User Password default admin openstack default demo openstack
到此,相信大家對“怎么在Ubuntu16單節點上安裝OpenStack”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。