التركيب
المتطلبات الأساسية
يلزم وجود قاعدة بيانات PostgreSQL مع مستخدم مخول بتعديل كائنات قاعدة البيانات. يجب تثبيت غلاف البيانات الخارجية (foreign data wrapper) على نفس مثيل الخادم الذي يعمل عليه خادم قاعدة البيانات.
يرجى الحفاظ على المجلد الافتراضي لـ «PG_HOME» في /var/lib/pgsql وتجنب نقله. كما يجب عدم إنشاء نقاط تثبيت إضافية داخل هذا المجلد (على سبيل المثال، تثبيت /var/lib/pgsql/17/data من جهاز آخر). قد يؤدي تغيير التخطيط بهذه الطريقة إلى تعقيد عمليات ترقية PostgreSQL المستقبلية بشكل كبير. بدلاً من ذلك، قم بتثبيت /var/lib/pgsql مباشرةً من جهاز آخر أو استخدم مساحات جداول إضافية كما هو موضح أدناه.
مثال: إنشاء قاعدة البيانات infosim المملوكة للدور infosim:
export DB_NAME=infosim
mkdir -p /var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/tab_space/${DB_NAME} \
/var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/idx_space/${DB_NAME} && \
chown -R postgres:postgres /var/lib/pgsql/custom/user_tblspc
psql -Upostgres -c "CREATE ROLE $DB_NAME WITH LOGIN PASSWORD '$DB_NAME';"
psql -Upostgres -c "CREATE TABLESPACE ${DB_NAME}_tab OWNER $DB_NAME \
LOCATION '/var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/tab_space/$DB_NAME';"
psql -Upostgres -c "CREATE TABLESPACE ${DB_NAME}_idx OWNER $DB_NAME \
LOCATION '/var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/idx_space/$DB_NAME';"
psql -Upostgres -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_NAME TEMPLATE template0 \
TABLESPACE ${DB_NAME}_tab ENCODING 'UTF8' LC_COLLATE 'de_CH.UTF-8' LC_CTYPE 'de_CH.UTF-8';"
التثبيت القياسي
تثبيت حزمة RPM من مستودع SKOOR
إذا كان يجب تثبيت StableNet FDW لإصدار رئيسي معين من SKOOR (مثل 8)، فاستخدم
dnf install "eranger-stablenet-fdw-8.*"
وإلا فاستخدم
dnf install "eranger-stablenet-fdw"
التكوين
بعد إجراء تغيير في التكوين، يجب إعادة تشغيل خادم 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 skoor ssh-keygen -t ed25519
اطبع المفتاح العام وانسخه:
sudo -u skoor cat /home/skoor/.ssh/id_ed25519.pub
قم بتسجيل الدخول إلى الخادم الهدف (StableNet) وأضف المفتاح
mkdir -p ~/.sshchmod 700 ~/.sshecho "<public-key>" >> ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keysثم قم بتسجيل الخروج من الخادم المستهدف
اختبر عملية تسجيل الدخول (من خادم SKOOR، دون مطالبة بكلمة مرور)
sudo -u skoor ssh guest@<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=skoor [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 من مفتاح 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
تهيئة الجداول الخارجية
قم بتهيئة الجداول الخارجية التي يحتاجها غلاف البيانات الخارجية.
/opt/stablenet-fdw/init-foreign-tables.sh -h <host> -p <port> -d <database> -U <user> -o <owner>
على سبيل المثال
/opt/stablenet-fdw/init-foreign-tables.sh -U postgres -h localhost -p 5432 -d infosim -o infosim
يجب تنفيذ هذا الأمر بعد كل تحديث لـ eranger-stablenet-fdw للحصول على تعريفات الجداول الجديدة.
اختبار الاتصال
psql -h localhost -p 5432 -U infosim -d infosim -c "SELECT * from stablenet.stablenet_info;"
ينبغي أن يُرجع هذا الأمر عدد الأجهزة الموجودة في مثيل StableNet® المتصل.