ceph集群安装记录

一、准备工作

1.参考文档

  • ceph官方文档:https://docs.ceph.com/en/latest/install/
  • ceph中文文档:http://docs.ceph.org.cn/start/
  • ceph看云:https://www.kancloud.cn/willseecloud/ceph/1788233

2.配置说明

  • 主机:3台主机node1~ node3,node1为管理节点
操作系统 内核版本 主机名 网段IP 磁盘 服务
centos 7.9 3.10.0 node1 10.0.8.116 系统盘: sda;osd盘: sdb mon1,osd0,rgw1,mds1,mgr1,dashboard,smb-server
centos 7.9 3.10.0 node2 10.0.8.159 系统盘: sda;osd盘: sdb mon2,osd1,rgw2
centos 7.9 3.10.0 node3 10.0.8.122 系统盘: sda;osd盘: sdb mon3,osd2,rgw3,fs-client,block-client
windows10 - - 10.0.6.229 - smb-client(fs-client)
  • 操作系统版本:centos 7.9 内核版本:3.10.0
  • ceph版本:Nautilus 14.2.22
  • 服务IP及端口
服务 访问IP 端口
对象存储 10.0.8.116 7480
文件系统 10.0.8.116 6789
块存储 10.0.8.116 3260
仪表盘 10.0.8.116 8443

3.服务器配置

  • 安装操作系统,设置网络
1
2
3
4
5
vim /etc/sysconfig/network-scripts/ifcfg-{iface}
【内容】【修改】
ONBOOT=yes

service network restart
  • 设置主机名,配置hosts支持主机名互访
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#设置主机名
sudo hostnamectl set-hostname node1
sudo hostnamectl set-hostname node2
sudo hostnamectl set-hostname node3

#设置host
vim /etc/hosts
【内容】
10.0.8.116 node1
10.0.8.159 node2
10.0.8.122 node3
  • 关闭firewalle,iptables和selinux
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
service iptables stop
service iptables status

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
reboot
/usr/sbin/sestatus -v
  • 时钟同步(https://www.cnblogs.com/quchunhui/p/7658853.html)
 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
#安装服务
sudo yum -y install ntp ntpdate ntp-doc

//同步阿里云
ntpdate ntp1.aliyun.com

//clock -w把当前系统时间写入到CMOS中
clock -w

#修改配置文件
vim /etc/ntp.conf
【内容】
restrict 10.0.8.116 nomodify notrap nopeer noquery     //当前节点IP地址
restrict 10.0.8.116 mask 10.0.8.1 nomodify notrap  //集群所在网段的网关(Gateway),子网掩码(Genmask)
【内容】主节点  ,在server部分添加如下部分,并注释掉server 0 ~ n
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
【内容】其他节点,在server部分添加如下语句,并注释掉server 0 ~ n,将server指向主节点。
server 10.0.8.116
Fudge 10.0.8.116 stratum 10

#启动服务
service ntpd start 或 systemctl start ntpd

#设置开机启动
chkconfig ntpd on 或 systemctl enable ntpd

#查看
ntpstat //查看ntp服务器有无和上层ntp连通
ntpq -p  //查看ntp服务器与上层ntp的状态
watch "ntpq -p" //查看ntpd进程的状态
  • 设置所有ceph节点为无需密码ssh互访(不要用 sudo 或 root 用户)
 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
#添加新用户
sudo useradd -d /home/cephnode -m cephnode
sudo passwd cephnode
#新用户权限
echo "cephnode ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephnode
sudo chmod 0440 /etc/sudoers.d/cephnode

#设置 ~/.ssh/config
vim  ~/.ssh/config
sudo chmod 600 config
【内容】
Host node1
   Hostname node1
   User cephnode
Host node2
   Hostname node2
   User cephnode
Host node3
   Hostname node3
   User cephnode
   
#生成ssh密钥对
ssh-keygen

#把公钥拷贝到各 Ceph 节点
ssh-copy-id cephnode@node1
ssh-copy-id cephnode@node2
ssh-copy-id cephnode@node3

#设置authorized_keys权限(视情况处理)
$ chmod 600 authorized_keys
#设置.ssh目录权限
$ chmod 700 -R .ssh
  • requiretty检查(ceph-deploy 命令时可能会报错)
1
2
sudo visudo
找到 Defaults requiretty 选项,把它改为 Defaults:ceph !requiretty 或者直接注释掉
  • 优先级/首选项
1
sudo yum install yum-plugin-priorities
  • 必要软件安装
1
2
yum install python2-pip* -y
yum install python-setuptools -y 

4.部署工具(cpeh-deploy)安装

  • yum源配置
 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
[root@ceph01 ~]# vim /etc/yum.conf
keepcache=1	//开启缓存 三个节点都改

[root@ceph01 ~]# yum -y install wget curl net-tools bash-completion   	//安装wget curl net-tools bash-completion 

[root@ceph01 ~]# cd /etc/yum.repos.d/
[root@ceph01 yum.repos.d]# mkdir backup
[root@ceph01 yum.repos.d]# mv C* backup

[root@ceph01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@ceph01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@ceph01 yum.repos.d]# cat << EOF > /etc/yum.repos.d/ceph.repo
[ceph]
name=Ceph packages for
baseurl=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/x86_64
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-noarch]
name=Ceph noarch packages 
baseurl=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/noarch/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages 
baseurl=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/SRPMS/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
EOF

