المقدمة
يوضح هذا المستند كيفية تكوين syslog-servers ل Network Services Orchestrator (NSO) 5.x.
المتطلبات الأساسية
المتطلبات
لا توجد متطلبات خاصة لهذا المستند.
المكونات المستخدمة
لا يقتصر هذا المستند على إصدارات برامج ومكونات مادية معينة.
تم إنشاء المعلومات الواردة في هذا المستند من الأجهزة الموجودة في بيئة معملية خاصة. بدأت جميع الأجهزة المُستخدمة في هذا المستند بتكوين ممسوح (افتراضي). إذا كانت شبكتك قيد التشغيل، فتأكد من فهمك للتأثير المحتمل لأي أمر.
معلومات أساسية
متطلبات التكوين
بمجرد أن يتم التثبيت، فإن هذه الملفات مطلوبة:
- ملف التكوين هو
/etc/rsyslog.conf
.
- الدليل المعرف بملف (ملفات) تكوين محدد هو
/etc/rsyslog.d/
.
بالنسبة لهذا التكوين، أستخدم خدمة rsyslog التي تكون متاحة بشكل افتراضي في العديد من برامج لينوكس. في حالة عدم توفرها على الخادم، قم بتنزيلها كما يلي (RHEL/CentOS):
yum install rsyslog
باستخدام NSO 5.1، عناصر syslog-server التي كانت جزءا من ncs.conf
الملف الذي تم جعله قديما.
ملاحظة: تمت إزالة دعم syslog عبر بروتوكول UDP للامتثال لمتطلبات أمان Cisco. الافتراضي syslog
من خلال libc syslog(3)
لا يزال متوفرا.
لإعادة توجيه سجلات NSO إلى خادم بعيد، ارجع إلى ملف قراءة ترحيل NSO syslog واستخدام تكوين ترحيل syslog daemon.
التكوين
يلزم وجود مجموعتين من ملفات التكوين للتكوين. أحدهما على الخادم حيث يتم تشغيل NSO، والمرسل في هذه الحالة، والآخر على جهاز الاستقبال (الخادم البعيد) الذي يقوم بتخزين جميع السجلات.
الخطوة 1: تحقق من أن ncs.conf
يحتوي الملف على هذا المقطع:
<logs>
<syslog-config>
<facility>daemon</facility>
</syslog-config>
...
</logs>
الخطوة 2: قم بتكوين /etc/rsyslog.conf
على النحو التالي:
- تحت
#### RULES ####
؛ قسم إضافة:
*.* @remote_ip
على سبيل المثال:
*.* @10.127.200.61
يوجه هذا خط ال rsyslog خدمة أن أيضا redirect 'all' مادة حفازة سجل إلى المضيف بعيد في ال يعين ip.
الخطوة 3: إضافة ملف جديد في /etc/rsyslog.d/
المسار كما هو موضح في المثال التالي.
- الملف الجديد هو ملف تكوين لإبلاغ R
syslog daemon
تفاصيل حول الملفات التي سيتم إرسالها عبر الشبكة إلى الخادم البعيد.
على سبيل المثال:
$ModLoad imfile
$InputFileName /var/log/ncs/devel.log
$InputFileTag devel:
$InputFileStateFile stat-devel
$InputFileSeverity info
$InputFileFacility local6
$InputRunFileMonitor
...
- بمجرد تعريف كل الملفات واحتوائها على تفاصيل، يمكنك تحديد أين يتم إرسال الملفات عبر البروتوكول:
# Send over UDP
local6.* @remote_ip:port
على سبيل المثال:
local6.* @10.127.200.61:514
الخطوة 4: إعادة تشغيل rsyslog
الخدمة:
service rsyslog restart
ملاحظة: يجب تنفيذ الخطوات من 2 إلى 4 على المرسل، أي الخادم حيث خدمة NSO قيد التشغيل.
الخطوة 5: قم بإلغاء التعليق على القسم الخاص ب UDP/TCP استنادا إلى متطلباتك في /etc/rsyslog.conf
ملف:
$ModLoad imudp
$UDPServerRun 514
ملاحظة: 514 هو المنفذ المستخدم لهذا النقل.
الخطوة 6: تعديل /etc/rsyslog.conf
ملف. إضافة البنود تحت ###MODULES###
القسم:
$template FileTemplate,"/var/log/ncs-server/%programname%.log"
if $programname startswith 'devel' then -?FileTemplate
if $programname startswith 'audit' then -?FileTemplate
if $programname startswith 'ncs' then -?FileTemplate
if $programname startswith 'ncs-java-vm' then -?FileTemplate
if $programname startswith 'ncserr' then -?FileTemplate
ملاحظة: يمكنك إستخدام اسم ncs-server للدليل الخاص بك.
في هذه الخطوة، يتم تحديد القواعد لتخزين السجلات بشكل محدد إلى NSO في موقع معين.
الخطوة 7: إعادة تشغيل rsyslog
الخدمة:
service rsyslog restart
ملاحظة: يجب تنفيذ الخطوات من 5 إلى 7 على جهاز الاستقبال، الخادم البعيد، حيث من المزمع تخزين السجلات.
تكوينات إضافية
يجب إعداد وظيفة ترحيل برنامج Syslog Daemon باستخدام هذه الخطوات. ومع ذلك، في بيئة الإنتاج، يتم عادة تمكين خدمة جدار الحماية و SELinux. وفي حالة تمكينها، لا يتم تخزين السجلات عن بعد. للتأكد من أن هذا لا يسبب أي مشاكل، يلزمك إضافة هذه التكوينات على كلا الخادمين:
semanage port -a -t syslogd_port_t -p udp 514
firewall-cmd --add-port=514/udp --permanent
firewall-cmd --reload
التحقق
إذا تم اتباع الخطوات بشكل صحيح، فإن syslog
يتم إعداد الخادم عن بعد. للتحقق من ذلك:
على الخادم البعيد:
nc -l -u -p 514
من المرسل:
logger "Message from client"
يجب أن يكون الخادم البعيد قد تلقى هذه الرسالة:
May 11 22:12:10 nso-recreate root: Message from client
استكشاف الأخطاء وإصلاحها
في الحالات التي يكون فيها الترحيل غير ناجح، تحتاج إلى التحقق من ملفات التكوين مرة أخرى.
ومن المفيد أيضا تأكيد حالة وحدة التخزين المتصلة بالشبكة rsyslog
:
systemctl status ncs.service
Expected output: [root@nso-recreate ncs]# systemctl status ncs.service ● ncs.service - LSB: NCS Loaded: loaded (/etc/rc.d/init.d/ncs; bad; vendor preset: disabled) Active: active (runnin) since Tue 2022-05-10 21:55:59 EDT; 24h ago ... No other lines in red in the status output.
service rsyslog status
Expected output: [root@nso-recreate ncs]# service rsyslog status Redirectin to /bin/systemctl status rsyslog.service ● rsyslog.service - System Loggin Service Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled) Active: active (runnin) since Wed 2022-05-11 01:12:08 EDT; 21h ago ... No other lines in red in the status output.
يمكنك التحقق من قواعد جدار الحماية أو تكوينات SELinux. يمكن لهذه العناصر حظر نقل السجل إلى الوجهة البعيدة.
systemctl status firewalld.service
sestatus