Hello,
I would like to migrate the application database from H2 to postgres.
If I understand well, I need :
To configure environment variables as such: export MB_DB_TYPE=mysql export MB_DB_DBNAME=metabase export MB_DB_PORT=3306 export MB_DB_USER=<username> export MB_DB_PASS=<password> export MB_DB_HOST=localhost
To create a new empty postgres db : createdb --encoding=UTF8 -e metabase-db-name
Then to configure metabase to work with it with environment variables: export MB_DB_TYPE=postgres export MB_DB_DBNAME=metabase export MB_DB_PORT=5432 export MB_DB_USER=<username> export MB_DB_PASS=<password> export MB_DB_HOST=localhost text
finally, to migrate h2 to postgres with java -jar metabase.jar load-from-h2 /path/to/metabase.db
I have setup the environment variables, but when I run: createdb --encoding=UTF8 -e metabase I get createdb: command not found.
What do I do wrong ?
Thanks !
Thanks !
Yes I am actually hosting a DB on DigitalOcean.
so I have set up the environment variables as such:
MB_DB_TYPE=postgres
bash-5.0# export MB_DB_DBNAME=metabase
bash-5.0# export MB_DB_TYPE=postgres
bash-5.0# export MB_DB_PORT=25060
bash-5.0# export MB_DB_USER=“user”
bash-5.0# export MB_DB_PASS=“pswd”
So I just need to run the migration command ?
java -jar metabase.jar load-from-h2 /path/to/metabase.db
If yes, then what should I put in /path/to/metabase.db ?
And we already use Docker to take care of Metabase. I just want to migrate the application database.
You need to shutdown Metabase before you can do migration.
Then you run the migration. If you’re executing from a different directory than where metabase.jar and metabase.db.mv.db is located, then you need to refer to those files by full path.
I am pretty new to metabase and finding my feet. I have managed to setup metabase on an ubuntu server and now I am looking at migrating my H2 database into mysql. I have spent quite some time reading different articles on the forum and have also followed the directions in this article.
When I run the command:
java -jar metabase.jar load-from-h2 /path/to/metabase.db it just seems to hang and nothing happens
root@test-metabase:~# java -jar /opt/metabase/metabase.jar load-from-h2 metabase.db
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2021-07-22 09:12:10,661 INFO metabase.util :: Maximum memory available to JVM: 481.4 MB
2021-07-22 09:12:28,923 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance.
For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
I did set the local environment variable as follows
root@test-metabase:~# export MB_DB_TYPE=mysql
root@test-metabase:~# export MB_DB_DBNAME=metabase
root@test-metabase:~# export MB_DB_PORT=3006
root@test-metabase:~# export MB_DB_USER=metabase
root@test-metabase:~# export MB_DB_PASS=mypasword
root@test-metabase:~# export MB_DB_HOST=localhost
I did stop the metabase.service before running the import command.
Is there a log file I can view to see any errors ?
Hi @Surge
You are running with very limited RAM - at least 1GB is recommended.
My initial thought is that you are running low on entropy, which means the startup will take much longer (up to 20 minutes). See this issue for workarounds: https://github.com/metabase/metabase/issues/10175
Also, there's a very big difference with the command you say you're using and the command you're actually using. Relative paths are great if you're in the right working directory - otherwise it's just going to cause more problems.
Either:
Thanks for the prompt answer. I was actually just reading this article on memory as i did not know why it started with such low memory and yes it was taking forever to start up.
Now I have ExecStart=/usr/bin/java -Xms1g -Xms2g -jar /opt/metabase/metabase.jar.
Still it starts up pretty slow... Actually started it about 10 minutes ago and still not up, I do not see any messages in the log that will show me if it is up or not, I basically check lsof -i tcp:3000 to see the port is listening and then sit and refresh my browser... very frustrating and I wish i could see some log or something to tell me if it is up and working or if there are issues.
Jul 22 12:04:45 test-metabase metabase[1244]: WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Jul 22 12:04:48 test-metabase metabase[1244]: 2021-07-22 12:04:48,015 INFO metabase.util :: Maximum memory available to JVM: 1.9 GB
Jul 22 12:05:05 test-metabase metabase[1244]: 2021-07-22 12:05:05,031 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance.
Jul 22 12:05:05 test-metabase metabase[1244]: For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
I already have followed the instructions in the last link you have sent and it is setup as a service.
Just a small update regarding speed and log, after I finally found where the java.security file and made the changes recommended in the article and now I am seeing a full log and metabase is starting up very fast.
Now I am moving onto the import... will keep you updated
I saw this error: Caused by: org.h2.jdbc.JdbcSQLException: Database "/opt/metabase/metabase.db" not found [90013-197]
which is strange as the file is there
@Surge Please make sure to double-check Admin > Troubleshooting > "Diagnostic Info", which should say "application-database": "mysql"
I have just seen too many who went through migration problems and using a mix of relative/absolute paths and then they ended up using H2 at some point after they restarted and lost all their Metabase data, since they didn't have backups of the H2.
Thanks, this is what the diagnostic info is showing:
"metabase-info": {
"databases": [
"h2",
"mysql"
],
"hosting-env": "unknown",
"application-database": "mysql",
@Surge It's correct. I would still recommend restarting, since I have seen incorrect setup of the SystemD service too. Then you know that it starts up correctly and everything is working even after a reboot.