[root@ceph03 yum.repos.d]# cat ceph.repo
[root@ceph03 yum.repos.d]# yum update -y	//升级yum源
  • yum安装cpeh-deploy
1
sudo yum install ceph-deploy

二、常用命令

1.安装命令

  • 清除命令
 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
#下列命令清除配置:
ceph-deploy purgedata {ceph-node} [{ceph-node}]
ceph-deploy forgetkeys

#用下列命令可以连 Ceph 安装包一起清除
ceph-deploy purge {ceph-node} [{ceph-node}]

#停止所有进程
stop ceph-all

#卸载所有ceph程序
ceph-deploy uninstall [{ceph-node}]

#卸载ceph-deploy管理
yum -y remove ceph-deploy

#如果想要重新部署,执行以下清除Ceph软件包,并清除其所有数据和配置
cd /etc/ceph
ceph-deploy purge node1 node2 node3
ceph-deploy purgedata node1 node2 node3
ceph-deploy forgetkeys
rm -rf ceph.*

#如果已经添加osd,需要先删除lvm然后zap磁盘
# lvs
# lvremove osd-xxx ceph-xxx
# ceph-deploy disk zap node1 /dev/sdb

2.集群命令

  • 查看集群状态
1
2
3
4
5
ceph -s
ceph -w
ceph health
ceph df //集群使用情况
tailf /var/log/ceph/ceph.log
  • 常用命令
1
2
3
4
5
6
7
8
9
ceph mon dump  //mon运行图,集群运行图之一
ceph osd dump  //osd运行图,集群运行图之一
ceph fs dump  //mds运行图,集群运行图之一
ceph pg dump  //pg运行图,集群运行图之一
ceph mds stat
ceph osd stat
ceph osd tree
ceph osd lspools
rados lspools
  • 对象存储操作
1
2
3
4
5
rados lspools
rados -p {poolname} ls
ceph osd map {poolname} {object-name}
rados put {object-name} {file-path} --pool={poolname}
rados rm {object-name} --pool={poolname}
  • 下发配置、分发配置至各个节点
1
2
3
4
#拉取某节点的配置
ceph-deploy --overwrite-conf config pull {hostname}
#将配置文件下发给所有节点
ceph-deploy --overwrite-conf config push node1 node2 node3
  • 服务管理
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
sudo start ceph-all  //启动所有守护进程
sudo stop ceph-all   //停止所有守护进程
sudo start ceph-osd-all
sudo start ceph-mon-all
sudo start ceph-mds-all
sudo stop ceph-osd-all 
sudo stop ceph-mon-all 
sudo stop ceph-mds-all
sudo start ceph-osd id={id}
sudo start ceph-mon id={hostname}
sudo start ceph-mds id={hostname}
sudo stop ceph-osd id={id}
sudo stop ceph-mon id={hostname}
sudo stop ceph-mds id={hostname}
systemctl restart ceph-mon.target	//将各个节点的mon服务重启下
systemctl restart ceph-osd.target	//将各个节点的osd服务重启下
systemctl restart ceph-radosgw.service //重启 Ceph 对象网关

