openstack安裝部署私有云詳細圖文

本文主要分享的是雲計算、openstack的使用、私有云平臺建設、雲服務器雲硬盤的構建和使用。從基本概念入手到私有云建設,信息量很是大。對於openstack的安裝部署都是從官方文檔中一步步的介紹,內容很是詳細。html

1、雲計算 基本概念node

雲計算(cloud computing)是基於互聯網的相關服務的增長、使用和交付模式,一般涉及經過互聯網來提供動態易擴展且常常是虛擬化的資源。雲是網絡、互聯網的一種比喻說法。過去在圖中每每用雲來表示電信網,後來也用來表示互聯網和底層基礎設施的抽象。所以,雲計算甚至可讓你體驗每秒10萬億次的運算能力,擁有這麼強大的計算能力能夠模擬核爆炸、預測氣候變化和市場發展趨勢。用戶經過電腦、筆記本、手機等方式接入數據中心,按本身的需求進行運算。python

雲計算分類mysql

簡單來講,就是把應用程序和數據都放在由大量服務器組成的雲中,用戶須要什麼只要購買相應服務並使用便可。linux

雲計算分爲私有云、公有云、混合雲。web

雲計算的服務分類:基礎設施即服務、平臺即服務、軟件即服務。sql

  1. 超大規模。「雲」具備至關的規模,Google雲計算已經擁有100多萬臺服務器,亞馬遜、IBM、微軟和Yahoo等公司的「雲」均擁有幾十萬臺服務器。「雲」能賦予用戶史無前例的計算能力。
  2. 虛擬化。雲計算支持用戶在任意位置使用各類終端獲取服務。所請求的資源來自「雲」,而不是固定的有形的實體。應用在「雲」中某處運行,但實際上用戶無需瞭解應用運行的具體位置,只須要一臺筆記本或一個PDA,就能夠經過網絡服務來獲取各類能力超強的服務。
  3. 高可靠性。「雲」使用了數據多副本容錯、計算節點同構可互換等措施來保障服務的高可靠性,使用雲計算比使用本地計算機更加可靠。
  4. 通用性。雲計算不針對特定的應用,在「雲」的支撐下能夠構造出於變萬化的應用,同一片「雲」能夠同時支撐不一樣的應用運行。
  5. 高可伸縮性。「雲」的規模能夠動態伸縮,知足應用和用戶規模增加的須要。
  6. 按需服務。「雲」是一個龐大的資源池,用戶按需購買,像自來水、電和煤氣那樣計費。
  7. 極其廉價。「雲」的特殊容錯措施使得能夠採用極其廉價的節點來構成雲;「雲」的自動化管理使數據中心管理成本大幅下降;「雲」的公用性和通用性使資源的利用率大幅提高;「雲」設施能夠建在電力資源豐富的地區,從而大幅下降能源成本。

 2、Openstack基本概念數據庫

OpenStack是一個開源的雲計算管理平臺項目,由幾個主要的組件組合起來完成django

具體工做。OpenStack支持幾乎全部類型的雲環境,項目目標是提供實施簡單、centos

可大規模擴展、豐富、標準統一的雲計算管理平臺。OpenStack經過各類互補的

服務提供了基礎設施即服務(IaaS)的解決方案,每一個服務提供API以進行集成。

常見組件:

  • Dashboard(web項目)
  • Keystone(權限管理)
  • Nova(管理虛擬機)
  • Nova-network(管理網絡流量和ip)
  • Glance(鏡像管理項目)
  • Cinder(磁盤管理)
  • Swift(網盤,對象)

基礎的系統圖

Openstack安裝部署

下面來講一說openstack的安裝部署。首先說明openstack的總體安裝很是複雜,文末提供官方安裝文檔下載,我就是根據這個英文的官方文檔來安裝部署的。如下內容是參照官方文檔「openstack-install-guide-yum-icehouse.pdf」來的。

