المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : إعدادات وحدة المراقبة المركزية rsyslog لخوادم الCentOS.



walid
11-02-2013, بتوقيت غرينيتش 01:53 AM
السلام عليكم ورحمة الله وبركاته,

من اهم الامور التي يجب توفرها لدى أي خادم server هي وحدة المراقبة المركزية للخوادم حيث يتم الرجوع إليها في حال وجود خطأ معين لا يوجد سبب له, او عملية قرصنة تمت على الخادم server أو تمت على أي موقع خاص بين المواقع الاخرى الموجودة على الخادم server, وهذه تتم عبر الخطوات التالية عند إستلام أي خادم server ببيئة CentOS;

أولا تحديث update الخادم server ومصادره

رمز Code:
yum update
ومن ثم نقم بكتابة الامر:


رمز Code:
yum update all
ومن ثم نقم بعمل ريستارت للخادم server

رمز Code:
reboot -h
بعد الدخول الى الخادم server والتاكد من تحديث updateه وتحدث مصادره كلكيرنال والاباتشي وإصدار البي اتش بي ووالخ نقم بلبدء بإعدادات وحدة المراقبة المركزية وهي rsyslog كلتالي:

نقم بلبداية بإيقاف برنامج syslog الذي يكون متوفر بلخادم server بشكل إفتراضي بلامر

رمز Code:
service syslog stop
ومن ثم نقم بتنصيب setup وحدة المراقبة المركزية rsyslog

رمز Code:
yum install rsyslog
نقم بإيقاف برنامج syslog من قائمة المهام للخادم server بلامر التالي

رمز Code:
chkconfig syslog off
ومن ثم تشغيل وحدة المراقبة المركزية حتى يتم تشغيلها بشكل الي بعد عمل اي ريستارت للخادم server

رمز Code:
chkconfig rsyslog on
ونقم بعدها بحذف اي برنامج مراقبة كبرنامج syslog بلامر

رمز Code:
yum erase sysklogd
لعدم وجود اخطاء بلعمل ...

الأن يتم التعديل بلخطوات التالية:

رمز Code:
nano /etc/sysconfig/rsyslog
نقم بتعديل السطور التالية كلشكل التالي:




رمز Code:
SYSLOGD_OPTIONS="-c 3" KLOGD_OPTIONS="-x"
نقم بحذف ملف syslog.conf

رمز Code:
rm /etc/syslog.conf
ومن ثم نقم بإنشاء ملف جديدة لوحدة المراقبة

رمز Code:
nano /etc/rsyslog.conf
ونضع بها الاتي بدون اي تغيير فيها


رمز Code:
#load the kernel logger module $ModLoad imklog #load the UNIX sockets module to receive local messages from processen $ModLoad imuxsock #load UDP powers, to receive messages via the UDP protocol $ModLoad imudp #make rsyslog listen on all ip addresses, you could specify an address $UDPServerAddress 7xx.xx.xx3 #make rsyslog listen on UDP port 514 $UDPServerRun 514 #repeated lines will be reduced $RepeatedMsgReduction on ()
ونقم بإضافة السطر الاخير

رمز Code:
*.info;mail.none;authpriv.none;cron.none /var/log/messages
ومن ثم نقم بتعديل الملف ومحتواه كلأتي:

رمز Code:
nano /etc/rsyslog.conf
ووضع التالي فيه

رمز Code:
$ModLoad imuxsock.so $ModLoad imklog.so $ModLoad imudp.so #load the network stuff $UDPServerAddress 0.0.0.0 $UDPServerRun 514 #reduce any duplicates $RepeatedMsgReduction on # The template that wil format the message as it is writen to the file # you can edit this line if you want to customize te message format $template TraditionalFormat,&quot;%timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-last-lf%\n&quot; # Log anything (except mail) of level info or higher. # Don't log private authentication messages! #*.info;mail.none;authpriv.none;cron.none /var/log/messages if \ $source == 'hostname' \ and \ $syslogseverity <= '6' \ and ( \ $syslogfacility-text != 'mail' \ and \ $syslogfacility-text != 'authpriv' \ and \ $syslogfacility-text != 'cron' \ ) \ then /var/log/messages;TraditionalFormat #authpriv.* /var/log/secure;TraditionalFormat # The authpriv file has restricted access. #authpriv.* /var/log/secure if \ $source == 'hostname' \ and \ $syslogfacility-text == 'authpriv' \ then /var/log/secure;TraditionalFormat # Log anything (except mail) of level info or higher. # Don't log private authentication messages! # mail.* /var/log/maillog;TraditionalFormat if \ $source == 'hostname' \ and \ $syslogfacility-text == 'mail' \ then /var/log/maillog;TraditionalFormat # Log cron stuff #cron.* /var/log/cron;TraditionalFormat if \ $source == 'hostname' \ and \ $syslogfacility-text == 'cron' \ then /var/log/cron;TraditionalFormat # Everybody gets emergency messages #*.emerg * if \ $source == 'hostname' \ and \ $syslogseverity-text == 'emerg' \ then * # this line creates a template that will store the messages for each host in a seperate file. # a new file will ben created daily because of the date in the filename. $template DailyPerHostLogs,&quot;/var/opt/syslog/%HOSTNAME%/%HOSTNAME%.%$YEAR%-%$MONTH%-%$DAY%.log&quot; *.* -?DailyPerHostLogs;TraditionalFormat
قم بعمل رستارت للوحدة بلامر التالي:

رمز Code:
/etc/rc.d/init.d/rsyslog restart
بعد التاكد من تشغيل البرنامج نقم بفحصه بلامر التالي:

رمز Code:
logger “this is a test from SecureJo.com”
للتاكد قم بكتابة الامر لمشاهدة الرسالة

رمز Code:
tail /var/log/messages
والتي ستكون محتواها

رمز Code:
this is a test from SecureJo.com
والتي تأكد لنا عمل الوحدة بشكل سليم, بدون تواجد أي خطأ فيها...

تحياتي






https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى