minger

minger

Ceph安装使用记录

Ceph 安装记录#

一、准备工作#

机器列表:

ceph0 192.168.100.40

ceph1 192.168.100.41

ceph2 192.168.100.42

# 三台机器都需要配置
#  关闭防火墙
systemctl stop firewalld 
systemctl disable firewalld 
# 关闭SELinux
setenforce 0
# 关闭图形网络管理器
systemctl stop NetworkManager
systemctl disable NetworkManager 
# 配置主机名
hostnamectl set-hostname ceph0
# 修改hosts(用scp同步到其他节点)
vim /etc/hosts
192.168.100.40 ceph0
192.168.100.41 ceph1
192.168.100.42 ceph2
# 配置ssh免密登录
ssh-keygen
ssh-copy-id ceph0
ssh-copy-id ceph1
ssh-copy-id ceph2

配置 yum 源,并同步到其他节点

vim /etc/yum.repos.d/ceph.repo

[Ceph]
name=Ceph packages for $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-nautilus/el7/x86_64/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1

[Ceph-noarch]
name=Ceph noarch packages
baseurl=https://mirrors.tuna.tsinghua.edu.cn/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=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-nautilus/el7/SRPMS/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1

二、创建集群#

1. 创建集群配置目录#

mkdir /etc/ceph

2. 安装 ceph-deploy 部署工具#

yum -y install ceph-deploy

3. 创建 ceph 集群#

ceph-deploy new ceph0 ceph1 ceph2
# ls 
# 说明:
# ceph.conf 集群配置文件
# ceph-deploy-ceph.log 使用ceph-deploy部署的日志记录
# ceph.mon.keyring 验证key文件

4. 修改配置文件#

[global]
fsid = 913835ff-cc9b-45d7-a243-f3978d3e0c53
mon_initial_members = ceph0, ceph1, ceph2
mon_host = 192.168.100.40,192.168.100.41,192.168.100.42
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx

#对外开放网段
public network = 192.168.100.0/24

[mgr]
# 开启WEB仪表盘
mgr modules = dashboard

5. 安装 ceph#

ceph-deploy install ceph0 ceph1 ceph2
# 补充说明:如果网络不好的话,可以手动安装ceph和ceph-radosgw ,好的话可以可以用 ceph-deploy install ceph0    ceph1    ceph2 命令来安装。 ceph-deploy 命令会自动通过公网官方的源安装。

yum install ceph ceph-radosgw -y

6. 初始化 monitor#

ceph-deploy mon create-initial

7. 同步管理信息#

将配置文件信息同步到所有 ceph 集群节点

ceph-deploy admin ceph0 ceph1 ceph2

8. 安装 mgr#

管理守护进程,该组件的主要作用是分担和扩展 monitor 的部分功能,减轻 monitor 的负担,让更好地管理 ceph 存储系统,ceph dashboard 图形管理也需要用到 mgr

ceph-deploy mgr create  ceph0 ceph1 ceph2

9. 安装 rgw#

ceph-deploy rgw create ceph0 ceph1 ceph2

10. 创建 mds 服务#

ceph-deploy mds create ceph0 ceph1 ceph2

11. 使用 zap 命令清除磁盘信息准备创建 osd#

 ceph-deploy disk zap ceph0 /dev/vdb
 ceph-deploy disk zap ceph1 /dev/vdb
 ceph-deploy disk zap ceph2 /dev/vdb

12. 创建 OSD 磁盘#

ceph-deploy osd create --data /dev/sdb ceph0
ceph-deploy osd create --data /dev/sdb ceph1
ceph-deploy osd create --data /dev/sdb ceph2

13. 验证#

ceph -s 
[root@ceph0 ceph]# ceph -s 
  cluster:
    id:     913835ff-cc9b-45d7-a243-f3978d3e0c53
    health: HEALTH_OK
 
  services:
    mon: 3 daemons, quorum ceph0,ceph1,ceph2 (age 18h)
    mgr: ceph0(active, since 17h), standbys: ceph2, ceph1
    mds: cephfs:1 {0=ceph1=up:active} 2 up:standby
    osd: 3 osds: 3 up (since 18h), 3 in (since 18h)
 
  data:
    pools:   2 pools, 192 pgs
    objects: 106 objects, 335 MiB
    usage:   4.0 GiB used, 26 GiB / 30 GiB avail
    pgs:     192 active+clean

三、开启 dashboard#

1、开启 dashboard 模块#

ceph mgr module enable dashboard

报错:

Error ENOENT: all mgr daemons do not support module 'dashboard', pass --force to force enablement
解决:

yum -y install ceph-mgr-dashboard
那是因为没有安装 ceph-mgr-dashboard,在 mgr 节点上安装即可

2、生成签名#

ceph dashboard create-self-signed-cert

3. 生成证书#

openssl req -new -nodes -x509   -subj "/O=IT/CN=ceph-mgr-dashboard" -days 3650   -keyout dashboard.key -out dashboard.crt -extensions v3_ca

4. 启动服务#

ceph mgr module disable dashboard
 
ceph mgr module enable dashboard

5. 设置访问地址与端口#

ceph config set mgr mgr/dashboard/server_addr 192.168.100.40
 
ceph config set mgr mgr/dashboard/server_port 9001

6. 关闭 https#

ceph config set mgr mgr/dashboard/ssl false

7. 查看守护进程#

ceph mgr services

8. 设置管理面板登录凭证#

echo "1234567890" >> ceph-password.txt
ceph dashboard set-login-credentials admin -i ceph-password.txt
# 通过http://192.168.100.40:9001/访问

image-20230721162111692

四、使用 Ceph#

1、创建存储池#

ceph osd pool create cephfs_data 128

ceph osd pool create cephfs_metadata 64

rbd pool init cephfs_data # 初始化 RBD 池

rbd pool init cephfs_metadata

2、查看存储池#

ceph osd lspools

3、创建文件系统#

ceph fs new fs_test cephfs_metadata cephfs_data

4、查看文件系统#

ceph fs ls

5、查看 mds 状态#

ceph mds stat

五、测试挂载#

yum install ceph-fuse

cat ceph.client.admin.keyring 

echo “ABCrM7lkDYZ8GxAA7SkHF7gcZIsFMR47LA8bsB==” >> admin.key

mount -t ceph ceph2:6789:/ /mnt -o name=admin,secretfile=/root/admin.key
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。