首先須要準備3臺linux的機器。我這裏選用的是centos6.6的64位的系統。配置IP地址,關閉防火牆,修改主機名。

• Controller Node: 1 processor, 2 GB memory, and 5 GB storage

• Compute01: 1 processor, 512 MB memory, and 5 GB storage

• Compute02 Node: 1 processor, 2 GB memory, and 10 GB storage

我這裏controller的ip地址是:192.168.44.147

computer01:192.168.44.148

computer02:192.168.44.149

基本環境配置

如下內容是在controller機器上配置的。

一、數據庫安裝。

由於須要一個數據庫,因此這裏選用了mysql數據庫。

yum install mysql mysql-server MySQL-python

編輯/etc/my.cnf文件,在裏面添加以下內容,主要意思就是設置編碼爲utf-8。

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

而後啓動服務,開機啓動。

# service mysqld start
# chkconfig mysqld on
# mysql_install_db
# mysql_secure_installation

賦權,使其能夠遠程登陸。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'a';

二、openstack基本包安裝。

# yum install yum-plugin-priorities

# yum install http://repos.fedorapeople.org/repos/openstack/openstackicehouse/rdo-release-icehouse-3.noarch.rpm

# yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.
noarch.rpm

# yum install openstack-utils

# yum install openstack-selinux

三、安裝消息隊列

yum install qpid-cpp-server

啓動服務

service qpidd start
chkconfig qpidd on

權限認證服務(keystone)

安裝權限認證服務:

yum install openstack-keystone python-keystoneclient -y

建立用戶,寫入到配置文件中:

openstack-config --set /etc/keystone/keystone.conf \
database connection mysql://keystone:KEYSTONE_DBPASS@controller/keystone

建立keystone數據庫表:

$ mysql -u root -p
mysql> CREATE DATABASE keystone;
mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
mysql> exit

自動生成表:

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

設置用戶環境變量:

ADMIN_TOKEN=$(openssl rand -hex 10)
echo $ADMIN_TOKEN
openstack-config --set /etc/keystone/keystone.conf DEFAULT \
admin_token $ADMIN_TOKEN

# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone
# chown -R keystone:keystone /etc/keystone/ssl
# chmod -R o-rwx /etc/keystone/ssl

啓動keystone服務:

service openstack-keystone start
chkconfig openstack-keystone on

將admin_token設置到環境變量中去。

export OS_SERVICE_TOKEN=$ADMIN_TOKEN
export OS_SERVICE_ENDPOINT=http://controller:35357/v2.0

建立管理員用戶,默認的用戶名爲admin,密碼爲ADMIN_PASS,你能夠自定義修改:

[root@controller keystone]# keystone user-create --name=admin --pass=ADMIN_PASS --email=ADMIN_EMAIL
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | ADMIN_EMAIL|
| enabled | True |
|id| 332f5ecb18c64bf687b154facd629fb6 |
| name | admin |
| username | admin |
+----------+----------------------------------+
[root@controller keystone]# keystone role-create --name=admin
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
|id| ab5da2c50d7443efb0514e84c2b4adb7 |
| name | admin |
+----------+----------------------------------+
[root@controller keystone]# keystone tenant-create --name=admin --description="Admin Tenant"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Admin Tenant |
| enabled | True |
| id | b89723a38b154eeea6416a83b293b0ad |
| name| admin |
+-------------+----------------------------------+
[root@controller keystone]# keystone user-role-add --user=admin --tenant=admin --role=admin
[root@controller keystone]# keystone user-role-add --user=admin --role=_member_ --tenant=admin
[root@controller keystone]#

建立一個權限認證服務,由於我這裏的主機名是controller,因此下面有 http://controller:35357/v2.0 這些信息,能夠自定義修改:

