Ceph 單/多節點 安裝小結 power by CentOS 6.x

來源:互聯網
上載者:User

標籤:ceph   storage   centos   

概述

Docs : http://docs.ceph.com/docs

Ceph是一個Distributed File System,在維持POSIX相容性的同時加入了複製和容錯功能。Ceph最大的特點是分布式的中繼資料服務器,通過CRUSH(Controlled Replication Under Scalable Hashing)這種擬演算法來分配檔案的location。Ceph的核心是RADOS(ReliableAutonomic Distributed Object Store),一個對象叢集儲存,本身提供對象的高可用、錯誤偵測和修複功能。

Ceph生態系統架構可以劃分為四部分:

client:用戶端(資料使用者)。client向外export出一個POSIX檔案系統介面,供應用程式調用,並串連mon/mds/osd,進行中繼資料及資料互動;最原始的client使用FUSE來實現的,現在寫到核心裡面了,需要編譯一個ceph.ko核心模組才能使用。
mon:叢集監視器,其對應的daemon程式為cmon(Ceph Monitor)。mon監視和管理整個叢集,對用戶端export出一個網路檔案系統,用戶端可以通過mount -t ceph monitor_ip:/ mount_point命令來掛載Ceph檔案系統。根據官方的說法,3個mon可以保證叢集的可靠性。
mds:中繼資料服務器,其對應的daemon程式為cmds(Ceph Metadata Server)。Ceph裡可以有多個MDS組成分布式中繼資料服務器叢集,就會涉及到Ceph中動態目錄分割來進行負載平衡。
osd:Object Storage Service叢集,其對應的daemon程式為cosd(Ceph Object StorageDevice)。osd將本地檔案系統封裝一層,對外提供Object Storage Service的介面,將資料和中繼資料作為Object Storage Service。這裡本地的檔案系統可以是ext2/3,但Ceph認為這些檔案系統並不能適應osd特殊的訪問模式,它們之前自己實現了ebofs,而現在Ceph轉用btrfs。

Ceph支援成百上千甚至更多的節點,以上四個部分最好分布在不同的節點上。當然,對於基本的測試,可以把mon和mds裝在一個節點上,也可以把四個部分全都部署在同一個節點上。


環境
hostname    ip             role           filesystem   release
master01    192.168.9.10   mon,mds,osd    xfs          CentOS release 6.7[2.6.32-573.8.1.el6.x86_64]
agent01     192.168.9.20   osd,[mon,mds]  xfs          CentOS release 6.7[2.6.32-573.8.1.el6.x86_64]
ocean-lab   192.168.9.70   client         xfs          CentOS release 6.7[4.3.0-1.el6.elrepo.x86_64]

版本
^_^[16:26:11][[email protected] ~]#ceph -v
ceph version 0.80.5 (38b73c67d375a2552d8ed67843c8a65c2c0feba6)


Repo
Epel
yum install ceph ceph-common python-ceph
yum install ceph-fuse        # for client

host 解析
192.168.9.10     master01.ocean.org   master01
192.168.9.20     agent01.ocean.org    agent01
192.168.9.70     ocean-lab.ocean.org  ocean-lab


Ceph 配置
^_^[16:26:15][[email protected] ~]#cat /etc/ceph/ceph.conf
[global]
public network = 192.168.9.0/24
pid file = /var/run/ceph/$name.pid
auth cluster required = none
auth service required = none
auth client required = none
keyring = /etc/ceph/keyring.$name
osd pool default size = 1
osd pool default min size = 1
osd pool default crush rule = 0
osd crush chooseleaf type = 1

[mon]
mon data = /var/lib/ceph/mon/$name
mon clock drift allowed = .15
keyring = /etc/ceph/keyring.$name

[mon.0]
host = master01
mon addr = 192.168.9.10:6789

[mds]
keyring = /etc/ceph/keyring.$name

[mds.0]
host = master01

[osd]
osd data = /ceph/osd$id
osd recovery max active = 5
osd mkfs type = xfs
osd journal = /ceph/osd$id/journal
osd journal size = 1000
keyring = /etc/ceph/keyring.$name

[osd.0]
host = master01
devs = /dev/sdc1
    
[osd.1]
host = master01
devs = /dev/sdc2


啟動ceph(在mon上執行)
初始化:
mkcephfs -a -c /etc/ceph/ceph.conf
/etc/init.d/ceph -a start

執行健全狀態檢查
ceph health            #也可以使用ceph -s命令查看狀態
如果返回的是HEALTH_OK,則代表成功!


掛載ceph
mount
升級系統核心
kernel 2.6.34以前的版本是沒有Module rbd的,把系統核心版本升級到最新
rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml  -y

