码迷,mamicode.com
首页 > 其他好文 > 详细

Ceph 单/多节点 安装小结 power by CentOS 6.x

时间:2015-11-26 01:30:54      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:ceph   storage   centos   

概述

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

Ceph是一个分布式文件系统,在维持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:对象存储集群,其对应的daemon程序为cosd(Ceph Object StorageDevice)。osd将本地文件系统封装一层,对外提供对象存储的接口,将数据和元数据作为对象存储。这里本地的文件系统可以是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][root@master01 ~]#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][root@master01 ~]#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][root@ocean-lab ~]$ 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][root@agent01 ~]$ 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

标签:ceph   storage   centos   

原文地址:http://oceanszf.blog.51cto.com/6268931/1716896

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!