[root@controller keystone]# keystone service-create --name=keystone --type=identity \
> --description="OpenStack Identity"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description |OpenStack Identity|
| enabled | True |
| id | 4bfd5f39b86c45edb92d5c0488987dd8 |
| name| keystone |
| type| identity |
+-------------+----------------------------------+
[root@controller keystone]# keystone endpoint-create \
> --service-id=$(keystone service-list | awk '/ identity / {print $2}') \
> --publicurl=http://controller:5000/v2.0 \
> --internalurl=http://controller:5000/v2.0 \
> --adminurl=http://controller:35357/v2.0
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://controller:35357/v2.0 |
| id | 0350b72901a141498fe48304b13a1b98 |
| internalurl | http://controller:5000/v2.0|
| publicurl | http://controller:5000/v2.0|
|region |regionOne |
| service_id | 4bfd5f39b86c45edb92d5c0488987dd8 |
+-------------+----------------------------------+
[root@controller keystone]# keystone user-create --name=demo --pass=DEMO_PASS --email=DEMO_EMAIL
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email |DEMO_EMAIL|
| enabled | True |
|id| b44a9a1462d74f4e928b3b339289a2ae |
| name | demo |
| username | demo |
+----------+----------------------------------+
[root@controller keystone]# keystone tenant-create --name=demo --description="Demo Tenant"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Demo Tenant|
| enabled | True |
| id | 7bd79509ee184a2098ca0644679b60a8 |
| name| demo |
+-------------+----------------------------------+
[root@controller keystone]# keystone user-role-add --user=demo --role=_member_ --tenant=demo
[root@controller keystone]#

爲了方便咱們取到token,咱們能夠vi admin-openrc.sh,而後添加以下內容:

export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://controller:35357/v2.0

在每次關機重啓以後都要從新執行下面的命令,讓環境變量起做用。不然會報」Expecting an auth URL via either –os-auth-url or env[OS_AUTH_URL]」的錯誤:

source admin-openrc.sh

咱們可使用下面的命令查看keystone目前的用戶有哪些:

keystone user-list

測試效果:

打開restclient-ui-3.5-jar-with-dependencies.jar來測試效果:

url地址是: http://192.168.44.147:5000/v2.0/

訪問成功。

配置鏡像服務(glance)

在controller服務器中安裝服務:

yum install openstack-glance python-glanceclient


openstack-config --set /etc/glance/glance-api.conf database \
connection mysql://glance:GLANCE_DBPASS@controller/glance


openstack-config --set /etc/glance/glance-registry.conf database \
connection mysql://glance:GLANCE_DBPASS@controller/glance

在mysql數據庫中建立glance數據庫:

$ mysql -u root -p
mysql> CREATE DATABASE glance;
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';

flush privileges;

自動生成表:

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

在keystone上建立用戶:

keystone user-create --name=glance --pass=GLANCE_PASS --email=glance@example.com
$ keystone user-role-add --user=glance --tenant=service --role=admin

配置受權服務:

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_host controller
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_port 35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_protocol http
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_tenant_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_user glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy \
flavor keystone
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
auth_host controller
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
auth_port 35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
auth_protocol http
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
admin_tenant_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
admin_user glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken \
admin_password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy \
flavor keystone

啓動服務:

service openstack-glance-api start
# service openstack-glance-registry start
# chkconfig openstack-glance-api on
# chkconfig openstack-glance-registry on

建立服務:

$ keystone service-create --name=glance --type=image \
--description="OpenStack Image Service"


$ keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ image / {print $2}') \
--publicurl=http://controller:9292 \
--internalurl=http://controller:9292 \
--adminurl=http://controller:9292

[root@controller ~]# keystone service-create --name=glance --type=image \
> --description="OpenStack Image Service"
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
 _warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStack Image Service |
| enabled | True |
| id | a45f77cfc12c42d19a45a6ea12cdfc51 |
| name| glance |
| type| image |
+-------------+----------------------------------+
[root@controller ~]# keystone endpoint-create \
> --service-id=$(keystone service-list | awk '/ image / {print $2}') \
> --publicurl=http://controller:9292 \
> --internalurl=http://controller:9292 \
> --adminurl=http://controller:9292

