minetestserver -migrate and postgresql?

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
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!
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
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:

Code: Select all
sudo dpkg -i minetest_0.4.15-dev-20170215_amd64.deb


Now install postgresql and client:

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:
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.
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.

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":

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:
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.
Code: Select all
minetestserver --migrate postgresql --world "/home/leeh/.minetest/worlds/myworld"

You should expect to see something like this if all went well:
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!
 

User avatar
googol
Member
 
Posts: 75
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.
I am groot!
 

User avatar
uwu
New member
 
Posts: 9
Joined: Sun Jan 21, 2018 15:01

Re: minetestserver -migrate and postgresql?

by uwu » Sun Jan 21, 2018 23:20

Thanks for this post.
I'd migrate the player database as well:
Code: Select all
pgsql_player_connection = host=<db_host> user=<db_user> password=<db_password> dbname=<db_name>
minetestserver --migrate-players <name of new backend> --world <path to your world directory>
 

User avatar
Edgy1
Member
 
Posts: 148
Joined: Thu Nov 24, 2016 16:29
GitHub: JamesTobin
In-game: Trump

Re: minetestserver -migrate and postgresql?

by Edgy1 » Sun Jul 22, 2018 21:36

Code: Select all
minetest@debian:~/minetest/bin$ ./minetestserver --migrate postgresql --world "/                                                                                                             home/minetest/minetest/worlds/Trumpland"
2018-07-22 17:29:32: WARNING[Main]: Couldn't find a locale directory!
2018-07-22 17:29:32: ERROR[Main]: An unhandled exception occurred: Database back                                                                                                             end postgresql not supported.
2018-07-22 17:29:32: ERROR[Main]: In thread 7fab6f525b80:
2018-07-22 17:29:32: ERROR[Main]: /home/minetest/minetest/src/main.cpp:e2: int m                                                                                                             ain(int, char**): A fatal error occured: Database backend postgresql not support                                                                                                             ed.
2018-07-22 17:29:32: ERROR[Main]: Debug stacks:
2018-07-22 17:29:32: ERROR[Main]: DEBUG STACK FOR THREAD 7fab6f525b80:
2018-07-22 17:29:32: ERROR[Main]: #0  int main(int, char**)
Aborted
minetest@debian:~/minetest/bin$


what should i do next?
Join #Edgy1 on XeroxIRC. servers: Legends of Revival, Survivalworks Next Generation, Grand Theft Auto Minetest, Survivalworks Original (mesecrafted01), Penguins Survival (penguins)
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
In-game: ExeterDad

Re: minetestserver -migrate and postgresql?

by ExeterDad » Wed Jul 25, 2018 13:02

Your version of Minetest is not compiled with postgresql support. Either build yourself with postgres headers installed or find a package that is compiled with support.
 

User avatar
Edgy1
Member
 
Posts: 148
Joined: Thu Nov 24, 2016 16:29
GitHub: JamesTobin
In-game: Trump

Re: minetestserver -migrate and postgresql?

by Edgy1 » Wed Jul 25, 2018 13:34

How do you compile with postgress support?
Join #Edgy1 on XeroxIRC. servers: Legends of Revival, Survivalworks Next Generation, Grand Theft Auto Minetest, Survivalworks Original (mesecrafted01), Penguins Survival (penguins)
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
In-game: ExeterDad
 

User avatar
Edgy1
Member
 
Posts: 148
Joined: Thu Nov 24, 2016 16:29
GitHub: JamesTobin
In-game: Trump

Re: minetestserver -migrate and postgresql?

by Edgy1 » Thu Jul 26, 2018 00:11

thx i'll try soon. appreciate it.
by the way i live in the same state as you :)
Join #Edgy1 on XeroxIRC. servers: Legends of Revival, Survivalworks Next Generation, Grand Theft Auto Minetest, Survivalworks Original (mesecrafted01), Penguins Survival (penguins)
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
In-game: ExeterDad

Re: minetestserver -migrate and postgresql?

by ExeterDad » Thu Jul 26, 2018 03:05

Fedora24 wrote:thx i'll try soon. appreciate it.
by the way i live in the same state as you :)

If I can find it... I have a handy script I made a couple years ago that still works. It will build you a .deb package, with or without the client or server. It will install all needed dev packages, download whatever git version your after, and build everything, make a legit .deb that you can install (or cleanly) remove in the system.
If I find it, I'll send it your way.
 

User avatar
Edgy1
Member
 
Posts: 148
Joined: Thu Nov 24, 2016 16:29
GitHub: JamesTobin
In-game: Trump

Re: minetestserver -migrate and postgresql?

by Edgy1 » Thu Jul 26, 2018 03:07

Thanks exter :) appreciated

I got a lot of homework tonight so if I don't do it tonight I will probably tomorrow night.
Join #Edgy1 on XeroxIRC. servers: Legends of Revival, Survivalworks Next Generation, Grand Theft Auto Minetest, Survivalworks Original (mesecrafted01), Penguins Survival (penguins)
 

User avatar
Edgy1
Member
 
Posts: 148
Joined: Thu Nov 24, 2016 16:29
GitHub: JamesTobin
In-game: Trump

Re: minetestserver -migrate and postgresql?

by Edgy1 » Sat Aug 04, 2018 20:35

i still got the same error
Join #Edgy1 on XeroxIRC. servers: Legends of Revival, Survivalworks Next Generation, Grand Theft Auto Minetest, Survivalworks Original (mesecrafted01), Penguins Survival (penguins)
 

User avatar
bhree
Member
 
Posts: 61
Joined: Tue Jun 19, 2018 07:45
GitHub: bhree
In-game: bhree

Re: minetestserver -migrate and postgresql?

by bhree » Thu Sep 06, 2018 05:10

I have succeeded migrating my map using above methods and it was a breeze. One question if I migrate players to postgresql also, will it create new table in the same database with map or should I create new database? Thanks.

[edit] my curiousity couldn't wait as I already have backup so I tried using map database. It seems players and map data can be in the same database.
 


Return to Feature Discussion



Who is online

Users browsing this forum: No registered users and 2 guests