1.2. 配置文件结构
Ceph 配置文件在启动时配置 Ceph 守护进程,覆盖默认值。Ceph 配置文件采用一种 格式 的语法。您可以在前面的注释中用井号 (#) 或分号 (;) 添加注释。例如:
# <--A number (#) sign precedes a comment.
; A comment may be anything.
# Comments always follow a semi-colon (;) or a pound (#) on each line.
# The end of the line terminates a comment.
# We recommend that you provide comments in your configuration file(s).
配置文件可以在 Ceph 存储集群中配置所有 Ceph 守护进程,或者在启动时配置特定类型的所有 Ceph 守护进程。要配置一系列守护进程,必须在接收配置的进程中包含设置,如下所示:
- [global]
- 描述
-
[global]下的设置会影响 Ceph Storage 集群中的所有守护进程。 - 示例
-
auth supported = cephx
- [osd]
- 描述
-
[osd]下的设置会影响 Ceph 存储集群中的所有ceph-osd守护进程,并覆盖[global]中的相同设置。 - 示例
-
OSD 日志大小 = 1000
- [mon]
- 描述
-
[mon]下的设置会影响 Ceph 存储集群中的所有ceph-mon守护进程,并覆盖[global]中的相同设置。 - 示例
-
mon host = hostname1,hostname2,hostname3mon addr = 10.0.0.101:6789
- [client]
- 描述
-
[client]下的设置会影响所有 Ceph 客户端(例如,挂载的 Ceph 块设备、Ceph 对象网关等)。 - 示例
-
log file = /var/log/ceph/radosgw.log
全局设置会影响 Ceph 存储集群中所有守护进程的所有实例。将 [global] 设置用于 Ceph 存储集群中所有守护进程通用的值。您可以通过以下方法覆盖每个 [global] 设置:
-
更改特定进程类型中的设置(例如
[osd]、[mon])。 -
更改特定进程的设置(例如,
[osd.1])。
覆盖全局设置会影响所有子进程,除了您在特定守护进程中特别覆盖的子进程。
典型的全局设置涉及激活身份验证。例如:
[global]
#Enable authentication between hosts within the cluster.
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
您可以指定适用于特定类型的守护进程的设置。当您指定 [osd] 或 [mon] 下的设置而不指定特定实例,则设置将分别应用于所有 OSD 或监控守护进程。
一个典型的守护进程范围内的设置是设置日志大小、文件存储设置等,例如:
[osd]
osd_journal_size = 1000
您可以为守护进程的特定实例指定设置。您可以通过输入类型,以句点 (.) 分隔来指定一个实例,或通过实例 ID 来指定实例。Ceph OSD 守护进程的实例 ID 始终是数字,但 Ceph 监视器可能会是字母数字。
[osd.1]
# settings affect osd.1 only.
[mon.a]
# settings affect mon.a only.
默认的 Ceph 配置文件位置按顺序包括:
-
$CEPH_CONF(跟随$CEPH_CONF环境变量的路径) -
-c path/path(-c命令行参数) -
/etc/ceph/ceph.conf -
~/.ceph/config -
./Ceph.conf(在当前工作目录中)
典型的 Ceph 配置文件至少具有以下设置:
[global]
fsid = {cluster-id}
mon_initial_members = {hostname}[, {hostname}]
mon_host = {ip-address}[, {ip-address}]
#All clusters have a front-side public network.
#If you have two NICs, you can configure a back side cluster
#network for OSD object replication, heart beats, backfilling,
#recovery, and so on
public_network = {network}[, {network}]
#cluster_network = {network}[, {network}]
#Clusters require authentication by default.
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
#Choose reasonable numbers for your journals, number of replicas
#and placement groups.
osd_journal_size = {n}
osd_pool_default_size = {n} # Write an object n times.
osd_pool_default_min_size = {n} # Allow writing n copy in a degraded state.
osd_pool_default_pg_num = {n}
osd_pool_default_pgp_num = {n}
#Choose a reasonable crush leaf type.
#0 for a 1-node cluster.
#1 for a multi node cluster in a single rack
#2 for a multi node, multi chassis cluster with multiple hosts in a chassis
#3 for a multi node cluster with hosts across racks, and so on
osd_crush_chooseleaf_type = {n}