+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://controller:9292 |
| id | 75deb2d2f85e4b7b88fe18bf5fca1a87 |
| internalurl | http://controller:9292 |
| publicurl | http://controller:9292 |
|region |regionOne |
| service_id | a45f77cfc12c42d19a45a6ea12cdfc51 |
+-------------+----------------------------------+

建立鏡像,先將下載好的cirros-0.3.2-x86_64-disk.img放置在/root目錄下,而後執行下面的命令:

複製代碼 代碼以下:


glance image-create --name "cirros-0.3.2-x86_64" --disk-format qcow2 \
--container-format bare --is-public True --progress < cirros-0.3.2-x86_64-disk.img

 

查看鏡像列表:

 

glance image-list

在前面咱們已經對kvm虛擬化有所瞭解,因此咱們如今知道qcow2就是一個鏡像文件。

服務器管理(Nova)

對於虛擬機管理咱們須要從controller和computer01進行配置。

先來看controller的配置:

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

$ mysql -u root -p
mysql> CREATE DATABASE nova;
mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
IDENTIFIED BY 'NOVA_DBPASS';
mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
IDENTIFIED BY 'NOVA_DBPASS';

openstack-config --set /etc/nova/nova.conf database connection mysql://nova:NOVA_DBPASS@controller/nova

openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend qpid
openstack-config --set /etc/nova/nova.conf DEFAULT qpid_hostname controller

openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.44.147
openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_listen 192.168.216.210
openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address 192.168.44.147


openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host controller
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password NOVA_PASS



$ keystone user-create --name=nova --pass=NOVA_PASS --email=nova@example.com
$ keystone user-role-add --user=nova --tenant=service --role=admin


$ keystone service-create --name=nova --type=compute \
--description="OpenStack Compute"
$ keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ compute / {print $2}') \
--publicurl=http://controller:8774/v2/%\(tenant_id\)s \
--internalurl=http://controller:8774/v2/%\(tenant_id\)s \
--adminurl=http://controller:8774/v2/%\(tenant_id\)s

而後是computer01的配置:

yum install openstack-nova-compute

 openstack-config --set /etc/nova/nova.conf database connection mysql://nova:NOVA_DBPASS@controller/nova
 openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller:5000
 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host controller
 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http
 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357
 openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova
 openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service
 openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password NOVA_PASS

 openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend qpid
 openstack-config --set /etc/nova/nova.conf DEFAULT qpid_hostname controller


 openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.44.148
 openstack-config --set /etc/nova/nova.conf DEFAULT vnc_enabled True
 openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_listen 0.0.0.0
 openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address 192.168.44.148
 openstack-config --set /etc/nova/nova.conf DEFAULT novncproxy_base_url http://controller:6080/vnc_auto.html


openstack-config --set /etc/nova/nova.conf DEFAULT glance_host controller

openstack-config --set /etc/nova/nova.conf libvirt virt_type kvm

啓動服務:

service libvirtd start
 service messagebus start
 service openstack-nova-compute start
 chkconfig libvirtd on
 chkconfig messagebus on
 chkconfig openstack-nova-compute on

網絡服務配置

在controller端:

openstack-config --set /etc/nova/nova.conf DEFAULT \
network_api_class nova.network.api.API

openstack-config --set /etc/nova/nova.conf DEFAULT \
security_group_api nova

在computer01端:

yum install openstack-nova-network openstack-nova-api


# openstack-config --set /etc/nova/nova.conf DEFAULT \
network_api_class nova.network.api.API
# openstack-config --set /etc/nova/nova.conf DEFAULT \
security_group_api nova
# openstack-config --set /etc/nova/nova.conf DEFAULT \
network_manager nova.network.manager.FlatDHCPManager

# openstack-config --set /etc/nova/nova.conf DEFAULT \
firewall_driver nova.virt.libvirt.firewall.IptablesFirewallDriver

