Ad Widget

Collapse

zabbix 4.0 migration from mysql to postgresql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oleg9301
    Junior Member
    • Oct 2019
    • 1

    #1

    zabbix 4.0 migration from mysql to postgresql

    Hello Guys!

    Is there any manual, how to migrate to DB postgresql?

    I was trying to do next:

    apt-get download zabbix-server-pgsql
    dpkg -x zabbix-server-pgsql_* ./zabbix-server-pgsql

    gzip -dc ./zabbix-server-pgsql/usr/share/doc/zabbix-server-pgsql/create.sql.gz > schema.sql
    sed -n '/CREATE.*/,/INSERT.*$/p' schema.sql | head -n-1 > createonly.sql
    grep ALTER schema.sql > alter.sql

    su -u postgres createuser --pwprompt zabbix
    su -u postgres createdb -O zabbix zabbix
    cat > zabbix.load << EOF
    LOAD DATABASE
    FROM mysql://zabbix:zabbix_password@localhost/zabbix
    INTO postgresql://zabbix:zabbix_password@localhost/zabbix
    WITH include no drop,
    truncate,
    create no tables,
    create no indexes,
    no foreign keys,
    reset sequences,
    data only
    SET maintenance_work_mem TO '128MB', work_mem to '12MB'
    ALTER SCHEMA 'zabbix' RENAME TO 'public'
    BEFORE LOAD EXECUTE createonly.sql
    AFTER LOAD EXECUTE alter.sql;
    EOF

    pgloader zabbix.load



    And when execute pgloader i have next error:

    2019-10-01T07:20:22.164000Z ERROR Database error 42830: "hosts" ,
    QUERY: ALTER TABLE ONLY hosts ADD CONSTRAINT c_hosts_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid)
    2019-10-01T07:20:22.164000Z FATAL An unhandled error condition has been signalled:
    Database error 42830: "hosts" ,
    QUERY: ALTER TABLE ONLY hosts ADD CONSTRAINT c_hosts_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid)



    OR

    psql -d zabbix < alter.sql
    ERROR: there is no uniqueness constraint in the target 'hosts' external table corresponding to these keys

    Last edited by oleg9301; 01-10-2019, 14:52.
  • arielzn
    Junior Member
    • Jan 2020
    • 1

    #2
    Hello,

    I'm trying to do the same procedure and still didn't converge to a working .load file .

    Did you finally manage to achieve the migration ?



    Comment

    Working...