Skip to content

Instantly share code, notes, and snippets.

@RooseveltAdvisors
Last active April 16, 2017 16:17
Show Gist options
  • Save RooseveltAdvisors/e17d2381fe918f417cfef7ea688ef9d8 to your computer and use it in GitHub Desktop.
Save RooseveltAdvisors/e17d2381fe918f417cfef7ea688ef9d8 to your computer and use it in GitHub Desktop.
OSRM with North america map installation and setup on Ubuntu 12.04 ~ 15.04

Install

sudo su
apt-get update -y
apt-get install -y software-properties-common python-software-properties || true
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get update -y
apt-get install -y zlib1g-dev curl libstdc++-5-dev make binutils libc-dev libgcc-5-dev git
cd /opt
mkdir /opt/osrm
cd /opt/osrm
git clone https://github.com/Project-OSRM/osrm-backend.git
cd osrm-backend
git checkout 5.6
./third_party/mason/mason install clang++ 3.9.1
./third_party/mason/mason install cmake 3.6.2
export PATH=$(./third_party/mason/mason prefix cmake 3.6.2)/bin:$PATH
export PATH=$(./third_party/mason/mason prefix clang++ 3.9.1)/bin:$PATH
mkdir build
cd build
cmake ../ -DENABLE_MASON=1
make
make install

reference : https://github.com/Project-OSRM/osrm-backend/wiki/Building-with-Mason#ubuntu-1204---1504

Increase Swap size

  1. We can create a 32 Gigabyte file by typing:

sudo fallocate -l 32G /swapfile The prompt will be returned to you almost immediately. We can verify that the correct amount of space was reserved by typing:

ls -lh /swapfile
-rw-r--r-- 1 root root 32.0G Apr 28 17:19 /swapfile
As you can see, our file is created with the correct amount of space set aside.
  1. Enabling the Swap File Right now, our file is created, but our system does not know that this is supposed to be used for swap. We need to tell our system to format this file as swap and then enable it.

Before we do that though, we need to adjust the permissions on our file so that it isn't readable by anyone besides root. Allowing other users to read or write to this file would be a huge security risk. We can lock down the permissions by typing:

sudo chmod 600 /swapfile

Verify that the file has the correct permissions by typing:

ls -lh /swapfile
-rw------- 1 root root 32.0G Apr 28 17:19 /swapfile

As you can see, only the columns for the root user have the read and write flags enabled.

Now that our file is more secure, we can tell our system to set up the swap space by typing:

sudo mkswap /swapfile
Setting up swapspace version 1, size = 32194300 KiB
no label, UUID=e2f1e9cf-c0a9-4ed4-b8ab-714b8a7d6944

Our file is now ready to be used as a swap space. We can enable this by typing:

sudo swapon /swapfile

We can verify that the procedure was successful by checking whether our system reports swap space now:

sudo swapon -s
Filename                Type        Size    Used    Priority
/swapfile               file        4194300 0       -1

We have a new swap file here. We can use the free utility again to corroborate our findings:

free -m
             total       used       free     shared    buffers     cached
Mem:          3953        101       3851          0          5         30
-/+ buffers/cache:         66       3887
Swap:         33791        16897   16897

Our swap has been set up successfully and our operating system will begin to use it as necessary.

  1. Make the Swap File Permanent We have our swap file enabled, but when we reboot, the server will not automatically enable the file. We can change that though by modifying the fstab file.

Edit the file with root privileges in your text editor:

sudo nano /etc/fstab

At the bottom of the file, you need to add a line that will tell the operating system to automatically use the file you created:

/swapfile   none    swap    sw    0   0

Save and close the file when you are finished.

Extract Map and run

cd /opt/osrm
mkdir north_america
cd north_america
wget http://download.geofabrik.de/north-america-latest.osm.pbf
ln -s ../osrm-backend/profiles/car.lua profile.lua
ln -s ../osrm-backend/profiles/lib
osrm-extract -p profile.lua north-america-latest.osm.pbf 
osrm-contract north-america-latest.osrm
osrm-routed north-america-latest.osrm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment