openstack I版的搭建一十--基於glusterfs的雲硬盤

計算節點和控制節點上都安裝一下

cd /etc/yum.repos.d/

wget http://download.gluster.org/pub/gluster/glusterfs/3.4/3.4.3/CentOS/glusterfs-epel.repo

yum install glusterfs-server

驗證一下兩個節點是否安裝成功

[root@linux-node1 ~]# glusterfs -V

glusterfs 3.4.5 built on Jul 24 2014 19:11:45

Repository revision: git://git.gluster.com/glusterfs.git

Copyright (c) 2006-2013 Red Hat, Inc. <http://www.redhat.com/>

GlusterFS comes with ABSOLUTELY NO WARRANTY.

It is licensed to you under your choice of the GNU Lesser

General Public License, version 3 or any later version (LGPLv3

or later), or the GNU General Public License, version 2 (GPLv2),

in all cases as published by the Free Software Foundation.


[root@linux-node2 yum.repos.d]# glusterfs -V

glusterfs 3.4.5 built on Jul 24 2014 19:11:45

Repository revision: git://git.gluster.com/glusterfs.git

Copyright (c) 2006-2013 Red Hat, Inc. <http://www.redhat.com/>

GlusterFS comes with ABSOLUTELY NO WARRANTY.

It is licensed to you under your choice of the GNU Lesser

General Public License, version 3 or any later version (LGPLv3

or later), or the GNU General Public License, version 2 (GPLv2),

in all cases as published by the Free Software Foundation.

啓動



[root@linux-node1 ~]# /etc/init.d/gluster

glusterd    glusterfsd  

[root@linux-node1 ~]# /etc/init.d/glusterd start

Starting glusterd:                                         [確定]


[root@linux-node2 ~]# /etc/init.d/glusterd start

Starting glusterd:                                         [確定]



[root@linux-node1 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.33.11 linux-node1.openstack.com linux-node1

192.168.33.12 linux-node2.openstack.com linux-node2

[root@linux-node2 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.33.12 linux-node2.openstack.com linux-node2

192.168.33.11 linux-node1.openstack.com linux-node1



[root@linux-node1 ~]# mkdir /data/gg1

[root@linux-node2 ~]# mkdir /data/gg2

咱們創建一個複製的卷,複製兩份


[root@linux-node2 ~]# gluster peer detach linux-node1.openstack.com

peer detach: success

[root@linux-node2 ~]# gluster peer status

peer status: No peers present


把另外一個節點加入到集羣

把node1加入集羣


glusterfs無中心的,對等的。

[root@linux-node2 ~]# gluster peer probe linux-node1.openstack.com

peer probe: success

[root@linux-node2 ~]# gluster peer status

Number of Peers: 1


Hostname: linux-node1.openstack.com

Port: 24007

Uuid: af7dd374-12c0-4201-8415-fe1a1e22f851

State: Peer in Cluster (Connected)

[root@linux-node2 ~]# gluster volume create demo replica 2 linux-node1.openstack.com:/data/gg1 linux-node2.openstack.com:/data/gg2 force

volume create: demo: success: please start the volume to access data


啓動卷

[root@linux-node2 ~]# gluster vol start demo

volume start: demo: success


我們查看一下,我們可以看到,你的數據是放兩份的

[root@linux-node2 ~]# gluster vol info

 

Volume Name: demo

Type: Replicate

Volume ID: ced081c2-a4de-4f00-8260-5fc0fb36ea9f

Status: Started

Number of Bricks: 1 x 2 = 2

Transport-type: tcp

Bricks:

Brick1: linux-node1.openstack.com:/data/gg1

Brick2: linux-node2.openstack.com:/data/gg2


我們要用這個卷,我們該怎麼辦?該修改配置文件

1830gg 

volume_driver=cinder.volume.drivers.glusterfs.GlusterfsDriver

1107 

glusterfs_shares_config=/etc/cinder/glusterfs_shares

1120 

glusterfs_mount_point_base=$state_path/mnt



我們要先把NFS卸載掉

umount 192.168.33.11:/data/nfs

查看一下

mount


重啓一下cinder的相關服務

[root@linux-node1 ~]# for i in {api,scheduler,volume};do /etc/init.d/openstack-cinder-$i restart;done

停止 openstack-cinder-api:                                [確定]

正在啓動 openstack-cinder-api:                            [確定]

停止 openstack-cinder-scheduler:                          [確定]

正在啓動 openstack-cinder-scheduler:                      [確定]

停止 openstack-cinder-volume:                             [確定]

正在啓動 openstack-cinder-volume:                         [確定]

[root@linux-node1 ~]# mount

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

nfsd on /proc/fs/nfsd type nfsd (rw)

192.168.33.11:/demo on /var/lib/cinder/mnt/4ac2acc000ff60653979b4a905bdecb3 type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)



創建雲硬盤

wKioL1P9kbuS-EJoAAIWh8xvQ_k956.jpg

wKioL1P9kc2j4eixAAE_KbtOQI4026.jpg

wKioL1P9kdnCj9egAAJWqJtjQ_0280.jpg

我們查看一下雲硬盤都存在哪

[root@linux-node1 ~]# cat /etc/cinder/glusterfs_shares

192.168.33.11:/demo

[root@linux-node1 ~]# mount

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

nfsd on /proc/fs/nfsd type nfsd (rw)

192.168.33.11:/demo on /var/lib/cinder/mnt/4ac2acc000ff60653979b4a905bdecb3 type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)

[root@linux-node1 ~]# ll /var/lib/cinder/mnt/4ac2acc000ff60653979b4a905bdecb3

總用量 4

-rw-rw-rw- 1 root root 1073741824 8月  27 15:58 volume-ca55ee76-956c-4fb6-96ce-d0a5d1f45aa9

[root@linux-node1 ~]# ll /data/gg1/

總用量 4

-rw-rw-rw- 2 root root 1073741824 8月  27 15:58 volume-ca55ee76-956c-4fb6-96ce-d0a5d1f45aa9


[root@linux-node2 ~]# ll /data/gg2/

總用量 4

-rw-rw-rw- 2 root root 1073741824 8月  27 15:58 volume-ca55ee76-956c-4fb6-96ce-d0a5d1f45aa9

一共有三份

掛載到虛擬機實例上


wKiom1P9kmGwR_SRAAKDmxVmfgs454.jpg

wKiom1P9ksnRS2bPAAEFICE8brE125.jpg

wKioL1P9lBGi2CFmAAJiKTlziVY428.jpg

wKioL1P9lJigmoHfAAOZacWcmPw271.jpg

wKiom1P9lV3CGi0rAAIshzyid10839.jpg

接下來,我們要對這塊硬盤進行格式化

sudo fdisk /dev/vdb

wKiom1P9lXDytfQnAAJIylfvj-M662.jpgwKioL1P9lqHxV0x2AAG7mfexsy8860.jpg

sudo mkfs.ext3 /dev/vdb1

wKiom1P9llmBN9eqAAHkxW6bLtc495.jpg

wKioL1P9l8rx0ftPAABfVGdo6kw096.jpg

本地文件系統是最好的。

萬兆網卡


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章