이 콘텐츠는 선택한 언어로 제공되지 않습니다.
25.5.2. Creating a New Directory for rsyslog Log Files
Rsyslog runs as the
syslogd
daemon and is managed by SELinux. Therefore all files to which rsyslog is required to write to, must have the appropriate SELinux file context.
Procedure 25.4. Creating a New Working Directory
- If required to use a different directory to store working files, create a directory as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]# mkdir /rsyslog
~]# mkdir /rsyslog
- Install utilities to manage SELinux policy:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]# yum install policycoreutils-python
~]# yum install policycoreutils-python
- Set the SELinux directory context type to be the same as the
/var/lib/rsyslog/
directory:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]# semanage fcontext -a -t syslogd_var_lib_t /rsyslog
~]# semanage fcontext -a -t syslogd_var_lib_t /rsyslog
- Apply the SELinux context:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]# restorecon -R -v /rsyslog restorecon reset /rsyslog context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:syslogd_var_lib_t:s0
~]# restorecon -R -v /rsyslog restorecon reset /rsyslog context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:syslogd_var_lib_t:s0
- If required, check the SELinux context as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]# ls -Zd /rsyslog drwxr-xr-x. root root system_u:object_r:syslogd_var_lib_t:s0 /rsyslog
~]# ls -Zd /rsyslog drwxr-xr-x. root root system_u:object_r:syslogd_var_lib_t:s0 /rsyslog
- Create subdirectories as required. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The subdirectories will be created with the same SELinux context as the parent directory.~]# mkdir /rsyslog/work
~]# mkdir /rsyslog/work
- Add the following line in
/etc/rsyslog.conf
immediately before it is required to take effect:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This setting will remain in effect until the next$WorkDirectory /rsyslog/work
$WorkDirectory /rsyslog/work
WorkDirectory
directive is encountered while parsing the configuration files.