กลุ่มชุมชนแลกเปลี่ยนความรู้แบ่งปั่น และช่วยเหลือ ต่อการใช้งาน OpenSource Zabbix เพราะการแบ่งปัน นั้นยิ่งใหญ่กว่า.

TimescaleDB + PostgreSQL + Zabbix Installation on CentOS7 - ความท้าทายด้านประสิทธิภาพที่มากับการเก็บข้อมูลขนาดใหญ่

การติดตั้ง TimescaleDB + PostgreSQL + Zabbix บน CentOS7 - ความท้าทายด้านประสิทธิภาพที่มากับการเก็บข้อมูลขนาดใหญ่
(TimescaleDB + PostgreSQL + Zabbix Installation on CentOS7 - Performance-related challenge with big history and trend data.)

   ได้ยินข่าวมาซักพักแล้ว สำหรับ TimescaleDB (TSDB) ที่นำมาใช้งานกับ Zabbix โดยที่ TimescaleDB คือ เป็นส่วนเสริมของ PostgreSQL (PG) ที่มีการทำงานซึ่งเพิ่มประสิทธิภาพตามอนุกรมเวลาและการเพิ่มประสิทธิภาพการจัดการข้อมูลให้กับ PostgreSQL หรือ อีกนัยนึงก็คือมีการออกแบบมาพิเศษเพื่อให้มีประสิทธิภาพการทำงานสูงสุดสำหรับข้อมูลที่มีเวลามาเกี่ยวข้อง
   (Heard the news for a while for TimescaleDB that is used with Zabbix. TimescaleDB (TSDB) is a PostgreSQL (PG)  extension, which adds time series based performance and data management optimizations to a regular PostgreSQL database. In other words, it is specially designed to provide maximum performance for time series data.)

   ซึ่งใน Zabbix นั้น ตารางในฐานข้อมูลที่เกี่ยวข้องอย่างยิ่งยวดที่เกี่ยวข้องกับเวลาคือ history, history_uint, history_str, history_log, history_text, trends and trends_uint
   (The Zabbix's database tables that related with time series data are history, history_uint, history_str, history_log, history_text, trends and trends_uint.)

   โดย TSDB นั้นจะคล้ายคลึงกับ Table Partitioning (แต่ไม่ได้เหมือนกันทั้งหมด) สำหรับ TSDB จะมีการแบ่งข้อมูลในตารางซึ่งข้อมูลที่แบ่งดังกล่าวจะเรียกว่า chunks ตามที่ได้กำหนดเวลาไว้ว่าในแต่ละอันนั้นคือเวลาช่วงละเท่าใด ซึ่งการแบ่งดังกล่าวจะดำเนินการโดยฐานข้อมูลโดยอัตโนมัติตามช่าวงเวลาที่ได้กำหนดไว้
   (In TSDB is similar to Table Partitioning (but quit difference). TSDB splits this table into so-called chunks in accordance with conditions you specify. This think of chunks as of automatically managed table partitions. Every chunk has an associated time range.)

   ในการทำ Partitioning นั้น โดยทั่วไปใน Zabbix จะมีโพรเซสที่ดำเนินการคือ Housekeeper ทำจะมี batch กำเนินการทำ partitioning ของข้อมูล เพื่อแยกข้อมูลตามช่วงเวลาที่ได้กำหนดไว้ ซึ่งในช่วงเวลาที่ housekeeper ทำการ partitioning นั้น เมื่อมีการ insert/update/delete ในช่วงเวลาดังกล่าวโดย database syncer ก็อาจเกิดการ lock ตามการทำงานของ database อีกทั้งถ้าข้อมูลมีขนาดใหญ่ ก็ยิ่งทำให้การทำงานดังกล่าวยิ่งช้าลง
   (In partitioning process, the Zabbix has batch process named "Housekeeper" that partitioning the table by time condition. Then when the database transaction such as insert/update/delete to perform operation via database synced, it may cause of database lock. In case of big table data, it have more longer process time.)

   ข้อได้เปรียบของการใช้งาน TSDB ที่สำคัญหนึ่งในหลายๆ ข้อ คือ จะช่วยเพิ่มประสิทธิภาพของ history syncer และ housekeeper
   (The one of manybenefit of TSDB is it brings considerable performance improvements for Zabbix history syncer and housekeeper.)


ขั้นตอนการติดตั้ง Zabbix 4.2 + PostgreSQL 11 + TimescaleDB 1.3 บน CentOS 7 (แถมการติดตั้ง PHP 7.2)
(Step for install Zabbix 4.2 + PostgreSQL 11 + TimescaleDB 1.3 on CentOS 7 plus PHP 7.2)

1. Install required yum related package.
   # yum install yum-utils


2. Preparing for PHP 7.2 installation (The PHP 7.2 will be installing with Zabbix frontend installation step.)
   # yum install epel-release
   # yum-config-manager --enable remi-php72

------ PostgreSQL and TimescaleDB Section ------
3. Preparing for PostgreSQL and TimescaleDB installation
   # yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
 
   - Add following line into file named /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
      exclude=postgresql*

   - Add TimescaleDB's third party repository and install TimescaleDB, which will download any dependencies it needs from the PostgreSQL repo
   # cat > /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/7/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL

   # yum update


4. Installing PostgreSQL + TimescaleDB
   # yum install timescaledb-postgresql-11


5. Setting PG data directory to other location (other disk/partition for increasing performance and reliability management) e.g. target directory named is /data/pgsql

   - Create target directory
   # mkdir -p /data/pgsql
   # chown -R postgres:postgres /data/pgsql

   - Setting target directory in daemon
   # systemctl edit postgresql-10.service
      [Service]
      Environment=PGDATA=/data/pgsql/11/data

   - Crosscheck this file will be created
   # cat /etc/systemd/system/postgresql-11.service.d/override.conf
      [Service]
      Environment=PGDATA=/data/pgsql/11/data

   - Reload this setting
   # systemctl daemon-reload


6. Initial PostgreSQL database
    # /usr/pgsql-11/bin/postgresql-11-setup initdb
      Initializing database ... OK


7. Tuning databs
   # timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config --conf-path=/data/pgsql/11/data/postgresql.conf
   Using postgresql.conf at this path:
      /data/pgsql/11/data/postgresql.conf

   --> Answer yes for all questions.


8. Enable and Start PostgreSQL database
   # systemctl enable postgresql-11
   # systemctl start postgresql-11
   # systemctl status postgresql-11


------ Zabbix Section ------
9. Preparing for Zabbix installation
   # rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
   # yum-config-manager --enable rhel-7-server-optional-rpms
   # yum update


10. Installing Zabbix server
   # yum install zabbix-server-pgsql


11. Installing Zabbix frontend (PHP 7.2 will be installing with this step)
   # yum install zabbix-web-pgsql


12. Database preparation
   - Create PG database user name zabbixdbusr
   # sudo -u postgres createuser --pwprompt zabbixdbusr

   - Create database in PG named zabbix
   # sudo -u postgres createdb -O zabbixdbusr -E Unicode -T template0 zabbix

   - Import schema to database
   # zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbixdbusr psql zabbix

   - Enable TimescaleDB extension for zabbix database
   # echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix

   - Create TimescaleDB related table (Hypertable)
   # zcat /usr/share/doc/zabbix-server-pgsql*/timescaledb.sql.gz | sudo -u zabbixdbusr psql zabbix


13. Setting database credentials to related configuration
   # vi /etc/zabbix/zabbix_server.conf
      DBHost=127.0.0.1
      DBName=zabbix
      DBUser=zabbixdbusr
      DBPassword=<password>


14. Setting PG authentication
   # vi /data/pgsql/11/data/pg_hba.conf
      host zabbix zabbixdbusr 127.0.0.1/32 password


15. Restarting PostgreSQL for reloading above configuration
   # systemctl stop postgresql-11
   # systemctl start postgresql-11
   # systemctl status postgresql-11


16. Enable and Start Zabbix server
   # systemctl enable zabbix-server
   # systemctl start zabbix-server
   # systemctl status zabbix-server


17. Setting PHP configuration that requires Zabbix
   # vi /etc/php.ini
   max_execution_time 300
   memory_limit 128M
   post_max_size 16M
   upload_max_filesize 2M
   max_input_time 300
   max_input_vars 10000
   #always_populate_raw_post_data -1
   date.timezone Asia/Bangkok


18. Enable and Start HTPD web server
   # systemctl enable httpd
   # systemctl start httpd
   #systemctl status httpd


19. Goto URL http://YOURZABBIXIP/zabbix for completing frontend installation and following installed step.
   Database type: PostgreSQL
   Database host: 127.0.0.1
   Database port: 5432
   Database name: zabbix
   User: zabbixdbusr
   Password: <password>


*** Please considering SELinux ***

Reference:
[1] https://blog.zabbix.com/zabbix-time-series-data-and-timescaledb/6642/
[2] https://www.zabbix.com/documentation/4.2/manual/installation
[3] https://docs.timescale.com/v1.3/getting-started/installation/rhel-centos/installation-yum

Share:

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

 
Zabbix in Thailand
Facebook Group · 701 members
Join Group
กลุ่มนี้จัดตั้งขึ้นเพื่อแลกเปลี่ยนความรู้ของ zabbix ใครมีคู่มือ เทคนิค หรือ ปัญหา มาร่วมมือกันแก้ไขกันสำหรับชาวไทย -----------------------------------...
 

Popular

ค้นหาบล็อกนี้

Labels

Comments

Labels

Recent Posts