现在的位置: 首页 > 综合 > 正文

Ubuntu 12.04 Ceph分布式文件系统之部署

2013年12月02日 ⁄ 综合 ⁄ 共 3609字 ⁄ 字号 评论关闭

二、   Ceph快速配置

资源:

两台机器:一台server,一台client,安装ubuntu12.04

其中,server安装时,另外分出两个区,作为osd0osd1的存储,没有的话,系统安装好后,使用loop设备虚拟出两个也可以。

步骤:

1、服务端安装CEPH  (MONMDSOSD)

2、添加keyAPT中,更新sources.list,安装ceph

#sudo wget -q -O- 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | sudo apt-key add -

#sudo echo deb http://ceph.com/debian/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list

# sudo apt-get update && sudo apt-get install ceph

3、查看版本

# ceph-v  //将显示ceph的版本和key信息

如果没有显示,请执行如下命令

# sudo apt-get update && apt-get upgrade

4、在/etc/ceph/下创建ceph.conf配置文件,并将配置文件拷贝到其它服务端

  1. [global] 
  2.  
  3.     # For version 0.55 and beyond, you must explicitly enable  
  4.     # or disable authentication with "auth" entries in [global]. 
  5.      
  6.     auth cluster required = none 
  7.     auth service required = none 
  8.     auth client required = none 
  9.  
  10. [osd] 
  11.     osd journal size = 1000 
  12.      
  13.     #The following assumes ext4 filesystem. 
  14.     filestore xattr use omap = true 
  15.  
  16.  
  17.     # For Bobtail (v 0.56) and subsequent versions, you may  
  18.     # add settings for mkcephfs so that it will create and mount 
  19.     # the file system on a particular OSD for you. Remove the comment `#`  
  20.     # character for the following settings and replace the values  
  21.     # in braces with appropriate values, or leave the following settings  
  22.     # commented out to accept the default values. You must specify the  
  23.     # --mkfs option with mkcephfs in order for the deployment script to  
  24.     # utilize the following settings, and you must define the 'devs' 
  25.     # option for each osd instance; see below. 
  26.  
  27.     osd mkfs type = xfs 
  28.     osd mkfs options xfs = -f   # default for xfs is "-f"    
  29.     osd mount options xfs = rw,noatime # default mount option is "rw,noatime" 
  30.  
  31.     # For example, for ext4, the mount option might look like this: 
  32.      
  33.     #osd mkfs options ext4 = user_xattr,rw,noatime 
  34.  
  35.     # Execute $ hostname to retrieve the name of your host, 
  36.     # and replace {hostname} with the name of your host. 
  37.     # For the monitor, replace {ip-address} with the IP 
  38.     # address of your host. 
  39.  
  40. [mon.a] 
  41.  
  42.     host = compute-01 
  43.     mon addr = 192.168.4.165:6789 
  44.  
  45. [osd.0] 
  46.     host = compute-02 
  47.      
  48.     # For Bobtail (v 0.56) and subsequent versions, you may  
  49.     # add settings for mkcephfs so that it will create and mount 
  50.     # the file system on a particular OSD for you. Remove the comment `#`  
  51.     # character for the following setting for each OSD and specify  
  52.     # a path to the device if you use mkcephfs with the --mkfs option. 
  53.      
  54.     devs = /dev/sda7 
  55.  
  56. [mds.a] 
  57.     host = compute-01 

5、创建目录

sudo mkdir -p /var/lib/ceph/osd/ceph-0

sudo mkdir -p /var/lib/ceph/osd/ceph-1

sudo mkdir -p /var/lib/ceph/mon/ceph-a

sudo mkdir -p /var/lib/ceph/mds/ceph-a

 

6、创建分区与挂载

fdisk  /dev/sda    //创建sda6分区

mkfs.xfs  -f /dev/sda7

mount  /dev/sda7  /var/lib/ceph/osd/ceph-0   (第一次必须先挂载分区写入初始化数据)

 

7、执行初始化

sudo mkcephfs -a -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.keyring

8、启动

# sudo service ceph -a start

9、执行健康检查

sudo ceph health

如果返回的是 HEALTH_OK,代表成功!

出现: HEALTH_WARN 576 pgs stuck inactive; 576 pgs
stuck unclean; no osds
之类的,请执行:

#ceph pg dump_stuck stale

#ceph pg dump_stuck inactive

#ceph pg dump_stuck unclean

再次健康检查是,应该是OK

 

注意:重新执行如下命令#sudo mkcephfs -a -c /etc/ceph/ceph.conf
-k ceph.keyring
前,所有服务端停止ceph服务在清空创建的四个目录/var/lib/ceph/osd/ceph-0/var/lib/ceph/osd/ceph-1/var/lib/ceph/mon/ceph-a/var/lib/ceph/mds/ceph-a

#/etc/init.d/ceph stop

# rm –frv /var/lib/ceph/osd/ceph-0/*

# rm –frv /var/lib/ceph/osd/ceph-1/*

# rm –frv /var/lib/ceph/mon/ceph-a/*

# rm –frv /var/lib/ceph/mds/ceph-a/*

三、   CephFS的使用

在客户端上操作:

sudo mkdir /mnt/mycephfs

sudo mount -t ceph {ip-address-of-monitor}:6789:/ /mnt/mycephfs

或者

sudo mkdir /home/{username}/cephfs

sudo ceph-fuse -m {ip-address-of-monitor}:6789 /home/{username}/cephfs

# df –h   查看

抱歉!评论已关闭.