osm2pgsql在具有192GB RAM的服务器上导入时极慢

时间:2018-08-01 05:23:20

标签: postgresql openstreetmap postgis

我有一台性能出色的服务器,双6核3.3GHz 196GB内存,在4个10K SAS驱动器上具有RAID 10。我编写了一个脚本,该脚本应该下载每个北美文件,并逐个处理而不是一次处理整个文件。

processList.sh:

wget http://download.geofabrik.de/north-america/us/alabama-latest.osm.pbf  -O ./geoFiles/north-america/us/alabama-latest.osm.pbf
osm2pgsql -d gis --create --slim  -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2000 --number-processes 15 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ./geoFiles/north-america/us/alabama-latest.osm.$


while read in; 
   do wget http://download.geofabrik.de/$in -O ./geoFiles/$in; 
      osm2pgsql -d gis --append --slim  -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2000 --number-processes 15 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ./geoFiles/$in;
done < maplist.txt

起初,它以接近40万个点/秒的速度开始处理,然后减慢到10k或更少

osm2pgsql version 0.96.0 (64 bit id space)

Using lua based tag processing pipeline with script /root/src/openstreetmap-carto/openstreetmap-carto.lua
Using projection SRS 3857 (Spherical Mercator)
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads
Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=2000MB, maxblocks=32000*65536, allocation method=11
Mid: pgsql, cache=2000
Setting up table: planet_osm_nodes
Setting up table: planet_osm_ways
Setting up table: planet_osm_rels

Reading in file: ./geoFiles/north-america/us/alabama-latest.osm.pbf
Using PBF parser.
Processing: Node(5580k 10.7k/s) Way(0k 0.00k/s) Relation(0 0.00/s))

我将https://wiki.openstreetmap.org/wiki/Osm2pgsql/benchmarks中的性能内容应用于Postgresql:

shared_buffers = 14GB
work_mem = 1GB                          
maintenance_work_mem = 8GB

effective_io_concurrency = 500          
max_worker_processes = 8                
max_parallel_workers_per_gather = 2     
max_parallel_workers = 8                

checkpoint_timeout = 1h         
max_wal_size = 5GB
min_wal_size = 1GB
checkpoint_completion_target = 0.9      

random_page_cost = 1.1                  
min_parallel_table_scan_size = 8MB
min_parallel_index_scan_size = 512kB
effective_cache_size = 22GB

尽管起步良好,但在约20秒内迅速变质。知道为什么吗?我看了top,但并没有真正显示任何内容:

top - 22:48:46 up  3:11,  2 users,  load average: 3.49, 4.03, 3.38
Tasks: 298 total,   1 running, 297 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni, 87.5 id, 12.5 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 19808144+total, 19237500+free,   780408 used,  4926040 buff/cache
KiB Swap: 29321212 total, 29321212 free,        0 used. 19437014+avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                
16156 root      20   0 50.819g  75920   8440 S   0.7  0.0   0:02.81 osm2pgsql                                                                                                                                                                              
16295 root      20   0   42076   4156   3264 R   0.3  0.0   0:00.27 top                                                                                                                                                                                    
    1 root      20   0   37972   6024   4004 S   0.0  0.0   0:07.10 systemd                                                                                                                                                                                
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd                                                                                                                                                                               
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.05 ksoftirqd/0                                                                                                                                                                            
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                                                                                                                           
    6 root      20   0       0      0      0 S   0.0  0.0   0:00.58 kworker/u64:0                                                                                                                                                                          
    8 root      20   0       0      0      0 S   0.0  0.0   0:01.79 rcu_sched                                                                                                                                                                              
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                                                                                                                                                 
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.05 migration/0                                                                                                                                                                            
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.03 watchdog/0    

它的平均负载很大,使用时没有列出任何内容。以下是iotop

的结果
Total DISK READ :       0.00 B/s | Total DISK WRITE :     591.32 K/s
Actual DISK READ:       0.00 B/s | Actual DISK WRITE:     204.69 K/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                                                                                                                                      
28638 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.60 % [kworker/u65:1]
20643 be/4 postgres    0.00 B/s  204.69 K/s  0.00 %  0.10 % postgres: wal writer process
20641 be/4 postgres    0.00 B/s  288.08 K/s  0.00 %  0.00 % postgres: checkpointer process
26923 be/4 postgres    0.00 B/s   98.55 K/s  0.00 %  0.00 % postgres: root gis [local] idle in transaction
    1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % init
    2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
    3 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [ksoftirqd/0]
    5 be/0 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/0:0H]
    6 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/u64:0]
    8 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_sched]
    9 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_bh]
   10 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [migration/0]
   11 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [watchdog/0]
   12 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [watchdog/1]

0 个答案:

没有答案