DB Wechsel mariaDB --> PostGreSQL

Hilfe zu Znuny Problemen aller Art
Post Reply
Ikkarus13
Znuny newbie
Posts: 42
Joined: 28 Sep 2016, 16:32
Znuny Version: 6.3.3
Real Name: Sascha Kunimünch
Company: Wetrok AG

DB Wechsel mariaDB --> PostGreSQL

Post by Ikkarus13 »

Hallo Zusammen,

ich will auf unserem Znuny 6.5.4 von MariaDB auf PostGreSQL wechseln. Habe dafür das CloneDB aus der Paketverwaltung installiert.
Wenn ich die Konvertierung mit dry-run teste sieht alles gut aus.

Code: Select all

[2024-07-01 15:04:51] Checking table web_upload_cache...
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x1B51A0 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x1E3A67 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x1B56F6 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x175877 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x3BBDBF4 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Unicode surrogate U+DF36 is illegal in UTF-8 at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x1FB838 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Unicode surrogate U+DF9E is illegal in UTF-8 at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x172176 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x11DDB2 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x158F7D is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x175BFB is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x1E0E78 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Unicode surrogate U+DAEB is illegal in UTF-8 at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x25B1E9C7 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x3378E9D is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x118B2C is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Unicode surrogate U+DFF2 is illegal in UTF-8 at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Unicode surrogate U+D9B7 is illegal in UTF-8 at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x127745 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[Mon Jul  1 15:04:51 2024] otrs.Console.pl: Code point 0x14D7A9 is not Unicode, may not be portable in print at /opt/znuny-6.5.4/Kernel/System/CloneDB/Driver/Base.pm line 325.
[2024-07-01 15:04:51] Checking table xml_storage...
Dry run successfully finished.
Done.
Wenn ich es dann aber laufen lasse, bekomme ich nach einiger Zeit folgende Meldung

Code: Select all

[Mon Jul  1 14:55:11 2024] otrs.Console.pl: DBD::Pg::db do failed: ERROR:  insert or update on table "ticket_history" violates foreign key constraint "fk_ticket_history_article_id_id"
[Mon Jul  1 14:55:11 2024] otrs.Console.pl: DETAIL:  Key (article_id)=(154710) is not present in table "article".
[Mon Jul  1 14:55:11 2024] otrs.Console.pl: CONTEXT:  SQL statement "ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)"
[Mon Jul  1 14:55:11 2024] otrs.Console.pl: PL/pgSQL function inline_code_block line 8 at SQL statement at /opt/znuny-6.5.4/Kernel/System/DB.pm line 497.
ERROR: OTRS-otrs.Console.pl-Maint::Database::Clone-32 Perl: 5.34.0 OS: linux Time: Mon Jul 1 14:55:11 2024

 Message: ERROR:  insert or update on table "ticket_history" violates foreign key constraint "fk_ticket_history_article_id_id"
DETAIL:  Key (article_id)=(154710) is not present in table "article".
CONTEXT:  SQL statement "ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)"
PL/pgSQL function inline_code_block line 8 at SQL statement, SQL: 'DO $$
BEGIN
IF NOT EXISTS (
    SELECT 1
    FROM pg_constraint
    WHERE LOWER(conname) = LOWER('FK_ticket_history_article_id_id')
    ) THEN
    ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_article_id_id FOREIGN KEY (article_id) REFERENCES article (id);
END IF;
END$$;
'

 Traceback (15142):
   Module: Kernel::System::CloneDB::Backend::PopulateTargetStructuresPost Line: 455
   Module: Kernel::System::Console::Command::Maint::Database::Clone::Run Line: 121
   Module: (eval) Line: 461
   Module: Kernel::System::Console::BaseCommand::Execute Line: 455
   Module: Kernel::System::Console::InterfaceConsole::Run Line: 81
   Module: bin/otrs.Console.pl Line: 37

Error: ERROR: Could not generate structures in target database!
[2024-07-01 14:55:11] Creating structures in target database (phase 2/2)
Leider kenne ich mich zu wenig mit den verschiedenen Datenbanken aus und habe auch im Internet keine Lösung gefunden. Hat hier vielleicht jemand einen Tipp?

Versionen:
Znuny: 6.5.4
Linux: Ubuntu 22.04.4 LTS
MariaDB: 10.6.18

Danke und viele Grüsse, Sascha
hkais
Znuny wizard
Posts: 365
Joined: 16 Apr 2016, 08:55
Znuny Version: see in post
Real Name: Hans
Contact:

Re: DB Wechsel mariaDB --> PostGreSQL

Post by hkais »

Hi Sascha,

generell die Frage, warum möchtest Du von MariaDB to PostgreSQL wechseln?

Zu deiner Frage

Code: Select all

ticket_history" violates foreign key constraint "fk_ticket_history_article_id_id"
Key (article_id)=(154710) is not present in table "article".
Du hast inkonsistente Daten in der Datenbank
in der article tabelle findet er den Key 154710 bzw. den Primärschlüssel nicht und lässt dich daher den Datensatz nicht importieren.

