Contents [hide] |
---|
參考
- MOUNT.CEPH – MOUNT A CEPH FILE SYSTEM
- MMOUNT CEPH FS WITH THE KERNEL DRIVER
- MOUNT CEPH FS AS A FUSE
- MOUNT CEPH FS IN YOUR FILE SYSTEMS TABLE
ceph端口訪問控制
成都ceph環境做為數據備份空間,因未啟用授權機制,為確保數據安全,現已添加端口訪問控制。
若需增加訪問點請在172.17.35.241:/usr/local/bin/default.iptables中進行設置:
1
2
3
4
5
6
7
8
9
|
# 若增加ceph節點,請將節點ip添加到LAN_IPs中
LAN_IPs=172.17.35.240,172.17.35.241,172.17.35.242,172.17.35.243
# 若增加訪問客戶端,請將客戶端IP添加到CEPH_IPs中
CEPH_IPs=
"$NMC_IPs,172.17.46.0/24"
CEPH_IPs=
"$CEPH_IPs,192.168.0.131,192.168.0.133,192.168.0.233,192.168.0.23,192.168.0.247"
# 修改完成default.iptables后,執行下面的命令加載策略:
setiptables.sh load default.iptables
|
用Kernel方式掛載
該方式需要更換系統內核、並重啟系統以支持ceph文件系統掛載。
經試用以方式掛載后,存在某些目錄丟失,重新mount后丟失目錄又出現的現象,而使用fuse方式掛載未發生這一現象。
安裝ELRepo及kernel-lt
1
2
3
4
5
6
7
8
9
10
11
12
|
# 首先你要做的就是導入public key
#rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm --
import
http:
//www
.elrepo.org
/RPM-GPG-KEY-elrepo
.org
# 然后安裝ELRepo到CentOS-6.5中
rpm -ivh http:
//www
.elrepo.org
/elrepo-release-6-5
.el6.elrepo.noarch.rpm
# 安裝kernel-lt(lt=long-term)
yum --enablerepo=elrepo-kernel
install
kernel-lt -y
# 你也可以裝kernel-ml(ml=mainline)kernel-lt、kernel-mt二者選一個就可以了!
#yum --enablerepo=elrepo-kernel install kernel-ml -y
|
修改Grub引導順序並重啟動
vim/etc/grub.conf
設置default值(從0開始),一般新安裝的內核在第一個位置,所以設置default=0。
目前內核為:title CentOS (3.10.59-1.el6.elrepo.x86_64)
重啟,這時候你的內核就成功升級了,你可以刪除你的舊內核了!
- 重啟后內核為:
uname -a Linux yunwei2.timait 3.10.59-1.el6.elrepo.x86_64 #1 SMP Thu Oct 30 23:46:31 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
- 重啟失敗參考(經在192.168.0.82上測試此方法無效)
CentOS 6 will not boot on KVM with elrepo kernel 3.13 / 3.14
You can work around it by booting into your working stock kernel and running these two commands:
1
2
|
yum
install
-y device-mapper-libs libudev
for
X
in
$(
cd
/boot
;
ls
-1 config-*elrepo* |
sed
's/config-//'
) ;
do
dracut --add-drivers virtio_blk -f
/boot/initramfs-
$X.img $X ;
done
|
添加ceph源
公司內部源、第三方源選擇添加一個即可。
- 公司內部源
內部源ceph版本為:0.67.5-16.g69a99e6.el6
1
2
3
4
5
6
|
cat
>
/etc/yum
.repos.d
/nailgun
.repo <<EOF
[nailgun]
name=Nailgun
baseurl=http:
//172
.17.45.15:8080
/centos/fuelweb/x86_64/
gpgcheck=0
EOF
|
- 第三方源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# ceph_release
# v0.67.9 dumpling
# v0.87 giant
ceph_release=giant
# distro:CentOS 6.4是el6
distro=el6
cat
>
/etc/yum
.repos.d
/ceph
.repo <<EOF
[ceph]
name=Ceph packages
for
\$basearch
baseurl=http:
//ceph
.com
/rpm-
${ceph_release}/${distro}/\$basearch
enabled=1
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
[ceph-noarch]
name=Ceph noarch packages
baseurl=http:
//ceph
.com
/rpm-
${ceph_release}/${distro}
/noarch
enabled=1
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
[ceph-
source
]
name=Ceph
source
packages
baseurl=http:
//ceph
.com
/rpm-
${ceph_release}/${distro}
/SRPMS
enabled=0
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
EOF
cat
>
/etc/yum
.repos.d
/ceph-extras
.repo <<EOF
[ceph-extras]
name=Ceph Extras Packages
baseurl=http:
//ceph
.com
/packages/ceph-extras/rpm/centos6/
\$basearch
enabled=1
priority=2
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
[ceph-extras-noarch]
name=Ceph Extras noarch
baseurl=http:
//ceph
.com
/packages/ceph-extras/rpm/centos6/noarch
enabled=1
priority=2
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
[ceph-extras-
source
]
name=Ceph Extras Sources
baseurl=http:
//ceph
.com
/packages/ceph-extras/rpm/centos6/SRPMS
enabled=1
priority=2
gpgcheck=1
type
=rpm-md
gpgkey=https:
//ceph
.com
/git/
?p=ceph.git;a=blob_plain;f=keys
/release
.asc
EOF
# 加載一個第三方依賴的repo、下載ceph
rpm -Uvh http:
//dl
.fedoraproject.org
/pub/epel/6/x86_64/epel-release-6-8
.noarch.rpm
|
安裝ceph客戶端
1
|
yum -y
install
ceph
|
[root@FTP-Maven ~]# rpm -qa|grep ceph libcephfs1-0.67.5-16.g69a99e6.el6.x86_64 python-ceph-0.67.5-16.g69a99e6.el6.x86_64 ceph-0.67.5-16.g69a99e6.el6.x86_64
掛載ceph卷
- 命令行掛載
1
2
|
mkdir
-p
/cephdata
mount
-t ceph 172.17.35.241:6789:/
/cephdata
|
- 添加/etc/fstab自動掛載
1
2
|
#172.17.35.241:6789:/ /cephdata
172.17.35.241:6789:/
/cephdata
ceph defaults 0 0
|
- 注意:開啟SELinux可能引起掛載ceph卷后進入子目錄報沒有權限錯誤。
fuse方式掛載ceph卷
因ceph-fuse使用64位的inode,在32位系統中會出現問題,因此僅限在64位系統中使用。
安裝epel源
1
2
3
|
yum -y
install
epel-release
# epel-release-6-8.noarch
|
若安裝后yum工作異常,修改/etc/yum.repos.d/epel.repo,取消mirrorlist、啟用baseurl即可。
安裝ceph-fuse
1
2
3
4
5
6
7
|
yum -y
install
ceph-fuse
# ceph-0.80.5-9.el6.x86_64
# ceph-common-0.80.5-9.el6.x86_64
# libcephfs1-0.80.5-9.el6.x86_64
# python-ceph-0.80.5-9.el6.x86_64
# ceph-fuse-0.80.5-9.el6.x86_64
|
測試掛載ceph卷
1
2
3
4
|
mkdir
/mnt/cephdata_backups
ceph-fuse -m 172.17.35.241:6789 -r
/backups
/mnt/cephdata_backups
umount
/mnt/cephdata_backups
|
通過fstab自動掛載
- ceph-fuse掛載腳本bug修復:/sbin/mount.fuse.ceph
1
2
3
|
# convert device string to options
#cephargs='--'`echo $1 | sed 's/,/ --/g'`
cephargs=
'-'
`
echo
$1 |
sed
-e
's/,/ -/g'
-e
's/=/ /g'
`
|
- 建立掛載點目錄
1
|
mkdir
-p
/mnt/cephdata_backups
|
- 設置/etc/fstab
1
2
|
# 設置掛載ceph中的backups目錄
m=172.17.35.241:6789,r=
/backups
/mnt/cephdata_backups
fuse.ceph defaults 0 0
|
- 測試掛載、卸載
1
2
3
|
mount
/mnt/cephdata_backups
umount
/mnt/cephdata_backups
|
- 基於ceph集群未正常的情況下,openstack集群開機自mount時該機器會無法啟動,當前先去掉該自動mount,改為手動方式