Keycloak and InnoDB Cluster
It seems many people have had issues setting up Keycloak with InnoDB Cluster (Group Replication).
Unfortunately the error messages thrown by the set process (Java) haven’t been very helpful in pointing out the actual reason behind the failures. Finding the root cause in such a scenario isn’t straightforward.
Searching on the web, I couldn’t find an answer but I eventually found the reason for the failures and a solution.
Root cause:
- InnoDB Cluster uses Group replication to enable creating elastic, highly-available, fault-tolerant replication topologies.
- Group replication requires that every table in MySQL database has a primary key
- Keycloak uses Liquibase for managing database migrations via a table called
DATABASECHANGELOG
. This table doesn’t have a primary key defined and so InnoDB Cluster logs this in MySQL error log and fails. Keycloak initialisation process then terminates with an error.
Solution:
- Before installing Keycloak, create the
DATABASECHANGELOG
table manually and add a primary key
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
CREATE TABLE `DATABASECHANGELOG` ( `ID` varchar(255) NOT NULL, `AUTHOR` varchar(255) NOT NULL, `FILENAME` varchar(255) NOT NULL, `DATEEXECUTED` datetime NOT NULL, `ORDEREXECUTED` int(11) NOT NULL, `EXECTYPE` varchar(10) NOT NULL, `MD5SUM` varchar(35) DEFAULT NULL, `DESCRIPTION` varchar(255) DEFAULT NULL, `COMMENTS` varchar(255) DEFAULT NULL, `TAG` varchar(255) DEFAULT NULL, `LIQUIBASE` varchar(20) DEFAULT NULL, `CONTEXTS` varchar(255) DEFAULT NULL, `LABELS` varchar(255) DEFAULT NULL, `DEPLOYMENT_ID` varchar(10) DEFAULT NULL, PRIMARY KEY (`ID`,`AUTHOR`,`FILENAME`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
- Now install keycloak as normal
Hope this helps.
Recent Posts
- Enable http/2 in Apache 16th Jan 2021
- MySQL Shell 8.x 16th Jan 2021
- vi/vim tricks 30th Dec 2020
- SELinux on CentOS 29th Dec 2020
- ssh-copy-id (password less ssh login) 26th Dec 2020
- MySQL auto_increment capacity calculation 26th Dec 2020
- Using UUID as a Primary Key 24th Dec 2020
- Keycloak and InnoDB Cluster 29th Nov 2020
- How to create Column in MySQL only if one does not exist? 19th Mar 2019
- Inject empty transactions in MySQL 5.6 GTID based Replication 25th Dec 2018
- Adding a new disk to CentOS 26th Aug 2018
- mysqldump extended inserts 26th Jun 2018
- CentOS Logical Volume Manager (LVM) 26th Oct 2017
- How to prepare SD Card for Raspberry Pi on a MAC 26th Jun 2017
- Convert .dmg file on a MAC to .iso 26th Apr 2017
Categories
- CentOS (4)
- CentOS 8 (2)
- InnoDB cluster (1)
- mysql (7)
- Raspberry Pi (1)
- ssh (1)
- Technical (3)
Tag cloud
Archives
- January 2021 (2)
- December 2020 (5)
- November 2020 (1)
- March 2019 (1)
- December 2018 (1)
- August 2018 (1)
- June 2018 (1)
- October 2017 (1)
- June 2017 (1)
- April 2017 (1)
- February 2016 (1)