Ad Widget

Collapse

Using Zabbix with a remote PSQL Database - how to install SQL scripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SunnyK
    Junior Member
    • Dec 2021
    • 7

    #1

    Using Zabbix with a remote PSQL Database - how to install SQL scripts?

    Zabbix 7.0 and PostgreSQL v16 both new installs on Rock 9

    I understand that SQL scripts (for creating database schema and inserting the dataset) need to be run whether you have a DB local to Zabbix, or a remote DB. I have a new Postgres server and would like to use that. When I install the package it installs without error, however it doesn't seem to deliver the contents expected.

    On the PSQL server
    Code:
    rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-7.0-5.el9.noarch.rpm
    Code:
    dnf install zabbix-sql-scripts
    Code:
    Installed: zabbix-sql-scripts-7.0.3-release1.el9.noarch Complete!
    Code:
    [postgres@postgres zabbix-sql-scripts]$ pwd
    /usr/share/doc/zabbix-sql-scripts
    [postgres@postgres zabbix-sql-scripts]$ ll
    total 1776
    -rw-r--r--. 1 root root      98 Aug 15 04:31 AUTHORS
    -rw-r--r--. 1 root root 1769460 Aug 19 10:21 ChangeLog
    -rw-r--r--. 1 root root   34523 Aug 15 04:31 COPYING
    -rw-r--r--. 1 root root      53 Aug 15 04:31 NEWS
    -rw-r--r--. 1 root root      26 Aug 15 04:31 README
    Next I would be looking to run something like
    Code:
    zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbixuser psql zabbixdb
    But clearly that path isn't going to work as there is nothing like
    Code:
    /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz
    Am I looking in the right place?

    These scripts have been installed OK on the Zabbix box when I used the command
    Code:
    dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-agent2 zabbix-web-service zabbix-selinux-policy
    but as I ran them all at once I don't know which, I would have assumed zabbix-sql-scripts? so I could just copy them over to the PSQL server but curious as to what I am doing wrong?
  • solution
    Senior Member
    • Jun 2020
    • 269

    #2
    go to
    Zabbix is being downloaded over 4 000 000 times every year for a reason. Download and install Zabbix for free and try it yourself!


    Step 1: Choose your platform and components

    Step 2c: Database instructions


    Wellington

    Comment


    • SunnyK
      SunnyK commented
      Editing a comment
      Thanks but unless I am being really dense;

      Step 2c
      - Create initial database on your db host which in my case is my remote psql server e.g. postgres.domain.local
      - On the Zabbix server zabbix.domain.local, which isn't where my database is, import schema and data. 'You will be promoted for your newly created password' - no I wont since I created those accounts on my other box
  • solution
    Senior Member
    • Jun 2020
    • 269

    #3
    Step 2c assumes that Zabbix Server and Database are on the same host.

    For those using separate hosts, copy server.sql.gz to Host DB or adapt the psql command to connect to the remote host.

    Wellington

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #4
      Originally posted by SunnyK
      Code:
      [postgres@postgres zabbix-sql-scripts]$ pwd
      /usr/share/doc/zabbix-sql-scripts
      [postgres@postgres zabbix-sql-scripts]$ ll
      total 1776
      -rw-r--r--. 1 root root 98 Aug 15 04:31 AUTHORS
      -rw-r--r--. 1 root root 1769460 Aug 19 10:21 ChangeLog
      -rw-r--r--. 1 root root 34523 Aug 15 04:31 COPYING
      -rw-r--r--. 1 root root 53 Aug 15 04:31 NEWS
      -rw-r--r--. 1 root root 26 Aug 15 04:31 README
      This in normal... its the DOC directory...
      Next I would be looking to run something like
      Code:
      zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbixuser psql zabbixdb
      But clearly that path isn't going to work as there is nothing like
      Code:
      /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz
      Am I looking in the right place?
      you are mixing places... some from ../doc/... some not... The latter shold be present and you should use it instead of the one with /doc/ in the path...
      Code:
      zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbixuser psql zabbixdb
      I specifically downloaded that zabbix-sql-scripts-7.0.3-release1.el9.noarch.rpm package and unpacked it...

      Code:
      rpm2cpio zabbix-sql-scripts-7.0.3-release1.el9.noarch.rpm | cpio -idmv
      ./usr/share/doc/zabbix-sql-scripts
      ./usr/share/doc/zabbix-sql-scripts/AUTHORS
      ./usr/share/doc/zabbix-sql-scripts/COPYING
      ./usr/share/doc/zabbix-sql-scripts/ChangeLog
      ./usr/share/doc/zabbix-sql-scripts/NEWS
      ./usr/share/doc/zabbix-sql-scripts/README
      ./usr/share/zabbix-sql-scripts/mysql/option-patches/history_upgrade_prepare.sql
      ./usr/share/zabbix-sql-scripts/mysql/proxy.sql
      ./usr/share/zabbix-sql-scripts/mysql/server.sql.gz
      ./usr/share/zabbix-sql-scripts/postgresql/option-patches/history_upgrade_prepare.sql
      ./usr/share/zabbix-sql-scripts/postgresql/proxy.sql
      ./usr/share/zabbix-sql-scripts/postgresql/server.sql.gz
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade_log.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade_prepare.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade_str.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade_text.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/history_upgrade_uint.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/with-compression/trends_upgrade.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade_log.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade_prepare.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade_str.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade_text.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/history_upgrade_uint.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/option-patches/without-compression/trends_upgrade.sql
      ./usr/share/zabbix-sql-scripts/postgresql/timescaledb/schema.sql
      ./usr/share/zabbix-sql-scripts/sqlite3/proxy.sql
      20966 blocks
      all needed scripts should be present...
      Last edited by cyber; 29-08-2024, 12:43.

      Comment

      • DikSoft
        Junior Member
        • Feb 2025
        • 1

        #5
        Don't forget to install proper pgsql client components to zabbix server, something like this:

        #apt install -y postgresql-client-common postgresql-client-15

        Comment

        Working...