2.8. 为容器化 Ceph 守护进程启用日志记录到文件
默认情况下,容器化 Ceph 守护进程不记录到文件。您可以使用集中式配置管理,使容器化 Ceph 守护进程能够记录到文件。
前提条件
- 安装 Red Hat Ceph Storage 软件。
- 根级别访问运行容器化守护进程的节点。
流程
进入
var/log/ceph目录:Example
[root@host01 ~]# cd /var/log/ceph记录任何现有日志文件。
语法
ls -l /var/log/ceph/Example
[root@host01 ceph]# ls -l /var/log/ceph/ total 396 -rw-r--r--. 1 ceph ceph 107230 Feb 5 14:42 ceph-osd.0.log -rw-r--r--. 1 ceph ceph 107230 Feb 5 14:42 ceph-osd.3.log -rw-r--r--. 1 root root 181641 Feb 5 14:42 ceph-volume.log在示例中,登录 OSD.0 和 OSD.3 的文件已经启用。
获取您要启用日志记录的守护进程的容器名称:
Red Hat Enterprise Linux 7
[root@host01 ceph]# docker ps -aRed Hat Enterprise Linux 8
[root@host01 ceph]# podman ps -a使用集中式配置管理,为 Ceph 守护进程启用文件日志记录。
Red Hat Enterprise Linux 7
docker exec CONTAINER_NAME ceph config set DAEMON_NAME log_to_file trueRed Hat Enterprise Linux 8
podman exec CONTAINER_NAME ceph config set DAEMON_NAME log_to_file trueDAEMON_NAME 由 CONTAINER_NAME 派生而来。删除
ceph-,并将守护进程和守护进程 ID 之间的连字符替换为一个句点。Red Hat Enterprise Linux 7
[root@host01 ceph]# docker exec ceph-mon-host01 ceph config set mon.host01 log_to_file trueRed Hat Enterprise Linux 8
[root@host01 ceph]# podman exec ceph-mon-host01 ceph config set mon.host01 log_to_file true可选:要为集群日志启用日志日志,请使用
mon_cluster_log_to_file选项:Red Hat Enterprise Linux 7
docker exec CONTAINER_NAME ceph config set DAEMON_NAME mon_cluster_log_to_file trueRed Hat Enterprise Linux 8
podman exec CONTAINER_NAME ceph config set DAEMON_NAME mon_cluster_log_to_file trueRed Hat Enterprise Linux 7
[root@host01 ceph]# docker exec ceph-mon-host01 ceph config set mon.host01 mon_cluster_log_to_file trueRed Hat Enterprise Linux 8
[root@host01 ceph]# podman exec ceph-mon-host01 ceph config set mon.host01 mon_cluster_log_to_file true验证更新的配置:
Red Hat Enterprise Linux 7
docker exec CONTAINER_NAME ceph config show-with-defaults DAEMON_NAME | grep log_to_fileRed Hat Enterprise Linux 8
podman exec CONTAINER_NAME ceph config show-with-defaults DAEMON_NAME | grep log_to_fileExample
[root@host01 ceph]# podman exec ceph-mon-host01 ceph config show-with-defaults mon.host01 | grep log_to_file log_to_file true mon default[false] mon_cluster_log_to_file true mon default[false]可选:重启 Ceph 守护进程:
语法
systemctl restart ceph-DAEMON@DAEMON_IDExample
[root@host01 ceph]# systemctl restart ceph-mon@host01验证新日志文件是否存在:
语法
ls -l /var/log/ceph/Example
[root@host01 ceph]# ls -l /var/log/ceph/ total 408 -rw-------. 1 ceph ceph 202 Feb 5 16:06 ceph.audit.log -rw-------. 1 ceph ceph 3182 Feb 5 16:06 ceph.log -rw-r--r--. 1 ceph ceph 2049 Feb 5 16:06 ceph-mon.host01.log -rw-r--r--. 1 ceph ceph 107230 Feb 5 14:42 ceph-osd.0.log -rw-r--r--. 1 ceph ceph 107230 Feb 5 14:42 ceph-osd.3.log -rw-r--r--. 1 root root 181641 Feb 5 14:42 ceph-volume.log创建了两个新文件,
ceph-mon.host01.log用于 monitor 守护进程和ceph.log,用于集群日志。