Skip to content

Instantly share code, notes, and snippets.

@smellman
Last active September 20, 2023 22:47
Show Gist options
  • Save smellman/559f74158447c60ebc88c8bc12ebb505 to your computer and use it in GitHub Desktop.
Save smellman/559f74158447c60ebc88c8bc12ebb505 to your computer and use it in GitHub Desktop.
OpenMapTiles 差分アップデート
listen_addresses = '*'
# Tuning at: https://pgtune.leopard.in.ua/
# DB Version: 9.6
# OS Type: linux
# DB Type: dw
# Total Memory (RAM): 16 GB
# CPUs num: 20
# Connections num: 100
# Hard drive type: ssd
max_connections = 100
shared_buffers = 4GB
effective_cache_size = 12GB
maintenance_work_mem = 2GB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 500
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 2097kB
min_wal_size = 4GB
max_wal_size = 8GB
max_worker_processes = 20
max_parallel_workers_per_gather = 10

openmaptiles diff update

generate tiles at first

prepare

cd openmaptiles
vim .env # DIFF_MODE -> true

tuning postgresql

vim my_postgres.conf
# see my_postgres.conf
vim docker-compose.yml
# see below diff file
diff --git a/docker-compose.yml b/docker-compose.yml
index f064f58..5576326 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,11 +7,13 @@ services:
     image: "openmaptiles/postgis:2.9"
     volumes:
     - pgdata:/var/lib/postgresql/data
+    - ./my-postgres.conf:/etc/postgresql/postgresql.conf
     networks:
     - postgres_conn
     ports:
      - "5432"
     env_file: .env
+    command: postgres -c 'config_file=/etc/postgresql/postgresql.conf'
   import-natural-earth:
     image: "openmaptiles/import-natural-earth:1.4"
     env_file: .env

install generate-tm2source

docker-compose run --rm openmaptiles-tools make clean
docker-compose run --rm openmaptiles-tools make

download osm data

mkdir data
cd data
wget http://free.nchc.org.tw/osm.planet/pbf/planet-180430.osm.pbf
cd ..

start postgis

docker-compose up -d postgres

import data

docker-compose run --rm import-water
docker-compose run --rm import-natural-earth
docker-compose run --rm import-lakelines
docker-compose run --rm import-osmborder

import osm

docker-compose run --rm import-osm

import wikidata(run import-wikidata only)

docker-compose run --rm import-wikidata

import sql and analyze it

docker-compose run --rm import-sql
docker-compose run --rm import-osm /usr/src/app/psql.sh  -P pager=off  -c 'ANALYZE VERBOSE;'

diff update

fix last.state.txt

mv last.state.txt last.state.txt.orig
wget https://planet.openstreetmap.org/replication/day/000/002/056.state.txt
mv 056.state.txt last.state.txt

run update osm

docker-compose run --rm update-osm

watching

watch docker-compose top
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment