Installing Traccar Server on Raspberry Pi (Rasperian)

jimjaeger7 years ago

Requirements:

  • Java installed (JRE is sufficient, SDK is ok too), The program needs java executable, so you can try to enter java --version to check if java is installed on your pi
  • wget installed (to download the zip file, you do not need it if you copy it with other tools)
  • unzip installed (to unzip the zip file, you do not need it if you unzip the content with other toots)

Steps:

  1. Create directory "mkdir -+ /opt/traccar" and switch to "cd /opt/traccar"

  2. Download Traccar server zip file traccar-other-*.zip from traccar download page https://www.traccar.org/download/,
    use at the moment wget https://github.com/tananaev/traccar/releases/download/v3.11/traccar-other-3.11.zip

  3. Extract the zip file traccar-other-*.zip by using at the moment: "unzip traccar-other-3.11.zip
    and delete the zip file rm -f traccar-other-3.11.zip

After this step you have the server installed on your raspberry and you can start it with
"java -jar tracker-server.jar conf/traccar.xml" (in the /opt/traccar folder)
Check that the server starts. The last line should be something "Server - started". One line before you can see the server port of the webserver.
Open your browser and enter http://localhost:<port> (replace the port with the finding, usually 8082)
If the UI will be displayed all is correctly installed.

Some problems that can happen when you start the server:

  1. Port already in use - In this case use google to find a step by step doc to find the application that run on the used host and stop the service

For the next step press STRG+C to stop the server again.

If you want to install a autostart for traccar server follow the next steps:

  1. Change to /etc/systemd/system use cd /etc/systemd/system
  2. Create empty file with name traccar.service use touch traccar.service
  3. Open the file e.g. vi traccar.service
  4. Add the following content (e.g. press i to switch in insert mode):

[Unit]
Description=Traccar Service
After=network.target
Conflicts=shutdown.target

[Service]
WorkingDirectory=/opt/traccar
SyslogIdentifier=traccarserver
ExecStart=/bin/sh -c "exec java -jar tracker-server.jar conf/traccar.xml"
Type=simple
Restart=on-failure
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

  1. Save content and close file (e.g. press : and wq!)
  2. Reload systemd config by using "systemctl daemon-reload"
  3. Try to start service by using "systemctl start traccar.service"
  4. Check log in journalctrl if service starts correctly (e.g. call journalctrl and press page down and look for entries from "traccarservice", press STRG+C to close)
    --> You see there the same output as when you start it manually.
Dario5 years ago

Thanks, worked well on Armbian too, except for the autostart.
9) systemctl enable traccar.service

Motociklas5 years ago

Thanks for this guide, I managed install Traccar along Octoprint on pi Zero W (waiting for 3B+).
I'm new to this SSH so I don't really know how this thing work, but managed to enable autostart after shutdown.
So, after creating traccar.service file and adding command lines,
I changed file permition to allow access to everyone:

sudo chmod 0777 traccar.service

then enabled service with:

sudo systemctl enable traccar.service

after that it should print that something was created, and it shoud be it. Restart and it should bootup automaticly.
I hope this will help to someone.

Claudio Carrasco4 years ago

HI!

can I assign an external ip to access the raspberry as a vps?

regards!

Dario4 years ago

You can forward all requests to your rpi, setting portforwarding on your router (a vpn it's better but common trackers just send packets to an ip:port). To avoid security problems I hosted all on a hetzner's vps (3.04€/month, 1vcpu 2gb ram 20gb storage, few cents for backups, I'm really happy)

Claudio Carrasco4 years ago

Thanks Dario,

how many devices can you track with your hardware?

I have a google cloud platform instance with 10GB HDD, 3,75GB RAM, single core CPU and ubuntu 16.04 with only one tracker on it. I would like to get an idea of ​​how many devices this hardware could support.

Regards!

Dario4 years ago

It's absolutely overkill, actually I have 7 registered (but just 2 active now, other sends few points) and I am consuming 700mb of ram... You could try and if it's not enough just close it, you will pay the daily usage up to 3.04/month.

Claudio Carrasco4 years ago

I am on google testing the service with the 300 dollars of initial credit they offer, but I will definitely not stop there, it is very expensive. Contaboo has good prices, do you have any experience with them?

Actually I am also looking for more accurate information on the consumption of resources for 200 devices with a report every 30s to have a clear idea about which vps should I pay.

Dario4 years ago

I have no experience in it, but 200 devices are quite a lot, assuming a linear increase, you need a lot of ram. I read there are some possible optimizations, ask to Anton Tananaev, you need qualified help

Claudio Carrasco4 years ago

Hi Dario, I migrate to hetzner but I can't open the port 80.

Do you know how can I open it?

Regards!

rival3 years ago

I am successfully running Traccar on my Raspberry Pi but cannot get autostart to work using the script above.
Checking journalctl, I get:
traccar.service: Changing to the requested working directory failed: No such file or directory
traccar.service: Failed at step CHDIR spawning /bin/sh: No such file or directory

But /opt/traccar and /bin/sh do exist, with sh redirecting to dash.

Do I have a permissions problem? Grateful for advice on how to get this working. Many thanks.

Lorenzo3 years ago

Good evening, I used the script in the description but it does not start. If I start it manualy it boots up. This is what journalctl replies to me

ago 30 00:19:16 raspberrypi systemd[16170]: traccar.service: Failed to determine user credentials: No such process
ago 30 00:19:16 raspberrypi systemd[16170]: traccar.service: Failed at step USER spawning /bin/sh: No such process