三、部署集群环境

1.创建集群

  • 创建集群目录
1
2
3
#su - cephnode (有问题,在root账户下成功)
mkdir /etc/ceph
cd /etc/ceph
  • 安装 Ceph
1
2
3
4
5
6
7
8
ceph-deploy install node1 node2 node3

手动安装时,需安装相关依赖包:
yum install ceph-mon ceph-radosgw ceph-mds ceph-mgr ceph-osd ceph-common -y

如果批量安装错误,可通过手动安装方式安装,命令如下:
yum -y install epel-release && yum -y install ceph-release && yum -y install ceph ceph-radosgw

  • 创建 monitor
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ceph-deploy new {initial-monitor-node(s)}

em:
ceph-deploy new node1 node2

ceph-deploy new \
--public-network 10.0.8.0/24 \
--cluster-network 10.0.8.0/24 \
node1 node2 node3

tips:
#1.报错ImportError: No module named pkg_resources解决方法
yum install python2-pip* -y
  • 修改ceph配置
1
2
3
4
5
6
7
vim ceph.conf

【内容】
osd pool default size = 2
public_network = 10.0.8.0/24
cluster_network = 10.0.8.0/24
mon_allow_pool_delete = true
  • 配置初始 monitor(s)、并收集所有密钥
1
2
3
ceph-deploy mon create-initial

ceph -s	##查看状态
  • 创建osd

    • 创建osd(create 命令是依次执行 prepare 和 activate 命令的捷径)
    1
    2
    3
    4
    
    #空间使用率达到 near full 比率后, OSD 失败可能导致集群空间占满
    ceph-deploy osd create [--data DATA] [HOST]
    ceph-deploy osd create --data /dev/vdb node1
    ceph-deploy osd create --data /dev/vdb node2
    
    • 查看osd状态
    1
    2
    
    [root@node1 /etc/ceph]# ceph osd tree
    [root@node1 /etc/ceph]# ceph osd stat
    
    • 删除osd
    1
    2
    3
    4
    5
    
    #踢出集群
    ceph osd out {osd-num}
    #停止osd
    sudo /etc/init.d/ceph stop osd.{osd-num}
    #删除osd
    
  • 用 ceph-deploy 把配置文件和 admin 密钥拷贝到管理节点和 Ceph 节点

    1
    2
    3
    4
    
    ceph-deploy admin {admin-node} {ceph-node}
    ceph-deploy admin node1 node2 node3
    
    sudo chmod +r /etc/ceph/ceph.client.admin.keyring
    

2.扩容

  • 新增osd到集群
1
ceph-deploy osd create --data /dev/vdb node3
  • 添加mds到集群
1
2
ceph-deploy mds create {ceph-node}
ceph-deploy mds create node1
  • 新增mon到集群
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#修改配置
mon_initial members = ceph01,ceph02,ceph03	//新增ceph03
mon_host = 10.0.8.116,10.0.8.159,10.0.8.122	//新增10.0.8.122
public network = 10.0.8.0/24 

#将配置文件下发给所有节点
ceph-deploy --overwrite-conf config push node1 node2 node3

#添加mon
ceph-deploy mon add {ceph-node}
ceph-deploy mon add node3

#三个节点重启mon服务
systemctl restart ceph-mon.target
  • 创建mgr服务
1
ceph-deploy mgr create node1
  • 添加 RGW 例程
1
2
ceph-deploy rgw create {gateway-node}
ceph-deploy rgw create node1

3.创建文件系统

  • 创建pool
1
2
3
4
5
6
7
8
ceph osd pool create {poll-name} <pg_num>
ceph osd pool ls
ceph osd pool rename {poll-name} {new-poll-name}
ceph osd pool rm {poll-name} {poll-name} --yes-i-really-really-mean-it

em:
ceph osd pool create cephfs_data 64
ceph osd pool create cephfs_metadata 64
  • 创建文件系统
