Goal
My goal is to run the latest OpenEMR Cloud Standard Edition (running 7.0.2) on AWS (us-east-2
) with MariaDB instead of MySQL.
The issue
I am able to download the original CloudFormation template (attached) for the MySQL Cloud Standard Edition setup & successfully deploy through the AWS console.
- (Success -
https://<MY_EC2_PUBLIC_IP_ADDRESS>
opens the OpenEMR login page)
Then I modify the template to use MariaDB (attached). I am then able to deploy this (as a separate CloudFormation Stack with all separate resources) but when I try to access https://<MY_EC2_PUBLIC_IP_ADDRESS>
, I get Unable to connect
- My only changes to the template are:
- Changing
"Engine": "MySQL",
→"Engine": "MariaDB",
- Replacing all occurrences of
8.0.36
(the MySQL version #) with10.11.6
(what I believe should be the correct MariaDB version number- I got
10.11.6
from:- Checking for the most up-to-date MariaDB version supported by my OpenEMR Version: OpenEMR_Downloads
- Compatible with … MariaDB versions 10.3 - 11.1
- Cross-reference with most up-to-date version of MariaDB supported by AWS RDS: MariaDB on Amazon RDS versions - Amazon Relational Database Service
- Running
aws rds describe-db-engine-versions --default-only --engine mariadb --engine-version 10.11 --region us-east-2 --query "*[].{Engine:Engine,EngineVersion:EngineVersion}" --output text
returns:mariadb 10.11.6
- Running
- Checking for the most up-to-date MariaDB version supported by my OpenEMR Version: OpenEMR_Downloads
- I got
- Changing
original_openemr_with_mysql.template (40.8 KB)
mariadb_updated_openemr.template (40.8 KB)
Digging Deeper
I SSH into my EC2 instance to see whats wrong.
root@ip-...:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b0d58961d0d openemr/openemr:7.0.2 "./openemr.sh" 2 hours ago Up 2 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp standard_openemr_1
Running docker logs standard_openemr_1
shows that this error is being thrown:
Couldn't set up. Any of these reasons could be what's wrong:
- You didn't spin up a MySQL container or connect your OpenEMR container to a mysql instance
- MySQL is still starting up and wasn't ready for connection yet
- The Mysql credentials were incorrect
mkdir: can't create directory '/tmp/php-file-cache': File exists
PHP Fatal error: Uncaught mysqli_sql_exception: Table 'contact' already exists in /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php:1349
Stack trace:
#0 /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php(1349): mysqli_query()
#1 /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php(369): Installer->execute_sql()
#2 /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php(317): Installer->load_file()
#3 /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php(1278): Installer->load_dumpfiles()
#4 /var/www/localhost/htdocs/openemr/auto_configure.php(41): Installer->quick_install()
#5 {main}
thrown in /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php on line 1349
Checking the options
You didn’t spin up a MySQL container or connect your OpenEMR container to a mysql instance
root@ip-...:~# docker exec -it 0b0d58961d0d /bin/sh
/var/www/localhost/htdocs/openemr # mysql -h $MYSQL_HOST -u openemr -p"$MYSQL_ROOT_PASS" -e "SELECT 1"
+---+
| 1 |
+---+
| 1 |
+---+
I believe this confirms the OpenEMR container can access the DB running in RDS
While we’re here, lets also check that contacts
table:
/var/www/localhost/htdocs/openemr # mysql -h $MYSQL_HOST -u openemr -p"$MYSQL_ROOT_PASS" -e "USE openemr; SELECT * FROM contact;"
/var/www/localhost/htdocs/openemr #
I believe this shows the contact
table exists but contains no records
MySQL is still starting up and wasn’t ready for connection yet
Just to be sure, I re-deployed & waited 2 hours before touching anything & got the same result
root@ip-...:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b0d58961d0d openemr/openemr:7.0.2 "./openemr.sh" 2 hours ago Up 2 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp standard_openemr_1
The Mysql credentials were incorrect
I double-checked echo $MYSQL_HOST
& echo $MYSQL_ROOT_PASS
, both are correct as far as I can tell
Lets try to find some logs
root@ip-...:~# docker exec -it 0b0d58961d0d /bin/sh
/var/www/localhost/htdocs/openemr # cd /var/www/logs
/var/www/logs # ls -a
. ..
Hmm, no logs
Alright, lets check RDS in AWS Console…
I see an interesting difference between the database connections graphs between the working MySQL instance and the MariaDB instance:
MySQL instance’s connections:
MariaDB instance’s connections:
Help Me Obi-Wan Kenobi, You’re My Only Hope
At this point I’m pretty stumped, does anyone have any ideas what the issue might be or more things to try?
Any and all assistance is greatly appreciated!