minetestserver -migrate and postgresql?

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

minetestserver -migrate and postgresql?

by ExeterDad » Thu Feb 16, 2017 18:10

I finally managed to build a .deb package with postgresql support. Cmake bug upstream prevents postgresql detection.
I'm wanting to convert my sqlite map to postgresql with the -migrate option. I've done it without issues in the past with redis, but unsure how to go about it with postgresql. I'm not even sure if migration is supported yet with postgresql. If so, do I need to supply a connection string somewhere? Or would it use some sort of defaults?

Googling Minetest and postgresql yeilds sparse results as it seems very few people are using postgresql as their backend.

Insight would be greatly appreciated. Examples would be awesome as well.

Thanks!
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: minetestserver -migrate and postgresql?

by ExeterDad » Fri Feb 17, 2017 04:21

So apparently minetestserver does support migrating from sqlite to postgresql. Yeay!!!

After much fiddling with various conversion tools without any luck, I went for it with my local instance of our server. Good thing I did as there was MUCH trial and error while I was figuring it out. I'm going to outline what I did for others (or even myself) to get it working for them. I know nothing about postgresql other than I learned today so feel free to pick this tutorial apart so I may edit this post.

Our server is running Debian Jessie completely Vanilla, with only what is required to build and run minetest server so your results may be quite different than mine.

First off, you need minetestserver with postgresql support intalled. I had already built and rolled minetest in a .deb package for easy install and clean removal. I just need to install it for the first time but not start it yet:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
sudo dpkg -i minetest_0.4.15-dev-20170215_amd64.deb


Now install postgresql and client:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
sudo apt-get install postgresql-9.4


This installed:
postgresql-9.4
postgresql-client-9.4
postgresql-client-common
postgresql-common

Check to see if postgresql server is up and running. There will be a bunch of output if this command is run and the server is up:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
ps -ef | grep postgre

On a Debian box, user postres is created. In the *nix terminal we need to become that user and run the postgresql client to connect and create a user, password and database for our map.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
sudo -u postgres psql

The prompt will change appearance when you are in the client. Type \q to quit if you change your mind.

I'm now going to create a new database user "minetest" with a password of "12345" and give minetest all privs on a new database called "myworld". Use whatever you like... maybe not such a lame password though.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
postgres=# CREATE USER minetest WITH PASSWORD '12345';
postgres=# CREATE DATABASE myworld OWNER minetest;
postgres=# GRANT ALL PRIVILEGES ON DATABASE myworld TO minetest;


The postgres=# portion of the above lines is the client "prompt", don't type that part. Also note, the uppercase commands must be uppercase. The semi-colons ";" must not be omitted. If they aren't included, it will be assumed you are typing a extra long command.

Check to make sure the new database is there and owned by new user "minetest". List the databases with \l <--- backslash and a lowercase "L":

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
postgres=# \l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 myworld  | minetest | LATIN1   | en_US   | en_US | =Tc/minetest         +
           |          |          |         |       | minetest=CTc/minetest
 postgres  | postgres | LATIN1   | en_US   | en_US |
 template0 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(4 rows)

Hopefully everthing is good, now exit the client with \q

Now we create a connection string in our worlds world.mt file. Do not change the backend string from sqlite yet. The migration will do that for you when it's done.
So the top part of world.mt should look like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
gameid = minetest
backend = sqlite3
pgsql_connection = host=127.0.0.1 port=5432 user=minetest password=12345 dbname=myworld


Save world.mt and let's start minetestserver and begin the migration. Launch it with the --migrate option, and --world option. I always use the full path to the world directory in quotes when launching via cli. Your path will be different naturally. Mine is in my user directory. So I don't have to deal with permissions when editing stuff.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetestserver --migrate postgresql --world "/home/leeh/.minetest/worlds/myworld"

You should expect to see something like this if all went well:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
leeh@s103139:~$ minetestserver --migrate postgresql --world "/home/leeh/.minetest/worlds/myworld"
2017-02-16 21:08:37: WARNING[Main]: Couldn't find a locale directory!
2017-02-16 21:08:37: WARNING[Main]: Your PostgreSQL server lacks UPSERT support. Use version 9.5 or better if possible.
 Migrated 880260 blocks, 99.2227% completed.
2017-02-16 21:10:24: ACTION[Main]: Successfully migrated 887156 blocks
2017-02-16 21:10:24: ACTION[Main]: world.mt updated


Now you can start your server with your usual method and it should "just work"

Enjoy!
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
googol
Member
 
Posts: 48
Joined: Mon Dec 09, 2013 09:23

Re: minetestserver -migrate and postgresql?

by googol » Mon Feb 20, 2017 09:31

Can rewrite your post to the wiki?
Interesting to redis too.
We do better minetest.
better than minecraft.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 35 guests

cron