This guide covers how to:
- Install Martin Tileserver.
- Download a Maptiler tileset for North America.
- Set up Martin to run as a persistent service using systemd.
Per instructions in the documentation:
mkdir martin
cd martin
# Download some sample data
curl -L -O https://github.com/maplibre/martin/raw/main/tests/fixtures/mbtiles/world_cities.mbtiles
# Download the latest version of Martin binary, extract it, and make it executable
curl -L -O https://github.com/maplibre/martin/releases/latest/download/martin-x86_64-unknown-linux-gnu.tar.gz
tar -xzf martin-x86_64-unknown-linux-gnu.tar.gz
chmod +x ./martin
# Run Martin with the sample data as the only tile source
./martin world_cities.mbtiles
Let's create a directory for all of our tilesets (just one in this example):
mkdir tilesets
cd tilesets
You can get your download URL directly from Maptiler. Next, you can download the Maptiler North America tileset with wget using the following command:
wget -c URL-FROM-MAPTILER
This will download the tileset as a .mbtiles file. Once downloaded, you can start serving these tiles using the Martin server.
To ensure Martin keeps running even after you log out, we will set it up with systemd.
sudo nano /etc/systemd/system/martin-tileserver.service
Paste the following into the file, chaning [ROOT]
and [MAPTILER-FILE]
to whatever those paths are.
[Unit]
Description=Martin Tileserver
After=network.target
[Service]
ExecStart=[ROOT]/martin/martin [ROOT]/tilesets/[MAPTILER-FILE]
WorkingDirectory=[ROOT]
User=mikaelbrunila
Restart=always
[Install]
WantedBy=multi-user.target
Do NOT use relative paths.
Reload systemd and start the service: Run the following commands to reload systemd and start Martin:
sudo systemctl daemon-reload
sudo systemctl start martin-tileserver
Enable Martin to start on boot: To make sure Martin starts on system boot, use:
sudo systemctl enable martin-tileserver
Verify the status of the service: To check that Martin is running correctly, use:
sudo systemctl status martin-tileserver
Now, Martin should be running as a persistent service. If you need to stop or restart Martin, use:
sudo systemctl stop martin-tileserver
sudo systemctl restart martin-tileserver
You can view logs for troubleshooting with:
sudo journalctl -u martin-tileserver
This guide should help you get Martin running as a persistent service on your server. You can now serve tiles and access them using the appropriate URL. When using GC, also remember to do the following:
- Go to the Google Cloud Console.
- In the left sidebar, go to
VPC network
>Firewall rules
. - Click
Create firewall rule
. - Name the rule (e.g., martin).
- In the Targets section, select
All instances in the network
orSpecified target tags
. - Under
Source filter
, select IP ranges and specify0.0.0.0/0
to allow all external IP addresses (or specify a more restricted range if necessary). - Set Allowed protocols and ports to
tcp:3000
. - Click
Create
.