التركيب

المتطلبات الأساسية

يلزم وجود خادم قاعدة بيانات PostgreSQL. ويجب تثبيت غلاف البيانات الخارجية على نفس مثيل الخادم الذي يعمل عليه خادم قاعدة البيانات.

يرجى الاحتفاظ بالدليل الافتراضي PG_HOME في /var/lib/pgsql وتجنب نقله. كما يجب عدم إنشاء نقاط تثبيت إضافية داخل هذا الدليل (على سبيل المثال، تثبيت /var/lib/pgsql/17/data من جهاز آخر). قد يؤدي تغيير التخطيط بهذه الطريقة إلى تعقيد عمليات ترقية PostgreSQL في المستقبل بشكل كبير. بدلاً من ذلك، قم بتثبيت /var/lib/pgsql مباشرةً من جهاز آخر أو استخدم مساحات جداول إضافية كما هو موضح أدناه.

التثبيت القياسي

تثبيت حزمة RPM من مستودع SKOOR

إذا كان يجب تثبيت StableNet FDW لإصدار رئيسي معين من SKOOR (مثل 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

تعمل هذه البرنامج النصي على أتمتة عملية الإعداد من خلال تنفيذ العمليات التالية:

  1. تكوين SKOOR Auth وStableNet FDW من خلال تطبيق الوسيطة --webservice.

  2. إنشاء مساحة جدول في المسار المحدد بواسطة --tablespace-root.

  3. ينشئ قاعدة بيانات PostgreSQL جديدة داخل مساحة الجدول تلك.

  4. تقوم بتهيئة الجداول الخارجية.

  5. يربط SKOOR بقاعدة البيانات الجديدة كمصدر للبيانات.

  6. يستورد نصوص برمجية المزامنة واستعلامات البيانات القياسية.

التكوين

بعد إجراء تغيير في التكوين، يجب إعادة تشغيل خادم 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، فما عليك سوى تخطي هذه الخطوة.

  1. قم بإنشاء مفتاح SSH للمستخدم skoor (لا تقم بتعيين عبارة مرور):

    1. sudo -u eranger ssh-keygen -t ed25519

  2. اطبع المفتاح العام وانسخه:

    1. sudo -u eranger cat ~eranger/.ssh/id_ed25519.pub

  3. قم بتسجيل الدخول إلى الخادم الهدف (StableNet) وأضف المفتاح

    1. mkdir -p ~/.ssh

    2. chmod 700 ~/.ssh

    3. echo "<public-key>" >> ~/.ssh/authorized_keys

    4. chmod 600 ~/.ssh/authorized_keys

    5. ثم قم بتسجيل الخروج من الخادم المستهدف

  4. اختبر عملية تسجيل الدخول (من خادم SKOOR، دون مطالبة بكلمة مرور)

    1. sudo -u eranger ssh <user>@<stablenet-ip>

  5. تثبيت autossh (على خادم SKOOR)

    1. sudo dnf install autossh

  6. أنشئ ملف خدمة systemd

    1. المسار: /etc/systemd/system/stablenet-mysql-tunnel.service

    2. ملاحظة: تحقق أولاً من مسار 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
  1. تمكين الخدمة وتشغيلها

    1. systemctl daemon-reload

    2. systemctl enable stablenet-mysql-tunnel

    3. systemctl start stablenet-mysql-tunnel

  2. تحقق من الحالة

    1. 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 من مفتاح ENV (على سبيل المثال: 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® المتصل.