# openstack-config --set /etc/nova/nova.conf DEFAULT \
network_size 254
# openstack-config --set /etc/nova/nova.conf DEFAULT \
allow_same_net_traffic False
# openstack-config --set /etc/nova/nova.conf DEFAULT \
multi_host True
# openstack-config --set /etc/nova/nova.conf DEFAULT \
send_arp_for_ha True
# openstack-config --set /etc/nova/nova.conf DEFAULT \
share_dhcp_address True
# openstack-config --set /etc/nova/nova.conf DEFAULT \
force_dhcp_release True
# openstack-config --set /etc/nova/nova.conf DEFAULT \
flat_network_bridge br100
# openstack-config --set /etc/nova/nova.conf DEFAULT \
flat_interface eth1
# openstack-config --set /etc/nova/nova.conf DEFAULT \
public_interface eth0

nova network-create demo-net –bridge br100 –multi-host T \

–fixed-range-v4 88.8.8.16/28

而後使用nova net-list來查看:

建立虛擬機

一、配置ssh密碼登陸:

ssh-keygen

二、增長公鑰到openstack環境中:

nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-key

三、驗證是否配置成功:

nova keypair-list

nova flavor-list

四、建立實例:

複製代碼 代碼以下:

nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64 --nic netid=DEMO_NET_ID\
--security-group default --key-name demo-key demo-instance1

說明:

DEMO_NET_ID:指的是nova net-list的ID。

demo-instance1指的是虛擬機的名字。

例如個人成功執行以下:

  1.  
    nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64 --nic net-id=55fc305f-570f-4d4f-89d0-ce303e589f20 \
  2.  
    --security-group default --key-name demo-key tfjt

五、使用nova list進行查看。

從這裏咱們看到我這上面有一個ip地址192.168.44.17.這個地址就是浮動IP。

六、配置浮動IP

浮動ip

nova-manage floating create --ip_range=192.168.44.16/28

查看可用地址

nova-manage floating list

nova floating-ip-create

給建立的虛擬機綁定浮動ip,這個7bc0086…就是我以前建立的虛擬機的ID。後面接上IP地址便可。

nova add-floating-ip 7bc00086-1870-4367-9f05-666d5067ccff 192.168.44.17

監聽

cpdump -n -i eth0 icmp

在controller上:

nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

七、使用下面的命令能夠輸出一個url地址:

nova get-vnc-console tfjt novnc

八、咱們能夠在瀏覽器中進行訪問。

到這裏爲止,咱們的雲服務器就算完成了。能夠在瀏覽器上訪問咱們的雲服務器,怎麼樣是否是很激動。

界面服務(dashboard)

上面咱們能夠看到不少操做是在終端進行的,那麼確定是有界面版的,因此咱們在computer02中進行配置。

一、安裝服務

yum install memcached python-memcached mod_wsgi openstack-dashboard

二、文件配置。

在controller中

配置/etc/openstack-dashboard/local_settings。修改成以下內容。

ALLOWED_HOSTS = ['*']


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

OPENSTACK_HOST = "controller"

三、鏈接

setsebool -P httpd_can_network_connect on

service httpd start
# service memcached start
# chkconfig httpd on
# chkconfig memcached on

四、瀏覽器中訪問。

http://192.168.44.147/dashboard/project/

用戶名就是咱們以前配置的admin,密碼是ADMIN_PASS

在這個界面版裏面的各類操做我這裏就不細說了,能夠本身去體驗。

在這裏能夠看到咱們的雲服務器實例。

雲硬盤服務(cinder)

瞭解過阿里雲或者騰訊雲的就知道,裏面都有一個雲硬盤服務,能夠給咱們的機器增長磁盤。

在controller端:

yum stall openstack-cinde

openstack-config --set /etc/cinder/cinder.conf \
database connection mysql://cinder:CINDER_DBPASS@controller/cinder

mysql> CREATE DATABASE cinder;
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
IDENTIFIED BY 'CINDER_DBPASS';
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
IDENTIFIED BY 'CINDER_DBPASS';