1
2
3
4
5
6
ceph fs new <fs_name> cephfs_metadata cephfs_data

em:
ceph fs new cephfs cephfs_metadata cephfs_data
ceph fs ls
ceph mds stat
  • 把 Ceph FS 挂载为内核驱动(node3操作)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
sudo mkdir /cephfs
cd /etc/ceph
cp ceph.client.admin.keyring admin.secret
vim admin.secret

【内容】
AQD7FbNhhDvhBBAAD1abMfsh8hXlPtqVqDQMKQ==

chmod +r /etc/ceph/admin.secret
#直接挂在
sudo mount -t ceph 10.0.8.116:6789:/ /cephfs
#带认证信息挂在
sudo mount -t ceph 10.0.8.116:6789:/ /cephfs -o name=admin,secretfile=/etc/ceph/admin.secret
#取消挂在
umount /cephfs
#查看挂载
  • 把 Ceph FS 挂载为用户空间文件系统( FUSE )(node3操作)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#安装ceph-fuse
yum -y install ceph-fuse
#需先取消之前内核驱动挂载的盘
umount /cephfs
#直接挂载
ceph-fuse -m 10.0.8.116:6789 /cephfs
#带认证信息挂在,除非它在默认位置(即 /etc/ceph ):
sudo ceph-fuse -k ./ceph.client.admin.keyring -m 10.0.8.116:6789 ~/cephfs
#取消挂载
fusermount -u /cephfs
  • Cephfs+Samba构建基于Ceph的文件共享服务

    • 安装Samba
    1
    2
    
    #安装Samba包
    yum -y install smaba samba-client samba-common
    
    • 创建samba用户
    1
    2
    3
    4
    5
    6
    
    groupadd samba
    useradd samba -d /home/samba -g samba -s /sbin/nologin
    touch /etc/samba/smbpasswd
    smbpasswd -a samba -c /etc/samba/smb.conf
    
    >samba   //账号:samba 密码:samba
    
    • 配置共享目录
    1
    
    mkdir -p /cephfs
    
    • 配置ceph
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
    cd /etc/ceph
    cp ceph.client.admin.keyring admin.secret
    vim admin.secret
    
    【内容】
    AQD7FbNhhDvhBBAAD1abMfsh8hXlPtqVqDQMKQ==
    
    #带认证信息挂在
    sudo mount -t ceph 10.0.8.116:6789:/ /cephfs -o name=admin,secretfile=/etc/ceph/admin.secret
    
    #设置文件夹权限,非777客户端无法写入数据
    chmod -R 777 /cephfs
    sudo chown -R nobody:nobody /smb
    
    • 配置smb
     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
    
    vim /etc/samba/smb.conf
    
    [global]
            workgroup = WORKGROUP
            netbios name = WINDOWS-6VQ5K0D
            server string = this is a test samba server
            log file = /var/log/samba/log.%m
            max log size = 500000
            security = user
            passdb backend = tdbsam
            load printing = no
    
    [cephfs]
            comment = CephFs Home Directories
            path = /cephfs
            writable = yes
            browseable = yes
            guest ok = no
    [linuxfs]
            comment = Linux Home Directories
            path = /
            writable = yes
            browseable = yes
            guest ok = no
    
    #检查配置文件正确性
    testparm
    
    • 启动服务
    1
    2
    
    sudo systemctl enable smb
    sudo systemctl start smb
    
    • windows客户端挂载
    1
    2
    3
    
    #账号:samba 密码:samba
    \\10.0.8.116\
    \\10.0.8.116\cephfs
    

4.对象存储

  • 新建 CEPH 对象网关实例
