Questo contenuto non è disponibile nella lingua selezionata.
8.8.3. Enabling Syslog for Cartridge Logs from Gears
$OPENSHIFT_LOG_DIR directory of an application. You can configure logshifter on node hosts to instead have gears send their cartridge logs to Syslog. Starting with OpenShift Enterprise 2.1.7, you can also have them sent to both Syslog and the $OPENSHIFT_LOG_DIR directory at the same time.
Procedure 8.6. To Enable Syslog for Cartridge Logs from Gears:
- Edit the
/etc/openshift/logshifter.conffile on the node host. The default value for theoutputTypesetting isfile, which results in gears sending cartridge logs to the$OPENSHIFT_LOG_DIRdirectory. Change this setting tosyslogto have them sent to Syslog:outputType=syslog
outputType=syslogCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, starting with OpenShift Enterprise 2.1.7, you can choose to change theoutputTypesetting instead tomulti, which results in logs being written using bothfileandsyslogat the same time. - Ask affected owners of existing applications to restart their applications for the changes to take effect. They can restart their applications with the following commands:
rhc app stop -a appname rhc app start -a appname
$ rhc app stop -a appname $ rhc app start -a appnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can restart all gears on affected node hosts. The downtime caused by restarting all gears is minimal and normally lasts a few seconds:oo-admin-ctl-gears restartall
# oo-admin-ctl-gears restartallCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Important
outputTypeFromEnviron setting in the /etc/openshift/logshifter.conf file is set to true, application owners are allowed to override the global outputType setting using a LOGSHIFTER_OUTPUT_TYPE environment variable in their application. See the OpenShift Enterprise User Guide for more information.
With the mmopenshift plug-in, all Cron cartridges will output all log information to the configured gear log file (/var/log/openshift_gears in the example 8.1). It may be necessary for system-level Cron logs to be separated from the gear logs for troubleshooting purposes. System-level Cron messages are tagged with cron_sys_log and can be separated into another file by adding the below to the /etc/syslog.conf Syslog configuration file:
:syslogtag entry must be placed before the *.* mmopenshift entry to prevent Cron system logs from going to both the openshift_cron_cartridges log and the openshift_gears log. The &~ tells Rsyslog to stop processing log entries if the filter condition on the previous line is met.
To provide context to cartridge logs aggregated to Syslog, a message modification plug-in for Rsyslog called mmopenshift can be used to add gear metadata to the cartridge logs. The plug-in can be configured to add metadata items to the JSON properties of each message that Rsyslog receives from a gear.
mmopenshift plug-in also only works for messages that have the $!uid JSON property, which can be added automatically when the imuxsock plug-in is enabled with the following options:
- SysSock.Annotate
- SysSock.ParseTrusted
- SysSock.UsePIDFromSystem
Procedure 8.7. To Enable Application and Gear Context for Cartridge Logs:
- Install the
mmopenshiftplug-in, which requires the rsyslog7 package, on the node host. Because installing the rsyslog7 package where the rsyslog package is already installed can cause conflicts, consult the following instructions relevant to your node host.If the rsyslog package is already installed, use ayumshell to remove the rsyslog package and install the rsyslog7 and rsyslog7-mmopenshift packages safely:- Stop the Rsyslog service:
service rsyslog stop
# service rsyslog stopCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open a
yumshell:yum shell
# yum shellCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following commands inside of the
yumshell:> erase rsyslog > install rsyslog7 rsyslog7-mmopenshift > transaction run > quit
> erase rsyslog > install rsyslog7 rsyslog7-mmopenshift > transaction run > quitCopy to Clipboard Copied! Toggle word wrap Toggle overflow The rsyslog package is uninstalled and a newer version of Rsyslog takes its place. The rsyslog7-mmopenshift package is also installed, which provides themmopenshiftmodule.
Alternatively, if the rsyslog package is not already installed, or if rsyslog7 is already the only version of Rsyslog installed, install themmopenshiftmodule using the following command:yum install rsyslog7 rsyslog7-mmopenshift
# yum install rsyslog7 rsyslog7-mmopenshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Review the existing
/etc/rsyslog.conffile, if relevant, and note any important default or custom settings. This includes changes that were made with the instructions described in Section 8.8.2, “Enabling Syslog for Node Components”. Next, make any required changes to ensure that the new/etc/rsyslog7.conffile contains those changes. Note that some settings may be different between/etc/rsyslog.confand/etc/rsyslog7.conf.rpmnew; see http://www.rsyslog.com/doc/v7-stable/ for more information.Once complete, take a backup of/etc/rsyslog.confand move/etc/rsyslog.conf.rpmnewto/etc/rsyslog.confImportant
A sample section of an/etc/rsyslog7.conf.rpmnewfile is provided at Example 8.8, “Sample Configuration Settings in/etc/rsyslog7.conf” which depicts how themmopenshiftplug-in can be enabled for Rsyslog. However, it is not meant to represent a comprehensive/etc/rsyslog7.conffile or be fully comparable to the standard/etc/rsyslog.confconfiguration. - Edit the
/etc/rsyslog7.conffile and add the following lines under theMODULESsection to enable theimuxsockplug-in and themmopenshiftplug-in:module(load="imuxsock" SysSock.Annotate="on" SysSock.ParseTrusted="on" SysSock.UsePIDFromSystem="on") module(load="mmopenshift")
module(load="imuxsock" SysSock.Annotate="on" SysSock.ParseTrusted="on" SysSock.UsePIDFromSystem="on") module(load="mmopenshift")Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the
/etc/rsyslog7.conffile and comment out the following line under theMODULESsection to configure theimuxsockplug-in:#$ModLoad imuxsock
#$ModLoad imuxsockCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the
/etc/rsyslog7.conffile and comment out the following lines to disable theimjournalplug-in:$ModLoad imjournal $OmitLocalLogging on $IMJournalStateFile imjournal.state
$ModLoad imjournal $OmitLocalLogging on $IMJournalStateFile imjournal.stateCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the
/etc/rsyslog7.conffile to have Syslog search the/etc/rsyslog7.ddirectory for configuration files:#$IncludeConfig /etc/rsyslog.d/*.conf $IncludeConfig /etc/rsyslog7.d/*.conf
#$IncludeConfig /etc/rsyslog.d/*.conf $IncludeConfig /etc/rsyslog7.d/*.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Examine the
/etc/rsyslog.ddirectory and copy any configuration files that are needed in/etc/rsyslog7.ddirectory for the Rsyslog7 logging configuration. - Create a gear log template file in the Rsyslog7 directory. This defines the format of the gear logs, including sufficient parameters to distinguish gears from each other. This example template can be modified to suit the requirements of your log analysis tools. For more information on template configuration instructions, see http://www.rsyslog.com/doc/v7-stable/configuration/templates.html.:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the following lines to the
/etc/rsyslog7.conffile under theRULESsection to configure themmopenshiftplug-in to use the template from the previous step. The following example logs all gear messages to the/var/log/openshift_gearsfile and all other messages to the/var/log/messagesfile, but these destinations are configurable to a different destination:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Also, comment out the following line:*.info;mail.none;authpriv.none;cron.none /var/log/messages
# *.info;mail.none;authpriv.none;cron.none /var/log/messagesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Start or restart the
rsyslogservice and ensure it starts persistently across reboots:service rsyslog restart chkconfig rsyslog on
# service rsyslog restart # chkconfig rsyslog onCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 8.8. Sample Configuration Settings in /etc/rsyslog7.conf