25.3. runlabels로 rsyslog 실행

rhel9/rsyslog 컨테이너 이미지는 rsyslogd 데몬의 컨테이너화된 버전을 실행하도록 생성되었습니다. rsyslog 이미지에는 다음 runlabels가 포함되어 있습니다. install,rununinstall 입니다. 다음 절차에서는 rsyslog 이미지를 설치, 실행 및 제거하는 단계를 수행합니다.

사전 요구 사항

  • container-tools meta-package가 설치되어 있습니다.

절차

  1. rsyslog 이미지를 가져옵니다.

    # podman pull registry.redhat.io/rhel9/rsyslog
  2. rsyslog 에 대한 설치 runlabel 표시 :

    # podman container runlabel install --display rhel9/rsyslog
    command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog registry.redhat.io/rhel9/rsyslog:latest /bin/install.sh

    그러면 명령이 호스트에 대한 권한을 열고 컨테이너의 /host 에 호스트 루트 파일 시스템을 마운트하고 install.sh 스크립트를 실행합니다.

  3. rsyslog 에 대한 install runlabel을 실행합니다.

    # podman container runlabel install rhel9/rsyslog
    command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog registry.redhat.io/rhel9/rsyslog:latest /bin/install.sh
    Creating directory at /host//etc/pki/rsyslog
    Creating directory at /host//etc/rsyslog.d
    Installing file at /host//etc/rsyslog.conf
    Installing file at /host//etc/sysconfig/rsyslog
    Installing file at /host//etc/logrotate.d/syslog

    이렇게 하면 rsyslog 이미지가 나중에 사용할 호스트 시스템에 파일이 생성됩니다.

  4. rsyslog 에 대한 run label을 표시합니다.

    # podman container runlabel run --display rhel9/rsyslog
    command: podman run -d --privileged --name rsyslog --net=host --pid=host -v /etc/pki/rsyslog:/etc/pki/rsyslog -v /etc/rsyslog.conf:/etc/rsyslog.conf -v /etc/sysconfig/rsyslog:/etc/sysconfig/rsyslog -v /etc/rsyslog.d:/etc/rsyslog.d -v /var/log:/var/log -v /var/lib/rsyslog:/var/lib/rsyslog -v /run:/run -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog --restart=always registry.redhat.io/rhel9/rsyslog:latest /bin/rsyslog.sh

    이 경우 명령은 rsyslogd 데몬을 실행하도록 rsyslog 컨테이너를 시작할 때 호스트에 대한 권한을 열고 컨테이너 내부의 호스트에서 특정 파일 및 디렉터리를 마운트한다는 것을 보여줍니다.

  5. rsyslog 에 대한 run label을 실행합니다.

    # podman container runlabel run rhel9/rsyslog
    command: podman run -d --privileged --name rsyslog --net=host --pid=host -v /etc/pki/rsyslog:/etc/pki/rsyslog -v /etc/rsyslog.conf:/etc/rsyslog.conf -v /etc/sysconfig/rsyslog:/etc/sysconfig/rsyslog -v /etc/rsyslog.d:/etc/rsyslog.d -v /var/log:/var/log -v /var/lib/rsyslog:/var/lib/rsyslog -v /run:/run -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog --restart=always registry.redhat.io/rhel9/rsyslog:latest /bin/rsyslog.sh
    28a0d719ff179adcea81eb63cc90fcd09f1755d5edb121399068a4ea59bd0f53

    rsyslog 컨테이너는 권한을 열고 호스트에서 필요한 항목을 마운트하고 백그라운드에서 rsyslogd 데몬(-d)을 실행합니다. rsyslogd 데몬은 로그 메시지 수집 및 /var/log 디렉터리의 파일로 메시지를 전달하기 시작합니다.

  6. rsyslog 에 대한 uninstall runlabel을 표시합니다.

    # podman container runlabel uninstall --display rhel9/rsyslog
    command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog registry.redhat.io/rhel9/rsyslog:latest /bin/uninstall.sh
  7. rsyslog:에 대해 uninstall runlabel을 실행합니다.

    # podman container runlabel uninstall rhel9/rsyslog
    command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel9/rsyslog:latest -e NAME=rsyslog registry.redhat.io/rhel9/rsyslog:latest /bin/uninstall.sh
참고

이 경우 uninstall.sh 스크립트는 /etc/logrotate.d/syslog 파일만 제거합니다. 구성 파일을 정리하지 않습니다.