建立數據庫表:

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

建立用戶並賦予角色:

$ keystone user-create --name=cinder --pass=CINDER_PASS--email=cinder@example.com
$ keystone user-role-add --user=cinder --tenant=service --role=admin

權限控制配置:

# openstack-config --set /etc/cinder/cinder.conf DEFAULT \
auth_strategy keystone
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_uri http://controller:5000
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_host controller
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_protocol http
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_port 35357
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_user cinder
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_tenant_name service
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_password CINDER_PASS

消息隊列配置:

# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT rpc_backend qpid
# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT qpid_hostname controller



$ keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"
$ keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volume / {print $2}') \
--publicurl=http://controller:8776/v1/%\(tenant_id\)s \
--internalurl=http://controller:8776/v1/%\(tenant_id\)s \
--adminurl=http://controller:8776/v1/%\(tenant_id\)s


$ keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storage v2"
$ keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volumev2 / {print $2}') \
--publicurl=http://controller:8776/v2/%\(tenant_id\)s \
--internalurl=http://controller:8776/v2/%\(tenant_id\)s \
--adminurl=http://controller:8776/v2/%\(tenant_id\)s


service openstack-cinder-api start
# service openstack-cinder-scheduler start
# chkconfig openstack-cinder-api on
# chkconfig openstack-cinder-scheduler on


cinder service-list
openstack-config --set /etc/cinder/cinder.conf \
DEFAULT qpid_hostname controller

cinder --debug list

keystone user-create --name=cinder --pass=CINDER_PASS --email=cinder@example.com


openstack-config --set /etc/cinder/cinder.conf \
DEFAULT my_ip 192.168.44.147

在node端(computer02)

pvcreate /dev/sdb
# vgcreate cinder-volumes /dev/sdb
 yum install openstack-cinder scsi-target-utils

# openstack-config --set /etc/cinder/cinder.conf DEFAULT \
auth_strategy keystone
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_uri http://controller:5000
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_host controller
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_protocol http
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
auth_port 35357
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_user cinder
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_tenant_name service
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken \
admin_password CINDER_PASS


# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT rpc_backend qpid
# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT qpid_hostname controller



# openstack-config --set /etc/cinder/cinder.conf \
database connection mysql://cinder:CINDER_DBPASS@controller/cinde



# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT my_ip MANAGEMENT_INTERFACE_IP_ADDRESS


# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT glance_host controller

# openstack-config --set /etc/cinder/cinder.conf \
DEFAULT iscsi_helper tgtadm

配置文件中:

vi /etc/tgt/targets.conf

include /etc/cinder/volumes/*

啓動服務:

# service openstack-cinder-volume start
# service tgtd start
# chkconfig openstack-cinder-volume on
# chkconfig tgtd on

建立磁盤:

cinder create --display-name myVolume 1

查看磁盤列表:

cinder list

而後再界面端查看雲硬盤的配置並進行掛載:

在雲服務器上掛載磁盤:

$ mkfs.ext3 /dev/vdb1

$ mkdir /mnt/test
$ mount /dev/vdb1 /mnt/test
$ mount

$ fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x64817ea3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
 p primary (0 primary, 0 extended, 4 free)
 e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048): +1G
Value out of range.
First sector (2048-2097151, default 2048): +512M
Last sector, +sectors or +size{K,M,G} (1048576-2097151, default 2097151): 
Using default value 2097151

Command (m for help): p

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: 0x64817ea3

 Device Boot Start End Blocks Id System
/dev/vdb1 1048576 2097151 524288 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
$ df -h

總結:整個操做流程很是複雜,我也是花了幾天才慢慢搭建好的,這其實也就是個基礎,給的實際上是一個思路,後面須要怎樣的擴展能夠根據本身的業務須要進行不一樣的設置。對於不明白的地方能夠查閱官方文檔。總之很複雜

相關文章
相關標籤/搜索