Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How openstack uses rsyslog to forward logs

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Openstack how to use rsyslog forward logs, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.

System: ubuntu14.04

Openstack Version: Juno

One, enable rsyslog in nova

1. Modify/etc/nova/nova.conf

[DEFAULT]use_syslog = Truesyslog_log_facility = LOG_LOCAL0

2. Modify the nova code.

2.1 First confirm the location of the nova code

python -c 'import nova;print nova.__ path__'['/usr/lib/python2.7/dist-packages/nova']

2.2 Go to nova directory

cd /usr/lib/python2.7/dist-packages/nova

2.3 modify the code

vim openstack/common/log.py

2.3.1 Search for "use-syslog-rfc-format" keyword, change default=False in the configuration to True, enable logs in rfc format, if not enabled, the program name sending logs will not be printed out, this configuration is invalid in the configuration file modification, so directly change the default value in the code. The amendment reads as follows:

cfg.BoolOpt('use-syslog-rfc-format', # TODO(bogdando) remove or use True after existing # syslog format deprecation in J default=True, help='(Optional) Enables or disables syslog rfc5424 format ' 'for logging. If enabled, prefixes the MSG part of the ' 'syslog message with APP-NAME (RFC5424). The ' 'format without the APP-NAME is deprecated in I, ' 'and will be removed in J. '),

2.3.2 Search for the keyword "if CONF.use_syslog" and go down a few lines.

(1)Change syslog = RFCSysLogHandler(facility=facility) to syslog = RFCSysLogHandler(address ='/dev/log', facility=facility)

(2)Change syslog = logging.handlers.SysLogHandler(facility=facility) to syslog = logging.handlers.SysLogHandler(address='/dev/log',facility=facility)

The final results are as follows:

if CONF.use_syslog: try: facility = _find_facility_from_conf() # TODO(bogdando) use the format provided by RFCSysLogHandler # after existing syslog format deprecation in J if CONF.use_syslog_rfc_format: syslog = RFCSysLogHandler(address='/dev/log',facility=facility) else: syslog = logging.handlers.SysLogHandler(address='/dev/log',facility=facility) #syslog = logging.handlers.SysLogHandler(facility=facility) log_root.addHandler(syslog) except socket.error: log_root.error('Unable to add syslog handler. Verify that syslog' 'is running. ')

Second, configure rsyslog

1. Added rsyslog configuration. rsyslog is installed in ubuntu 14.04.

#Add configuration file echo 'local0.* @@192.168.100.100:514' > /etc/rsyslog.d/60-nova.conf

The effect is to convert local0.* The log is forwarded to 192.168.100.100:514 remotely.

local0 corresponds to LOG_LOCAL0 in nova.conf, followed by.* It means to forward all levels of logs. If you only want to send error logs, you can change it to local0.error. The last@@192.168.100.100:514 means to forward local rsyslog to remote log server. Refer to the official rsyslog documentation for details.

local0.* @@192.168.100.100:514

2. Restart the server

service rsyslog restartservice nova-compute restart

3. Verify that rsyslog is configured successfully. Run the following command in the shell, and the result will normally be displayed at 192.168.100.100.

logger -p local0.debug "test rsyslog"

III. Summary

The whole logging process is (1) nova sends logs to the local rsyslog server. The local rsyslog receives logs and forwards them to the remote log server 192.168.100.100. (3) Remote log servers can be rsyslog, or other log servers such as graylog. Remember to open the tcp receive port of the remote log server.

The configuration of other openstack services is similar, the only difference is the location of the code, if you want to modify the finder, you can determine the code location like this:

python -c 'import cinder;print cinder.__ path__'

Remember to restart the service after modifying the openstack or rsyslog configuration.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report