1
2
ceph-deploy rgw create {gateway-node}
ceph-deploy rgw create node1 node2 node3
  • 访问:http://:7480

  • 配置 CEPH 对象网关

    • s3风格接口
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    #创建用户
    radosgw-admin user create --uid="ceph-s3-user" --display-name="ceph s3 user demo"
    #获取到用户信息
    "user": "ceph-s3-user",
    "access_key": "A3NNVXFRGGBNVWQU72SJ",
    "secret_key": "sbtEd2g1Q7FXN7GCf2N25CauxXTMDAzS37xOKfoG"
    #查看用户
    radosgw-admin user list
    radosgw-admin user info --uid ceph-s3-user
    #命令行操作
    yum install -y s3cmd //安装
    s3cmd --configure //配置
    vim /root/.s3cfg  //signature_v2 = True//启用signature_v2
    s3cmd ls    //查看bucket
    s3cmd mb s3://my-new-bucket //创建bucket
    s3cmd ls s3://my-new-bucket //查看bucket中的文件
    #软件操作(S3 Browser)
    
    
    • swift风格接口
    1
    2
    3
    4
    
    #创建swift用户
    radosgw-admin subuser create --uid=ceph-s3-user --subuser=ceph-s3-user:swift --access=full
    #Create the secret key
    radosgw-admin key create --subuser=ceph-s3-user:swift --key-type=swift --gen-secret
    
  • 新建用户和KEYRING

    • 为每一个实例生成一个 Ceph 对象网关用户名和key. 举一个典型实例, 我们将使用 client.radosgw 后使用 gateway 作为用户名
    1
    
    sudo ceph auth get-or-create client.radosgw.gateway osd 'allow rwx' mon 'allow rwx' -o /etc/ceph/ceph.client.radosgw.keyring
    
    • 分发生成的keyring到网关实例所在节点
    1
    2
    
    sudo scp /etc/ceph/ceph.client.radosgw.keyring  root@node2:/etc/ceph/ceph.client.radosgw.keyring
    sudo scp /etc/ceph/ceph.client.radosgw.keyring  root@node3:/etc/ceph/ceph.client.radosgw.keyring
    
  • apache和网关配置

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    
    vim ceph.config
    【内容】
    [client.radosgw.gateway]
    host = node1
    keyring = /etc/ceph/ceph.client.radosgw.keyring
    rgw socket path = ""
    log file = /var/log/radosgw/client.radosgw.gateway.log
    rgw frontends = fastcgi socket_port=9000 socket_host=0.0.0.0
    rgw print continue = false
    
    sudo mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway
    sudo chown apache:apache /var/run/ceph
    

5.块设备

  • 创建pool及初始化pool(服务节点)
1
2
3
4
#创建存储池
ceph osd pool create rbd 128
#初始化存储池
rbd pool init rbd
  • 创建设备镜像并映射块设备(客户端操作)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#创建1G块设备镜像
sudo rbd create foo --size 1024 --image-feature layering -p rbd
#列出块设备镜像
sudo rbd ls
#设备镜像映射块设备
sudo rbd map foo --name client.admin -p rbd
#挂载
mkfs.xfs /dev/rbd0
mkdir -p /cephblock
mount /dev/rbd0 /cephblock
#查看
df -Th
#查看已映射块设备
rbd showmapped
rbd device list
#取消块设备映射
sudo rbd device unmap /dev/rbd/{poolname}/{imagename}
sudo rbd device unmap /dev/rbd/rbd/foo
  • 扩容/缩容(客户端操作)
1
2
3
4
5
6
7
#客户端操作 扩容/缩容的本质就是调整设备镜像大小
sudo rbd resize --size 2048 foo # 扩容至2G
sudo rbd resize --size 1024 foo --allow-shrink # 减少至1G
#然后使用扩展工具刷新生效
sudo xfs_growfs /dev/rbd0  # xfs文件系统格式使用xfs_growfs,其它ext4等使用resize2fs
#查看
df -Th

6.dashboard安装及配置

  • 启用dashboard
 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
#在所有dashboard节点上安装插件包
yum install -y ceph-mgr-dashboard
#开启插件
ceph mgr module enable dashboard --force
ceph mgr module ls | grep dashboard
#创建自签证书
ceph dashboard create-self-signed-cert
#禁用SSL
ceph dashboard set-rgw-api-ssl-verify False
#配置监听IP
ceph config set mgr mgr/dashboard/server_addr 0.0.0.0
#配置监听端口
ceph config set mgr mgr/dashboard/server_port 8443
#新增用户
vim /etc/ceph/ceph_dashboard_admin_passard.txt
【内容】
123456

