当前位置: > CentOS > CentOS教程 >

CentOS 7安装 Ceph

时间:2015-03-15 01:59来源:linux.it.net.cn 作者:IT
CentOS 7  x64 安装 Ceph


二, 实验环境

节点            IP                 主机名                  系统

MON         172.24.0.13           ceph-mon0             CentOS 7 X64
MDS         172.24.0.13           ceph-mds0             CentOS 7 X64
OSD0        172.24.0.14           ceph-osd0             CentOS 7 X64 
OSD1        172.24.0.14           ceph-osd1             CentOS 7 X64


client     


三、安装步骤

1、首先建立机器SSH互信关系

生成密钥
ssh-keygen -t rsa -P ''
ssh-keygen -t rsa -f .ssh/id_rsa -P ''

向被授权的主机上拷贝

ssh-copy-id -i .ssh/id_rsa.pub root@主机

--------------------------------------------------------
ssh-copy-id -i .ssh/id_rsa.pub root@172.24.0.13
ssh-copy-id -i .ssh/id_rsa.pub root@172.24.0.14
--------------------------------------------------------


配置所有主机时间同步

安装ntpdate
yum -y install ntpdate

开始同步时间
ntpdate time.windows.com


修改每台机器的主机名 (hostname)  ( mon,mds,osd,client 都必须设置 )
------------------------------------------------------------------------------------
echo 172.24.0.13 ceph-mon0 >> /etc/hosts
echo 172.24.0.13 ceph-mds0 >> /etc/hosts
echo 172.24.0.14 ceph-osd0 >> /etc/hosts
echo 172.24.0.14 ceph-osd1 >> /etc/hosts
------------------------------------------------------------------------------------


yum更新,安装相关依赖包(适用于mon,mds,osd)    
-------------------------------------------------------------------------------------
rpm --import 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc'
rpm -Uvh http://mirrors.yun-idc.com/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum install snappy leveldb gdisk python-argparse gperftools-libs -y
rpm -Uvh http://ceph.com/rpm-dumpling/el7/noarch/ceph-release-1-0.el7.centos.noarch.rpm
yum install ceph-deploy -y
yum install ceph -y

yum install btrfs-progs           (适用于所有osd)
-------------------------------------------------------------------------------------


配置/etc/ceph/ceph.conf,  (适用于mon,mds,osd)

vi /etc/ceph/ceph.conf

------------------------------------------------------------------------------------------------
[global]
public network = 172.24.0.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 = ceph-mon0
mon addr = 172.24.0.13:6789
[mds]
keyring = /etc/ceph/keyring.$name
[mds.0]
host = ceph-mds0
[osd]
osd data = /mnt/osd$id
osd recovery max active = 5
osd mkfs type = xfs
osd journal = /mnt/osd$id/journal
osd journal size = 1000
keyring = /etc/ceph/keyring.$name
[osd.0]
host = ceph-osd0
devs = /dev/mapper/centos-osd0
[osd.1]
host = ceph-osd1
devs = /dev/mapper/centos-osd1
----------------------------------------------------------------------------------------------------

创建目录 ( osd )

mkdir /mnt/osd0
mkdir /mnt/osd1



启动ceph(在mon上执行)

初始化:
mkcephfs -a -c /etc/ceph/ceph.conf
/etc/init.d/ceph -a start


( #遇到 Error ENOENT: osd.0 does not exist.  create it before updating the crush map ) 执行如下代码:

ceph osd create

然后在执行   /etc/init.d/ceph -a start       既可完成




执行健康检查
ceph health      #也可以使用ceph -s命令查看状态  (如果返回的是HEALTH_OK,则代表成功!)


挂载ceph  (172.24.0.15 为客户端)

mon推荐有至少3个,假如挂掉一个、服务也能正常使用

client0的CentOS7默认没有开启ceph_fs的内核,需要更改内核,这里直接用yum更新(可以手工编译)

使用elrepo提供的, 已经编译好的内核

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum install -y yum-plugin-fastestmirror
yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel
grub2-set-default 0
reboot 重启服务器

mkdir /opt/ceph
1.  ceph-fuse -m 172.24.0.13:6789 /opt/ceph

2.  mount -t ceph 172.24.0.13:6789/ /opt/ceph

#这里的密钥,是mon /etc/ceph/ keyring.client.admin 中的内容。

多个 mon 可使用,号分开 如:ceph-fuse -m 172.24.0.13:6789,172.24.0.14:6789,172.24.0.15:6789 /opt/ceph



(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容