centos6安裝sheepdog 虛擬機分佈式儲存

前言

sheepdog是一個專門爲qemu設計的虛擬機分佈式文件系統,採用徹底對稱的結構,沒有元數據服務的中心節點,所以免除了單點故障的隱患.本文基於最新的0.7.0版本測試,介紹sheepdog的安裝配置和使用.node

sheepdog的後端集羣管理

sheepdog的後端集羣管理用於管理節點間的成員關係和消息通信.目前可以使用四種模式,分別是local driver(用於單機測試),corosync (默認), zookeeper and Accord.git

分爲兩種模型: github

– 全對稱 (依賴 Corosync ,運行於 Sheepdog 的地址空間)後端

● 缺點:規模小 [<100]centos

● 優勢:無需配置分佈式

– 單獨的控制集羣 (依賴 Accord* 或者 Zookeeper ,運行於獨立地址空間)oop

● 缺點:須要配置控制集羣測試

● 優勢:規模大 [>1000]spa

本測試使用的就是默認的Corosync模式.debug

 

安裝前準備:

先作一些系統設置

  
echo " * soft nofile 65533 " >> / etc / security / limits . conf echo " * hard nofile 65533 " >> / etc / security / limits . conf yum install -y make automake autoconf gcc nss-devel wget git glib2

安裝epel源

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

 

安裝sheepdog

1).安裝corosync

centos6自帶的版本過舊,咱們須要安裝新版

  
yum remove corosync corosynclib corosynclib-devel -y git clone git: // github . com / corosync / corosync . git cd corosync git checkout -b flatiron origin / flatiron ./ autogen . sh ./ configure --enable-nss make install

 

2).安裝sheepdog

  
cd / home2 / install git clone git: // github . com / collie / sheepdog . git cd sheepdog ./ autogen . sh ./ configure make install

 

配置corosync和sheepdog

  
cd / etc / corosync cp corosync . conf . example corosync . conf

編輯corosync.conf修改bindnetaddr成你的網段如192.168.1.0

  
# Please read the corosync . conf 5 manual page compatibility: whitetank totem { version: 2 secauth: off threads : 0 # Note , fail_recv_const is only needed if you're # having problems with corosync crashing under # heavy sheepdog traffic . This crash is due to # delayed / resent / misordered multicast packets . # fail_recv_const: 5000 interface { ringnumber: 0 bindnetaddr: 192.168 . 1.0 mcastaddr: 226.94 . 1.1 mcastport: 5405 } } logging { fileline: off to_stderr: no to_logfile: yes to_syslog: yes # the pathname of the log file logfile: / var / log / cluster / corosync . log debug : off timestamp: on logger_subsys { subsys: AMF debug : off } } amf { mode : disabled }

啓動服務

  
/ etc / init . d / corosync start # 或經過命令啓動 (/ var / lib / sheepdog是sheepdog使用的數據目錄 , 你能夠更改到其餘 ) # sheep / var / lib / sheepdog

 

sheepdog要求/var/lib/sheepdog目錄所在的分區支持xattr

  
mount -o remount , user_xattr /

以上操做須要在每一臺sheepdog節點執行

 

格式化sheepdog集羣並設置3個副本,只須要在其中一臺節點執行

  
collie cluster format --copies = 3

查看節點狀態

  
collie node list

至此sheepdog集羣已經配置完畢

使用qemu-img建立sheepdog磁盤鏡像

因爲centos6自帶的qemu1.2版本並不支持sheepdog,這裏要編譯新版的qemu.

安裝依賴的包

 
  
    
    
    
    
  
   
yum install zlib-devel glib2-devel -y

編譯qemu

 
  
    
    
    
    
  
   
wget http: // wiki . qemu-project . org / download / qemu- 1.5 . 2 . tar . bz2 tar jxvf qemu- 1.5 . 2 . tar . bz2 cd qemu- 1.5 . 2 ./ configure make ; make install

建立磁盤

  
/ usr / local / bin / qemu-img create -f qcow2 sheepdog :MyFirstDisk 10G

若是sheepdog運行在其餘機器上,須要指定IP和端口

  
/ usr / local / bin / qemu-img create -f qcow2 sheepdog: 192.168 . 1.100 : 7000 :MyFirstDisk 10G

列出sheepdog裏的鏡像

  
collie vdi list

將現有的鏡像轉換到sheepdog裏

  
qemu-img convert ./ mysystem . raw sheepdog :mysystem

啓動虛擬機

  
qemu-system-x86_64 --enable-kvm -m 1024 -drive file = sheepdog :MyFirstDisk , cache = writeback -vnc : 15 -cdrom / data / CentOS- 6.4 -i386-minimal . iso

 

其餘用法

1)建立快照

  
qemu-img snapshot -c name sheepdog :MyFirstDisk

快照建立後查看鏡像列表

  
collie vdi list name id size used shared creation time object id -------------------------------------------------------------------- Bob 0 2.0 GB 1.6 GB 0.0 MB 2010 - 03 - 23 16 : 16 80000 MyFirstDisk 0 256 GB 0.0 MB 0.0 MB 2010 - 03 - 23 16 : 21 c0000 s MyFirstDisk 1 256 GB 0.0 MB 0.0 MB 2010 - 03 - 23 16 : 16 40000

用快照啓動虛擬機

  
qemu-system-x86_64 sheepdog :MyFirstDisk : 1

2)磁盤克隆

  
qemu-img create -b sheepdog :MyFirstDisk sheepdog :Disk2

3)關閉sheepdog集羣

  
collie cluster shutdown

此命令會關閉全部節點的進程

 

4)使用fuse掛載sheepdog

首先創建一個名爲my_volume的卷

  
echo my_volume > / var / lib / sheepdog / vdi / mount

格式化爲ext4並掛載

  
mkfs . ext4 / var / lib / sheepdog / volume / my_volume mount -o loop / var / lib / sheepdog / volume / my_volume / mnt

當鏈接的sheepdog機器宕機咱們能夠在線切換到另外一臺sheepdog

  
echo ip :port > / var / lib / sheepdog / config / sheep_info
相關文章
相關標籤/搜索