Ceph 文件系统部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ceph 文件系统部署相关的知识,希望对你有一定的参考价值。
参考技术A Ceph文件存储部署与使用1.安装client操作系统
(1)虚拟机基础设置
在VMware中创建一台虚拟机,操作系统为CentOS-7-x86_64-DVD-1908,硬盘大小为20G,并将虚拟机的名字设为client,如图7-10所示。
图7-10 虚拟机配置
(2)虚拟机网络设置
为虚拟机配置主机名:client。设置网络为NAT模式,配置IP地址:192.168.100.100,子网掩码为255.255.255.0,默认网关为192.168.100.2,DNS服务器为192.168.100.2,使虚拟机可以访问Internet。
2.配置Ceph文件系统
(1)部署MDS
在ceph-1节点中,将MDS部署到ceph-1节点
[root@ceph-1 ~]# cd /opt/osd
[root@ceph-1 osd]# ceph-deploy mdscreate ceph-1
(2)创建数据和存储池
在ceph-1节点为Ceph文件系统创建数据和元数据存储池。
[root@ceph-1 osd]# ceph osd poolcreate cephfs_data 64
pool 'cephfs_data' created
[root@ceph-1 osd]# ceph osd poolcreate cephfs_metadata 64
pool 'cephfs_metadata' created
(3)创建Ceph文件系统
在ceph-1节点创建ceph的文件系统cephfs。
[root@ceph-1 osd]# ceph fs newcephfs cephfs_metadata cephfs_data
new fs with metadata pool 2 anddata pool 1
(4)验证MDS和CephFS的状态
[root@ceph-1 osd]# ceph mds stat
cephfs:1 0=ceph-1=up:active
[root@ceph-1 osd]# ceph osd pool ls
rbd
.rgw.root
default.rgw.control
default.rgw.meta
default.rgw.log
.rgw
.rgw.control
.rgw.gc
.rgw.buckets
.rgw.buckets.index
.rgw.buckets.extra
.log
.intent-log
.usage
.users
.users.email
.users.swift
.users.uid
default.rgw.buckets.index
default.rgw.buckets.data
cephfs_data
cephfs_metadata
[root@ceph-1 osd]# ceph fs ls
name: cephfs, metadata pool:cephfs_metadata, data pools: [cephfs_data ]
(5)创建用户
在Ceph集群中创建用户client.cephfs,允许这个用户可以访问CephFS池。
[root@ceph-1 osd]# ceph authget-or-create client.cephfs mon 'allow r' mds 'allow r,allow rw path=/' osd'allow rw pool=cephfs_data' -o /etc/ceph/client.cephfs.keyring
[root@ceph-1 osd]# ceph-authtool -p-n client.cephfs /etc/ceph/client.cephfs.keyring > /etc/ceph/client.cephfs
[root@ceph-1 osd]# cat/etc/ceph/client.cephfs
AQA18Nldot+5DBAAQc4R6zbX+V6jBRINE4lJRA==
3、访问CephFS
(1)创建挂载点
[root@client ~]# mkdir/media/cephfs
(2)文件系统挂载
使用mount命令挂载CephFS文件系统
[root@client ~]# mount -t ceph192.168.100.101:6789:/ /media/cephfs -o name=cephfs,secret=AQA18Nldot+5DBAAQc4R6zbX+V6jBRINE4lJRA==
(3)查看挂载并解除挂载
[root@client ~]# mount | grep/media/cephfs
192.168.100.101:6789:/ on/media/cephfs type ceph(rw,relatime,name=cephfs,secret=,acl,wsize=16777216)
[root@client ~]# umount/media/cephfs
(4)通过文件挂载
为了更安全的挂载CephFS,防止在命令行历史中泄露密码,应该把密码存储在一个单独的文本文件中,然后把这个文件作为挂载命令的参数值。为了实现这个功能,需要在client节点安装ceph。
首先编辑ceph-1节点的hosts。
[root@ceph-1 osd]# vi /etc/hosts
192.168.100.100 client
192.168.100.101 ceph-1
192.168.100.102 ceph-2
192.168.100.103 ceph-3
(5)复制公钥
在ceph-1节点,将公钥复制到client节点。
[root@ceph-1 osd]# ssh-copy-idroot@client
/usr/bin/ssh-copy-id: INFO: Sourceof key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'client(192.168.100.100)' can't be established.
ECDSA key fingerprint isSHA256:XpUmb4kHGXWKkaTj44vITJDwBBApSk6Yo8ZunIEW010.
ECDSA key fingerprint isMD5:85:d3:f8:41:59:c4:a4:b4:c3:e9:71:2c:3b:45:0b:29.
Are you sure you want to continueconnecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO:attempting to log in with the new key(s), to filter out any that are alreadyinstalled
/usr/bin/ssh-copy-id: INFO: 1key(s) remain to be installed -- if you are prompted now it is to install thenew keys
root@client's password:
Number of key(s) added: 1
Now try logging into the machine,with: "ssh 'root@client'"
and check to make sure that onlythe key(s) you wanted were added.
(6)编辑yum文件
在client节点编辑YUM软件源配置文件
[root@client ~]# mkdir /opt/bak
[root@client ~]# cd/etc/yum.repos.d
[root@client yum.repos.d]# mv */opt/bak
将CentOS7-Base-163.repo通过SFTP复制到client节点的/etc/yum.repos.d目录。
[root@client yum.repos.d]# ls
CentOS7-Base-163.repo
[root@client yum.repos.d]# viceph.repo
[Ceph]
name=Ceph packages for $basearch
baseurl=http://mirrors.163.com/ceph/rpm-nautilus/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.163.com/ceph/rpm-nautilus/el7/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.163.com/ceph/rpm-nautilus/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
[root@client yum.repos.d]# yumclean all
[root@client yum.repos.d]# yummakecache
(7)安装ceph
在ceph-1节点,通过ceph-deploy将ceph安装到client节点。
[root@ceph-1 osd]# ceph-deployinstall --release=nautilus client
(8)生成密钥
在client节点生成密钥文件
[root@client ~]# echo AQA18Nldot+5DBAAQc4R6zbX+V6jBRINE4lJRA==> /etc/ceph/cephfskey
(9)使用secretfile参数挂载
[root@client ~]# mount -t ceph 192.168.100.101:6789://media/cephfs -o name=cephfs,secretfile=/etc/ceph/cephfskey
[root@client ~]# mount | grep/media/cephfs
192.168.100.101:6789:/ on/media/cephfs type ceph (rw,relatime,name=cephfs,secret=,acl,wsize=16777216)
[root@client ~]# umount/media/cephfs
(10)开机自动挂载
将参数按要求写入系统文件实现开机时自动挂载CephFS文件系统
[root@client ~]# vi /etc/fstab
192.168.100.101:6789://media/cephfs ceph name=cephfs,secretfile=/etc/ceph/cephfskey,_netdev,noatime 02
[root@client ~]# mount -a
[root@client ~]# mount | grep /media/cephfs
192.168.100.101:6789:/ on/media/cephfs type ceph(rw,noatime,name=cephfs,secret=,acl,wsize=16777216)
以上是关于Ceph 文件系统部署的主要内容,如果未能解决你的问题,请参考以下文章