SetUp Traccar on Google Cloud





SetUp Traccar on Google Cloud


This is a how to guide to set traccar up on a VM on Google Cloud, providing an overview on the commands needed to get traccar working fast. Since I managed to figure it out, it is a relatively simple job, however other VM guides needed some tweaking.Set up a Google VM Instance. Choose at least g1-small to avoid issues with installation. I used Ubuntu 18.04 LTS Boot disk.
Once the instance has been created, access your server using the cloud based SSH. And update the libraries:
sudo apt-get update -y
Next install Java and MYSQL:
sudo apt-get install unzip default-jre mysql-server -y
For some reason, it is necessary to create a new user. Login to MYSQL — the default password is set as “password”:
sudo mysql -u root -p
Next up create a user (traccar) and set the password:
CREATE USER 'traccar'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'traccar'@'localhost';
FLUSH PRIVILEGES;
With the user set up, it’s time to create a database called traccar, which will be used by the application when we install it:
create database traccar;
exit;
With MYSQL set up, now it’s time to download the latest traccar installer. Head over to https://www.traccar.org/download/ to grab the URL for the latest stable release and then:
wget https://github.com/tananaev/traccar/releases/download/v4.0/traccar-linux-4.0.zip
The unzip and install:
unzip traccar-linux-*.zip
sudo ./traccar.run
Time to build the config file with your MYSQL details:
nano traccar.xml
The paste in the following:
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'><properties><entry key="config.default">./conf/default.xml</entry><entry key='web.port'>80</entry><entry key='geocoder.enable'>false</entry><entry key='database.driver'>com.mysql.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://localhost/traccar?allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
    <entry key='database.user'>tobyt</entry>
    <entry key='database.password'>pa55word</entry>
    
    <entry key='server.timeout'>120</entry></properties>
Save the file and then move it to traccar’s config folder:
sudo cp traccar.xml /opt/traccar/conf/
remove the installer:
sudo rm -f traccar.run README.txt traccar-linux-*.zip
Start the app:
sudo /opt/traccar/bin/startDaemon.sh
  • 4.1 and later: sudo systemctl start traccar.service
  • 4.0 and earlier: sudo /opt/traccar/bin/startDaemon.sh

And watch the build log:
tail -f /opt/traccar/logs/wrapper.log.*
You can now login to your traccar server at the public URL of your VM using HTTP. user: admin — password: admin.






This is the first time that I have managed to figure out how to get something working and was not able to find someone else’s how-to guide, so I thought I would write one. Please let me know if you have comments or suggestions. I think this might be better deployed via docker?

Post a Comment

1 Comments

  1. Very well written article. It was an awesome article to read. Complete rich content and fully informative. I totally Loved it. Read more info about gcp

    ReplyDelete