安裝完核心後修改/etc/grub.conf設定檔使
修改設定檔中的 Default=1 to Default=0

驗證核心支援
#modprobe -l|grep ceph
kernel/fs/ceph/ceph.ko
kernel/net/ceph/libceph.ko
#modprobe  ceph
 
機器重啟後生效 init 6

mount -t ceph 192.168.9.10:6789:/ /mnt/ceph
[17:07:39][[email protected] ~]$ df -TH
Filesystem           Type   Size  Used Avail Use% Mounted on
/dev/mapper/vg_oceani-lv_root
                     ext4    30G  7.7G   21G  28% /
tmpfs                tmpfs  111M     0  111M   0% /dev/shm
/dev/sda1            ext4   500M   94M  375M  21% /boot
192.168.9.10:/data2  nfs     30G   25G  4.0G  87% /mnt/log
192.168.9.10:6789:/  ceph   172G  5.4G  167G   4% /mnt/ceph

ceph-fuse [未測]
mon推薦有至少3個,假如掛掉一個、服務也能正常使用
ceph-fuse -m 192.168.9.10:6789,192.168.9.20:6789 /mnt/ceph



10.1、增加OSD
這裡在agent01新增硬碟
[15:58:07][[email protected] ~]$ cat /etc/ceph/ceph.conf
[global]
public network = 192.168.9.0/24
pid file = /var/run/ceph/$name.pid
auth cluster required = none
auth service required = none
auth client required = none
keyring = /etc/ceph/keyring.$name
osd pool default size = 1
osd pool default min size = 1
osd pool default crush rule = 0
osd crush chooseleaf type = 1

[mon]
mon data = /var/lib/ceph/mon/$name
mon clock drift allowed = .15
keyring = /etc/ceph/keyring.$name

[mon.0]
host = master01
mon addr = 192.168.9.10:6789

[mds]
keyring = /etc/ceph/keyring.$name

[mds.0]
host = master01

[osd]
osd data = /ceph/osd$id
osd recovery max active = 5
osd mkfs type = xfs
osd journal = /ceph/osd$id/journal
osd journal size = 1000
keyring = /etc/ceph/keyring.$name

[osd.2]
host = agent01
devs = /dev/sdc1

[osd.3]
host = agent01
devs = /dev/sdc2


master01 ~ $ cd /etc/ceph; scp keyring.client.admin  agent01:/etc/ceph/
以下操作都在新增OSD節點上操作
初始化新增osd節點,需要在新增的節點機器上運行,這裡在10.2.180.180上運行
ceph-osd -i 2 --mkfs --mkkey;
ceph-osd -i 3 --mkfs --mkkey;

加入節點
ceph auth add osd.2 osd ‘allow *‘ mon ‘allow rwx‘ -i /etc/ceph/keyring.osd.2;
ceph auth add osd.3 osd ‘allow *‘ mon ‘allow rwx‘ -i /etc/ceph/keyring.osd.3;
ceph osd create #added key for osd.2
ceph osd create #added key for osd.3
ceph osd rm osd_num    # 刪除osd

/etc/init.d/ceph -a start osd.2 #啟動osd.2
/etc/init.d/ceph -a start osd.3 #啟動osd.3
/etc/init.d/ceph -a start osd   #啟動所有osd
ceph -s #查看狀態
ceph auth list #能查看所有認證節點



增加MDS
增加agent01 MDS到節點
將以下配置增加到設定檔,並同步到節點
[mds.1]
host = agent01
以下操作都在新增OSD節點上操作
產生key
ceph-authtool --create-keyring --gen-key -n mds.1 /etc/ceph/keyring.mds.1
加入認證
ceph auth add mds.1 osd ‘allow *‘ mon ‘allow rwx‘ mds ‘allow‘ -i /etc/ceph/keyring.mds.1
啟動新增MDS
/etc/init.d/ceph -a start mds.1



增加MON
增加agent01 MDS到節點

將以下配置增加到設定檔,並同步到節點
[mon.1]
host = agent01
mon addr = 192.168.9.20:6789

匯出key及mon map
mkdir /tmp/ceph
ceph auth get mon. -o /tmp/ceph/keyring.mon
ceph mon getmap -o /tmp/ceph/monmap

初始化新mon
ceph-mon -i 1 --mkfs --monmap /tmp/ceph/monmap --keyring /tmp/ceph/keyring.mon

啟動新mon
ceph-mon -i 1 --public-addr 192.168.9.20:6789

加入quorum votes
ceph mon add 1 192.168.9.20:6789

本文出自 “Jeffrey Blog” 部落格,請務必保留此出處http://oceanszf.blog.51cto.com/6268931/1716896

Ceph 單/多節點 安裝小結 power by CentOS 6.x

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.