2.8. 为容器化 Ceph 守护进程启用日志记录到文件


默认情况下,容器化 Ceph 守护进程不记录到文件。您可以使用集中式配置管理,使容器化 Ceph 守护进程能够记录到文件。

前提条件

  • 安装 Red Hat Ceph Storage 软件。
  • 根级别访问运行容器化守护进程的节点。

流程

  1. 进入 var/log/ceph 目录:

    Example

    [root@host01 ~]# cd /var/log/ceph

  2. 记录任何现有日志文件。

    语法

    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 的文件已经启用。

  3. 获取您要启用日志记录的守护进程的容器名称:

    Red Hat Enterprise Linux 7

    [root@host01 ceph]# docker ps -a

    Red Hat Enterprise Linux 8

    [root@host01 ceph]# podman ps -a

  4. 使用集中式配置管理,为 Ceph 守护进程启用文件日志记录。

    Red Hat Enterprise Linux 7

    docker exec CONTAINER_NAME ceph config set DAEMON_NAME log_to_file true

    Red Hat Enterprise Linux 8

    podman exec CONTAINER_NAME ceph config set DAEMON_NAME log_to_file true

    DAEMON_NAMECONTAINER_NAME 派生而来。删除 ceph-,并将守护进程和守护进程 ID 之间的连字符替换为一个句点。

    Red Hat Enterprise Linux 7

    [root@host01 ceph]# docker exec ceph-mon-host01 ceph config set mon.host01 log_to_file true

    Red Hat Enterprise Linux 8

    [root@host01 ceph]# podman exec ceph-mon-host01 ceph config set mon.host01 log_to_file true

  5. 可选:要为集群日志启用日志日志,请使用 mon_cluster_log_to_file 选项:

    Red Hat Enterprise Linux 7

    docker exec CONTAINER_NAME ceph config set DAEMON_NAME mon_cluster_log_to_file true

    Red Hat Enterprise Linux 8

    podman exec CONTAINER_NAME ceph config set DAEMON_NAME mon_cluster_log_to_file true

    Red Hat Enterprise Linux 7

    [root@host01 ceph]# docker exec ceph-mon-host01 ceph config set mon.host01 mon_cluster_log_to_file true

    Red Hat Enterprise Linux 8

    [root@host01 ceph]# podman exec ceph-mon-host01 ceph config set mon.host01 mon_cluster_log_to_file true

  6. 验证更新的配置:

    Red Hat Enterprise Linux 7

    docker exec CONTAINER_NAME ceph config show-with-defaults DAEMON_NAME | grep log_to_file

    Red Hat Enterprise Linux 8

    podman exec CONTAINER_NAME ceph config show-with-defaults DAEMON_NAME | grep log_to_file

    Example

    [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]

  7. 可选:重启 Ceph 守护进程:

    语法

    systemctl restart ceph-DAEMON@DAEMON_ID

    Example

    [root@host01 ceph]# systemctl restart ceph-mon@host01

  8. 验证新日志文件是否存在:

    语法

    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,用于集群日志。

其它资源

  • 有关更多信息,请参阅 Red Hat Ceph Storage 故障排除指南中的 配置日志记录 部分。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.