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