ceph dashboard ac-user-create [--enabled] [--force-password] [--pwd_update_required] <username> -i <file-containing-password> [<rolename>] [<name>] [<email>] [<pwd_expiration_date>]
ceph dashboard ac-user-create admin -i /etc/ceph/ceph_dashboard_admin_passard.txt administrator
【输出】
{"username": "admin", "lastUpdate": 1639444868, "name": null, "roles": ["administrator"], "password": "$2b$12$eYx1APRQuQrKCBnHEo6YquHGKnmNItyyX4jWYylWt2rU3KIFI0hxi", "email": null}
生成好角色为administrator,账号为admin,密码为123456的用户
#使用配置生效
ceph mgr module disable dashboard
ceph mgr module enable dashboard
#查看已开启模块信息
ceph mgr services
#web访问
http://10.0.8.116:8443/
#为Dashboard设置access_key 和 secret_key
radosgw-admin user create --uid=dashboard-rgw --display-name=dashboard-rgw --system
radosgw-admin user info --uid=dashboard-rgw
vim /etc/ceph/ceph_dashboard_rgw_access.txt
【内容】
N0N1O1683KPQPAJD8ED7

vim /etc/ceph/ceph_dashboard_rgw_secret.txt
【内容】
MKMsGEOQBZ7LFPDaBjUxoH3R5uGyytucCeWa6AOn

ceph dashboard set-rgw-api-ssl-verify False
ceph dashboard set-rgw-api-host 10.0.8.116
ceph dashboard set-rgw-api-port 7480
ceph dashboard set-rgw-api-user-id dashboard-rgw
ceph dashboard set-rgw-api-access-key -i /etc/ceph/ceph_dashboard_rgw_access.txt
ceph dashboard set-rgw-api-secret-key -i /etc/ceph/ceph_dashboard_rgw_secret.txt

四、常见问题及解决

1.osd故障

  • 发现node3的服务osd为down状态
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph osd tree //出现故障,osd2,down
-7       0.00980     host node3                         
 2   hdd 0.00980         osd.2      down  0 1.00000 
[root@node3 ~]# df -hT   //查看ceph信息
文件系统	类型      容量  已用  可用 已用% 挂载点
tmpfs  tmpfs    3.8G   52K  3.8G    1% /var/lib/ceph/osd/ceph-2
[root@node3 ~]cd /var/lib/ceph/osd/ceph-2
[root@node3 /var/lib/ceph/osd/ceph-2]# more fsid //查看fsid
338dc846-e848-4067-9dd1-66213cbc0ba7
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph osd create 338dc846-e848-4067-9dd1-66213cbc0ba7   //ceph osd create uuid
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph auth add osd.2 osd 'allow *' mon 'allow rwx' -i /var/lib/ceph/osd/ceph-2/keyring	//增加权限
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph osd crush add 2 0.99899 host=node3	 //0.99899是权重,host=主机名称
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph osd in osd.2
[root@node3 /var/lib/ceph/osd/ceph-2]# systemctl restart ceph-osd.target
[root@node3 /var/lib/ceph/osd/ceph-2]# ceph osd tree //恢复正常
-7       0.00980     host node3                         
 2   hdd 0.00980         osd.2      up  1.00000 1.00000 
  • mon is allowing insecure global_id reclaim
1
2
#禁用不安全模式
ceph config set mon auth_allow_insecure_global_id_reclaim false

2.Error ERANGE: pg_num 128 size 3 would mean 1088 total pgs, which exceeds max 750 (mon_max_pg_per_osd 250 * num_in_osds 3)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
官网有人说是BUG(https://tracker.ceph.com/issues/22735),有两种解决方式,一种覆盖配置,另一种减小创建pool时的pg数。
我选择的是覆盖配置。
$ vim /etc/ceph/ceph.conf
[global]
mon_max_pg_per_osd = 3000
mon_pg_warn_max_per_osd = 3000

ceph-deploy --overwrite-conf config push node2 node3
systemctl restart ceph-mon.target
systemctl restart ceph-mgr.target