التثبيت
المتطلبات الأساسية
يلزم توفر خادم قاعدة بيانات PostgreSQL. يجب تثبيت غلاف البيانات الخارجية على مثيل الخادم نفسه الذي يعمل عليه خادم قاعدة البيانات.
يرجى الإبقاء على الدليل الافتراضي PG_HOME في /var/lib/pgsql وتجنب نقله. كذلك، لا تقم بإنشاء نقاط تحميل إضافية داخل هذا الدليل (على سبيل المثال، تحميل /var/lib/pgsql/17/data من جهاز مختلف). قد يؤدي تغيير التخطيط بهذه الطريقة إلى تعقيد ترقيات PostgreSQL المستقبلية بشكل كبير. بدلاً من ذلك، قم بتحميل /var/lib/pgsql مباشرةً من جهاز آخر أو استخدم مساحات جداول إضافية كما هو موضح أدناه.
التثبيت القياسي
تثبيت RPM من مستودع SKOOR
إذا كان يجب تثبيت StableNet FDW لإصدار SKOOR Major محدد (مثل 8)، فاستخدم
dnf install "eranger-stablenet-fdw-8.*"
وإلا فاستخدم
dnf install "eranger-stablenet-fdw"
لإعداد تطبيق SKOOR لاستخدام StableNet FDW، يمكن استخدام البرنامج النصي init-data-source.py.
python3 /opt/stablenet-fdw/init-data-source.py -h
usage: init-data-source.py [-h] -w WEBSERVICE [-t TABLESPACE_ROOT]
[-d DATABASE_CONNECTION]
[--database-name DATABASE_NAME]
[--database-owner DATABASE_OWNER]
[--database-password DATABASE_PASSWORD]
Initializes StableNet data source in Skoor
optional arguments:
-h, --help show this help message and exit
-w WEBSERVICE, --webservice WEBSERVICE
StableNet webservice URL (usually something like
https://<host>:5443/api/1)
-t TABLESPACE_ROOT, --tablespace-root TABLESPACE_ROOT
Root directory for PostgreSQL tablespace folders.
--database-name DATABASE_NAME
PostgreSQL database name for StableNet FDW.
--database-owner DATABASE_OWNER
PostgreSQL role/user owning the StableNet database.
--database-password DATABASE_PASSWORD
Password for the PostgreSQL owner role.
تكون القيمة الافتراضية لاسم قاعدة البيانات والمالك وكلمة المرور هي infosim، وتكون القيمة الافتراضية لـ tablespace-root هي /var/lib/pgsql.
مثال على الاستخدام:
sudo python3 /opt/stablenet-fdw/init-data-source.py -w https://<STABLENET_HOST>:5443/api/1
يقوم هذا البرنامج النصي بأتمتة عملية الإعداد من خلال تنفيذ العمليات التالية:
تهيئة SKOOR Auth وStableNet FDW عن طريق تطبيق الوسيطة
--webservice.إنشاء مساحة جداول في المسار المحدد بواسطة
--tablespace-root.إنشاء قاعدة بيانات PostgreSQL جديدة داخل مساحة الجداول تلك.
تهيئة الجداول الخارجية.
ربط SKOOR بقاعدة البيانات الجديدة كمصدر بيانات.
استيراد البرامج النصية للمزامنة واستعلامات البيانات القياسية.
التكوين
بعد تغيير التكوين، يجب إعادة تشغيل خادم PostgreSQL.
systemctl restart postgresql-17
ملف التكوين
/etc/stablenet-fdw/stablenet-fdw.conf
الحد الأدنى للتكوين
يعد تعيين الإعدادات التالية إلزامياً للحصول على تثبيت يعمل بشكل صحيح.
[global]
default_user =
# Default user name for the StableNet® API.
# This is used in case no authorization
# is provided by the SQL client.
default_password =
# Default password for the StableNet® API.
# This is used in case no authorization
# is provided by the SQL client.
تتطلب بعض إصدارات Oracle الأقدم تثبيت مكتبة عميل Oracle على النظام. قم بتثبيتها باستخدام أحدث مثبت Oracle Instant Client وقم بتكوين المسار
#oracle_client_lib_dir =
# Path to the Oracle client library directory.
# This is used to load the Oracle client library
# for the Oracle database connection.
# If omitted, the thin client is used which might have
# problems connectiong to older Oracle databases.
إعداد نفق autossh للوصول إلى قاعدة بيانات StableNet MySQL
المتطلب الأساسي:
لا يلزم إنشاء النفق إلا إذا كان اتصال قاعدة بيانات MySQL في /opt/stablenet/snmw/wildfly/standalone/configuration/standalone.xml يشير إلى localhost. في هذه الحالة، يمر الاتصال عبر نقطة نهاية النفق المحلية، والتي يتم توجيهها إلى خادم StableNet. إذا تم تعيين عنوان IP الخاص بـ StableNet مباشرةً هناك، فسيتم تجاوز النفق ولا تكون هناك حاجة إليه.
إذا تم إعداد قاعدة بيانات StableNet على الخادم نفسه الذي يعمل عليه SKOOR، فيمكنك ببساطة تخطي هذا الإعداد.
إنشاء مفتاح SSH للمستخدم skoor (لا تقم بتعيين عبارة مرور):
sudo -u eranger ssh-keygen -t ed25519
طباعة المفتاح العام ونسخه:
sudo -u eranger cat ~eranger/.ssh/id_ed25519.pub
تسجيل الدخول إلى الخادم المستهدف (StableNet) وإضافة المفتاح
mkdir -p ~/.sshchmod 700 ~/.sshecho "<public-key>" >> ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keysثم تسجيل الخروج من الخادم المستهدف
اختبار تسجيل الدخول (من خادم SKOOR، دون مطالبة بكلمة مرور)
sudo -u eranger ssh <user>@<stablenet-ip>
تثبيت autossh (على خادم SKOOR)
sudo dnf install autossh
إنشاء ملف خدمة systemd
المسار:
/etc/systemd/system/stablenet-mysql-tunnel.serviceملاحظة: تحقق من مسار autossh أولاً باستخدام
which autosshوأدرج النتيجة في ExecStart
[Unit] Description=SSH tunnel to StableNet MySQL Database After=sshd.service [Service] ExecStart=/bin/autossh -M 22023 -N -L 3306:localhost:3306 <user>@<stablenet-ip> Restart=always RestartSec=10 User=eranger [Install] WantedBy=multi-user.target
تمكين الخدمة وبدء تشغيلها
systemctl daemon-reload
systemctl enable stablenet-mysql-tunnel
systemctl start stablenet-mysql-tunnel
التحقق من الحالة
systemctl status stablenet-mysql-tunnel
النتيجة: يتم توجيه المنفذ المحلي 3306 على خادم SKOOR عبر نفق SSH إلى منفذ MySQL (3306) الخاص بخادم StableNet. استبدل العنصرين النائبين <public-key> و<stablenet-ip> وفقاً لذلك.
اتصال قاعدة البيانات
[webservice] # use te form werbservice_<server_id>
# to configure multiple StableNet® servers
# (see below).
url =
# URL of the StableNet® API
# Usually something like https://<stablenet-host>:5443/api/1
database_connection =
# Connection string to the StableNet® database.
# This is used for the measurement data sync.
# The connection string must be in the format:
# MySQL: mysql+pymysql://<user>:<password>@<host>:3306/<database>
# Oracle: oracle+oracledb://<user>:<password>@<host>:1521/?service_name=<service>
# Connection info can be found on the StableNet server in
# /opt/stablenet/snmw/wildfly/standalone/configuration/standalone.xml (<datasources>).
# It's usually a good idea to use a different user and service than the one used by StableNet.
تصفية القياسات / المقاييس
للحد من كمية البيانات التي يلزم مزامنتها من قاعدة بيانات StableNet، قد يكون من المفيد تكوين بعض عوامل التصفية أو إلغاء تنشيط بعض أنواع القياسات بالكامل.
#sync_ping_data = true
# Sync ping measurement data from the StableNet® database.
# Defaults to true.
#sync_snmp_data = true
# Sync SNMP measurement data from the StableNet® database.
# Defaults to true.
#sync_usrscript_data = true
# Sync usrscript measurement data from the StableNet® database.
# Defaults to true.
#sync_external_data = true
# Sync external measurement data from the StableNet® database.
#sync_derived_data = false
# Sync derived measurement data from the StableNet® database.
#ping_measurement_filter =
# Filter for the ping measurement.
#snmp_measurement_filter =
# Filter for the SNMP measurement.
#snmp_indexes =
# List of SNMP indexes to be used for the SNMP measurement.
# This is the number part of the metric key, e.g. #1234 -> 1234
#snmp_state_agg_measurements =
# Comma separated list of template name / metric_key pairs of measurements
# which should have state aggregation enabled.
# Example: Interface Relative IPMPLS 64Bit#1234,template2#5678
#usrscript_measurement_filter =
# Filter for the usrscript measurement.
#usrscript_indexes =
# List of usrscript indexes to be used for the usrscript measurement.
# This is the number part of the metric key, e.g. #1234 -> 1234
#usrscript_state_agg_measurements =
# Comma separated list of template name / metric_key pairs of measurements
# which should have state aggregation enabled.
# Example: Interface Relative IPMPLS 64Bit#1234,template2#5678
#external_measurement_filter =
# Filter for the external measurement.
#external_indexes =
# List of external indexes to be used for the external measurement.
# This is the number part of the metric key, e.g. #1234 -> 1234
#external_state_agg_measurements =
# Comma separated list of template name / metric_key pairs of measurements
# which should have state aggregation enabled.
# Example: Y.1731#1234,template2#5678
#derived_measurement_filter =
# Filter for the derived measurement.
#derived_indexes =
# List of derived indexes to be used for the derived measurement.
# This is the number part of the metric key, e.g. #1234 -> 1234
#derived_state_agg_measurements =
# Comma separated list of template name / metric_key pairs of measurements
# which should have state aggregation enabled.
# Example: Y.1731#1234,template2#5678
سياسات الاحتفاظ
يمكن تكوين مدة تخزين البيانات لكل تجميع.
[retention_days]
#raw = 1
#minutely = 1
#5_minutely = 14
#15_minutely = 31
# ~1 month
#hourly = 93
# ~3 months
#daily = 365
# ~1 years
#weekly = 365
# ~1 years
#monthly = 1825
# ~5 years
#quarterly = 1825
# ~5 years
#yearly = 3650
# ~10 years
الإعدادات المتقدمة
توجد العديد من الخيارات الإضافية التي يمكن استخدامها لضبط أداء StableNet FDW بدقة. يتم وصف هذه الإعدادات في ملف التكوين مباشرةً.
استخدام متغيرات البيئة
يمكن أيضاً توفير الخيارات عبر متغيرات البيئة باستخدام البادئة STABLENET_FDW_WEBSERVICE_ واسم الخيار بأحرف كبيرة (مثل STABLENET_FDW_WEBSERVICE_URL). بالنسبة لإعدادات global، يجب حذف GLOBAL من مفتاح متغير البيئة (مثل STABLENET_FDW_DEFAULT_USER ).
url هو عنوان URL الأساسي لخدمة الويب الخاصة بواجهة برمجة تطبيقات StableNet®. ويكون عادةً بالصيغة https://<host>:5443/api/1.
خوادم StableNet متعددة
يمكن تعريف مثيلات StableNet® متعددة باستخدام أقسام webservice متعددة ذات لاحقات server_id فريدة. يُستخدم server_id كمعرّف داخلي، على سبيل المثال للحصول على سلسلة التخويل المطابقة من SKOOR Auth. يجب تعيين server_name مناسب يُستخدم لتعريف الخادم في الجداول الخارجية والمجمّعة. يمكن تكوين ذلك أيضاً باستخدام متغيرات البيئة (مثل STABLENET_FDW_WEBSERVICE_URL_TEST وSTABLENET_FDW_WEBSERVICE_SERVER_NAME_TEST).
[webservice_production] server_name = Production Server url = https://stablenet.prod:5443/api/1 database_connection = ... [webservice_staging] server_name = Staging Server url = https://stablenet.staging:5443/api/1 database_connection = ...
الإدخال المقابل في SKOOR Auth (/etc/opt/eranger/eranger-auth.conf)
[provider.1] type = stablenet name = StableNet® webservice_url_production = https://stablenet.prod:5443/api/1 webservice_url_staging = https://stablenet.staging:5443/api/1
اختبار الاتصال
psql -h localhost -p 5432 -U infosim -d infosim -c "SELECT * from stablenet.stablenet_info;"
ينبغي أن يُرجع هذا عدد الأجهزة في مثيل StableNet® المتصل.