| 462 | | How to set up a local mirror for Africa with selected Feature types, suitable for use by Import PoI: |
| 463 | | {{{ |
| 464 | | apt-get install -y postgresql-8.4-postgis postgresql-contrib |
| | 462 | How to set up a local mirror for a country, optionally with just selected Feature types, suitable for use by Import PoI: |
| | 463 | {{{ |
| | 464 | Debian stable |
| | 465 | apt-get install sudo |
| | 466 | visudo |
| | 467 | fran ALL = NOPASSWD: ALL |
| | 468 | |
| | 469 | cat << EOF >> "/etc/apt/sources.list.d/pgdg.list" |
| | 470 | deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main |
| | 471 | EOF |
| | 472 | wget --no-check-certificate https://www.postgresql.org/media/keys/ACCC4CF8.asc |
| | 473 | apt-key add ACCC4CF8.asc |
| | 474 | apt-get update |
| | 475 | |
| | 476 | apt-get -y install postgresql-9.3 python-psycopg2 postgresql-9.3-postgis ptop postgresql-contrib |
| | 477 | |
| | 478 | # Tune PostgreSQL |
| | 479 | cat << EOF >> "/etc/sysctl.conf" |
| | 480 | ## Increase Shared Memory available for PostgreSQL |
| | 481 | # 512Mb |
| | 482 | kernel.shmmax = 279134208 |
| | 483 | # 1024Mb (may need more) |
| | 484 | #kernel.shmmax = 552992768 |
| | 485 | kernel.shmall = 2097152 |
| | 486 | EOF |
| | 487 | sysctl -w kernel.shmmax=279134208 # For 512 MB RAM |
| | 488 | #sysctl -w kernel.shmmax=552992768 # For 1024 MB RAM |
| | 489 | sysctl -w kernel.shmall=2097152 |
| | 490 | |
| | 491 | sed -i 's|#track_counts = on|track_counts = on|' /etc/postgresql/9.3/main/postgresql.conf |
| | 492 | sed -i 's|#autovacuum = on|autovacuum = on|' /etc/postgresql/9.3/main/postgresql.conf |
| | 493 | # 512Mb RAM: |
| | 494 | sed -i 's|shared_buffers = 28MB|shared_buffers = 56MB|' /etc/postgresql/9.3/main/postgresql.conf |
| | 495 | sed -i 's|#effective_cache_size = 128MB|effective_cache_size = 256MB|' /etc/postgresql/9.3/main/postgresql.conf |
| | 496 | sed -i 's|#work_mem = 1MB|work_mem = 2MB|' /etc/postgresql/9.3/main/postgresql.conf |
| | 497 | # If 1Gb+ RAM, activate post-install via pg1024 script |
| | 498 | |
| | 499 | adduser osm |
| 497 | | wget http://download.geofabrik.de/openstreetmap/africa.osm.pbf |
| 498 | | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/africa.osm.pbf --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --write-pbf /home/osm/planet/eurosha.osm.pbf |
| 499 | | su postgres |
| 500 | | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha.osm.pbf --write-pgsql database=osm user=osm password=planet |
| | 535 | # Either grab snapshot from GeoFabrik or use HOT Export Tool |
| | 536 | #wget http://download.geofabrik.de/africa/cameroon-latest.osm.pbf -O extract.osm.pbf |
| | 537 | wget http://export.hotosm.org/download/023803/rawdata.osm.pbf -O extract.osm.pbf |
| | 538 | |
| | 539 | apt-get install -y openjdk-7-jre |
| | 540 | |
| | 541 | # If wishing to filter the data to just certain types of object |
| | 542 | #mv extract.osm.pbf full.osm.pbf |
| | 543 | #/home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/full.osm.pbf --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --write-pbf /home/osm/planet/extract.osm.pbf |
| | 544 | su postgres |
| | 545 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/extract.osm.pbf --write-pgsql database=osm user=osm password=planet |
| 512 | | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/eurosha.osm.pbf --ac --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --tf reject-relations --write-pbf /home/osm/planet/eurosha-new.osm.pbf |
| 513 | | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha-new.osm.pbf --read-pbf /home/osm/planet/eurosha.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| 514 | | mv /home/osm/planet/eurosha-new.osm.pbf /home/osm/planet/eurosha.osm.pbf |
| 515 | | vim /home/osm/replicate.sh |
| | 558 | # If wishing to filter the data to just certain types of object |
| | 559 | #/home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/extract.osm.pbf --ac --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --tf reject-relations --write-pbf /home/osm/planet/new.osm.pbf |
| | 560 | #/home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/new.osm.pbf --read-pbf /home/osm/planet/extract.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| | 561 | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/extract.osm.pbf --ac --write-pbf /home/osm/planet/new.osm.pbf |
| | 562 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/new.osm.pbf --read-pbf /home/osm/planet/extract.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| | 563 | mv /home/osm/planet/new.osm.pbf /home/osm/planet/extract.osm.pbf |
| | 564 | vi /home/osm/replicate.sh |
| 524 | | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/eurosha.osm.pbf --ac --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --tf reject-relations --write-pbf /home/osm/planet/eurosha-new.osm.pbf |
| 525 | | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha-new.osm.pbf --read-pbf /home/osm/planet/eurosha.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| 526 | | mv /home/osm/planet/eurosha-new.osm.pbf /home/osm/planet/eurosha.osm.pbf |
| | 573 | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/extract.osm.pbf --ac --write-pbf /home/osm/planet/new.osm.pbf |
| | 574 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/new.osm.pbf --read-pbf /home/osm/planet/extract.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| | 575 | mv /home/osm/planet/new.osm.pbf /home/osm/planet/extract.osm.pbf |