Jetzt kann es sein, dass Du den Article in der Vergangenheit gelöscht hast aber die History noch besteht.
@Znuny-devs: Ich bin mir nicht sicher ob es hierzu in eines der vergangenen Znuny Version nicht eine Bereinigung gab oder geben soll?!?

Um das Problem zu beheben, musst Du wieder Konsistenz zwischen ticket-history und article herstellen.
Wenn unklar einfach nochmals melden.
Elected 2022-06 as an IT Governance Portal Expert. The portal for Znuny, OTRS and OTOBO power users and admins
Specialized for AI-based Solutions with Znuny

IT Governance Portal
Ikkarus13
Znuny newbie
Posts: 42
Joined: 28 Sep 2016, 16:32
Znuny Version: 6.3.3
Real Name: Sascha Kunimünch
Company: Wetrok AG

Re: DB Wechsel mariaDB --> PostGreSQL

Post by Ikkarus13 »

Hi,

danke für die erste Antwort. Den Wechsel will ich vornehmen, damit ich die Datenbank besser mit Veeam Backupen kann. PostgreSQL wird voll unterstützt, MariaDB leider nicht.

Gibt es einen Befehl oder eine Vorgehensweise, wie ich die Datenbank wieder konsistent bekomme?

Viele Grüsse, Sascha
hkais
Znuny wizard
Posts: 365
Joined: 16 Apr 2016, 08:55
Znuny Version: see in post
Real Name: Hans
Contact:

Re: DB Wechsel mariaDB --> PostGreSQL

Post by hkais »

Ikkarus13 wrote: 01 Jul 2024, 16:34 danke für die erste Antwort. Den Wechsel will ich vornehmen, damit ich die Datenbank besser mit Veeam Backupen kann. PostgreSQL wird voll unterstützt, MariaDB leider nicht.
Ich nehme an Du kennst die Pre- und Post-Scripts bei Veeam?
Ich mache das immer stumpf, wenn es die Backupfenster erlauben (downtime). backup-pre-script, MariaDB stoppen, backup durchführen, post-script, mariadb starten.

Und die Integration von mysql https://helpcenter.veeam.com/docs/agent ... tml?ver=60 kennst Du vermutlich auch?
Ikkarus13 wrote: 01 Jul 2024, 16:34 Gibt es einen Befehl oder eine Vorgehensweise, wie ich die Datenbank wieder konsistent bekomme?
Nicht von Haus aus. Bei alten OTRS Installation ist es leider so, dass früher die Entwickler nicth sonderlich gut auf die DB Konsistenz geachtet haben...
Manchmal kommen dann noch Admins dazu, die dann Daten direkt löschen...

Damit müsstest Du dich von Tabelle zu Tabelle hangeln können:
https://stackoverflow.com/questions/382 ... ted-tables

ABER: wird i.d.R. aufwendig!
Elected 2022-06 as an IT Governance Portal Expert. The portal for Znuny, OTRS and OTOBO power users and admins
Specialized for AI-based Solutions with Znuny

IT Governance Portal
root
Administrator
Posts: 4250
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: DB Wechsel mariaDB --> PostGreSQL

Post by root »

hkais wrote: 01 Jul 2024, 16:49
Ikkarus13 wrote: 01 Jul 2024, 16:34 Gibt es einen Befehl oder eine Vorgehensweise, wie ich die Datenbank wieder konsistent bekomme?
Manchmal kommen dann noch Admins dazu, die dann Daten direkt löschen...
Hi

Das ist in der Regel das Problem und weniger die ursprüngliche Entwicklung. Und Foreign Keys wurde mit der InnoDB bei MySQL eingeführt. Selbst jetzt tauchen bei mir immer noch Versionen mit MyISAM aus.
Und: wer das Update auf die 6.0 ordentlich durchgeführt hat, der hat auch dieses Problem nicht mehr.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Ikkarus13
Znuny newbie
Posts: 42
Joined: 28 Sep 2016, 16:32
Znuny Version: 6.3.3
Real Name: Sascha Kunimünch
Company: Wetrok AG

Re: DB Wechsel mariaDB --> PostGreSQL

Post by Ikkarus13 »

Hi,

wollte halt auf PostGreSQL wechseln, weil man damit auch die Transactional Logs Backupen kann. Das geht bei MySQL nicht. Aber wenn ich so nen Aufwand habe, bis ich den Fehler finde, lasse ich das lieber.

Danke für eure Hilfe.

Gruss, Sascha
Ikkarus13
Znuny newbie
Posts: 42
Joined: 28 Sep 2016, 16:32
Znuny Version: 6.3.3
Real Name: Sascha Kunimünch
Company: Wetrok AG

Re: DB Wechsel mariaDB --> PostGreSQL

Post by Ikkarus13 »

Jetzt wirds langsam lustig. Habe heute mal ein wenig rum probiert mit SQL Abfragen und gesehen, dass es die ID sowohl in der History als auch in der Article gibt. Also habe ich den DBMove nochmal gestartet und er bringt jetzt einen Error an einer anderen Stelle. Also suche ich mal weiter, ob ich das auch beheben kann.

Code: Select all

[2024-07-03 11:21:41] Finished converting table xml_storage.
[Wed Jul  3 11:21:44 2024] otrs.Console.pl: DBD::Pg::db do failed: ERROR:  insert or update on table "communication_log_object_entry" violates foreign key constraint "fk_communication_log_object_entry_communication_log_objectaa"
[Wed Jul  3 11:21:44 2024] otrs.Console.pl: DETAIL:  Key (communication_log_object_id)=(7424942) is not present in table "communication_log_object".
[Wed Jul  3 11:21:44 2024] otrs.Console.pl: CONTEXT:  SQL statement "ALTER TABLE communication_log_object_entry ADD CONSTRAINT FK_communication_log_object_entry_communication_log_objectaa FOREIGN KEY (communication_log_object_id) REFERENCES communication_log_object (id)"
[Wed Jul  3 11:21:44 2024] otrs.Console.pl: PL/pgSQL function inline_code_block line 8 at SQL statement at /opt/znuny-6.5.4/Kernel/System/DB.pm line 497.
ERROR: OTRS-otrs.Console.pl-Maint::Database::Clone-32 Perl: 5.34.0 OS: linux Time: Wed Jul 3 11:21:44 2024

 Message: ERROR:  insert or update on table "communication_log_object_entry" violates foreign key constraint "fk_communication_log_object_entry_communication_log_objectaa"
DETAIL:  Key (communication_log_object_id)=(7424942) is not present in table "communication_log_object".
CONTEXT:  SQL statement "ALTER TABLE communication_log_object_entry ADD CONSTRAINT FK_communication_log_object_entry_communication_log_objectaa FOREIGN KEY (communication_log_object_id) REFERENCES communication_log_object (id)"
PL/pgSQL function inline_code_block line 8 at SQL statement, SQL: 'DO $$
BEGIN
IF NOT EXISTS (
    SELECT 1
    FROM pg_constraint
    WHERE LOWER(conname) = LOWER('FK_communication_log_object_entry_communication_log_objectaa')
    ) THEN
    ALTER TABLE communication_log_object_entry ADD CONSTRAINT FK_communication_log_object_entry_communication_log_objectaa FOREIGN KEY (communication_log_object_id) REFERENCES communication_log_object (id);
END IF;
END$$;
'

 Traceback (518785):
   Module: Kernel::System::CloneDB::Backend::PopulateTargetStructuresPost Line: 455
   Module: Kernel::System::Console::Command::Maint::Database::Clone::Run Line: 121
   Module: (eval) Line: 461
   Module: Kernel::System::Console::BaseCommand::Execute Line: 455
   Module: Kernel::System::Console::InterfaceConsole::Run Line: 81
   Module: bin/otrs.Console.pl Line: 37
Ikkarus13
Znuny newbie
Posts: 42
Joined: 28 Sep 2016, 16:32
Znuny Version: 6.3.3
Real Name: Sascha Kunimünch
Company: Wetrok AG

Re: DB Wechsel mariaDB --> PostGreSQL

Post by Ikkarus13 »

OK, ich denke es lag alles nur daran, dass ich keinen Maintenance Mode gemacht hatte. Jetzt läuft es besser durch. Aber die neue Meldung verstehe ich jetzt noch weniger. Habt ihr vielleicht noch ne Idee?

Code: Select all

[Wed Jul  3 11:47:04 2024] otrs.Console.pl: DBD::Pg::db do failed: ERROR:  relation "groups" does not exist
[Wed Jul  3 11:47:04 2024] otrs.Console.pl: CONTEXT:  SQL statement "ALTER TABLE ps_checklist_tmpl_grp ADD CONSTRAINT FK_ps_checklist_tmpl_grp_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)"
[Wed Jul  3 11:47:04 2024] otrs.Console.pl: PL/pgSQL function inline_code_block line 8 at SQL statement at /opt/znuny-6.5.4/Kernel/System/DB.pm line 497.
ERROR: OTRS-otrs.Console.pl-Maint::Database::Clone-32 Perl: 5.34.0 OS: linux Time: Wed Jul 3 11:47:04 2024
Wenn ich mir die Tabelle anschaue, steht folgendes drin

Code: Select all

MariaDB [otrs]> SELECT * FROM ps_checklist_tmpl_grp LIMIT 10;
+-------------+----------+
| template_id | group_id |
+-------------+----------+
|           1 |        2 |
|           1 |       11 |
|           1 |       12 |
|           2 |        1 |
|           2 |        2 |
|           2 |        3 |
|           2 |       11 |
|           2 |       12 |
|           3 |        2 |
|           3 |       11 |
+-------------+----------+
10 rows in set (0.001 sec)
root
Administrator
Posts: 4250
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: DB Wechsel mariaDB --> PostGreSQL

Post by root »

Hi,

recht einfach: es gibt keine Tabelle groups in der Version 6.5.4. Das Add-on bezieht sich aber darauf und will nutzt es bei der tabell ps_checklist_tmpl_grp. Der Name dieser Tabelle sieht merkwürdig aus für mich, da würde ich mal auf den Hersteller des Add-ons zugehen.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Post Reply