GPS Tracking System Traccar

insert image description here

What is Traccar?

Traccaris an open source GPStracking system. Supports 200multiple GPSprotocols and 2000multiple models of GPStracking devices. Of course, it also includes mobile devices like iOS/Androidthis , which Traccarcan be used only by installing the client.

The previously introduced Haukonly supports Androidthe client, which is suitable for personal sharing; while the application range Traccarof is obviously much wider, and can be used in industry applications such as fleet management and taxi management.

Prepare

traccar.xml

The official method is to execute the container once to get the defaulttraccar.xml

The first step, create a working directory

# 新建文件夹 traccar 和 子目录
mkdir -p /volume2/docker/traccar/logs

# 进入 traccar 目录
cd /volume2/docker/traccar

The second step, get the default traccar.xmlfile

docker run \
    --rm \
    --entrypoint cat \
    traccar/traccar:latest \
    /opt/traccar/conf/traccar.xml > /opt/traccar/traccar.xml

Of course, the easier way is to save the following content directly astraccar.xml

<?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>

    <!--

    This is the main configuration file. All your configuration parameters should be placed in this file.

    Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
    with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
    remove "config.default" parameter from this file unless you know what you are doing.

    For list of available parameters see following page: https://www.traccar.org/configuration-file/

    -->

    <entry key='database.driver'>org.h2.Driver</entry>
    <entry key='database.url'>jdbc:h2:./data/database</entry>
    <entry key='database.user'>sa</entry>
    <entry key='database.password'></entry>

</properties>

For a detailed description of the configuration file, you can see the official document: https://www.traccar.org/configuration-file/

database

In the default setting, H2the database , which is an Javaembedded database developed with . It is only a class library, that is, there is only one jarfile . It can be directly embedded into the application project, but it is not recommended to be used in the production environment.

If you want to change MySQL, for example, use the one that comes with Synology MariaDB, you can refer to the official document: https://www.traccar.org/mysql/ to modify traccar.xmlthe file .

However, Lao Su has never tried it, so he is not sure if there will be any problems, so it may be easier to open another MySQLcontainer ;

port

The official installation method needs to open the port range, 5000-5150the protocol includes TCP/UDP, this method is relatively easy, but for us, on the one hand, there are not so many devices to support, on the other hand, Synology itself occupies some of the ports , such as the most conventional 5000, if WebDAV Serverenabled , may 5005also be occupied

So Lao Su's suggestion is to open ports on demand. Open https://www.traccar.org/devices/ and find GPSthe device

If you can't find it, you can try to identify it by protocol: https://www.traccar.org/identify-protocol/

But if you are just using the mobile appterminal , it is also possible not to open another port

Install

Install it in Docker mode on Synology.

Search in the registry traccar, select the first one traccar/traccar, version selection latest.

At the time of writing this article, latestthe version corresponds to 5.7;

roll

Inside dockerthe folder , create a new folder traccarwith a subfolder inside itlogs

folder mount path illustrate
docker/traccar/logs /opt/traccar/logs store log
docker/traccar/traccar.xml /opt/traccar/conf/traccar.xml settings file

port

It is fine if the local port does not conflict. If you are not sure, you can check it with the command

# 查看端口占用
netstat -tunlp | grep 端口号
local port container port
8082 8082

By default no ports are exposed

Need to add +by

If the device you want to add needs to use ports 5023, you need to add TCPandUDP

command line installation

If you are familiar with the command line, it may be docker clifaster

# 新建文件夹 traccar 和 子目录
mkdir -p /volume2/docker/traccar/logs

# 进入 traccar 目录
cd /volume2/docker/traccar

# 获取 traccar.xml 文件
docker run \
    --rm \
    --entrypoint cat \
    traccar/traccar:latest \
    /opt/traccar/conf/traccar.xml > ./traccar.xml

# 根据需要对 traccar.xml 文件进行修改

# 运行容器(标准)
docker run -d \
   --restart unless-stopped \
   --name traccar \
   -p 8082:8082 \
   -p 5000-5150:5000-5150 \
   -p 5000-5150:5000-5150/udp \
   -v $(pwd)/logs:/opt/traccar/logs \
   -v $(pwd)/traccar.xml:/opt/traccar/conf/traccar.xml:ro \
   traccar/traccar:latest

# 运行容器(只使用手机app)
docker run -d \
   --restart unless-stopped \
   --name traccar \
   -p 8082:8082 \
   -v $(pwd)/logs:/opt/traccar/logs \
   -v $(pwd)/traccar.xml:/opt/traccar/conf/traccar.xml:ro \
   traccar/traccar:latest

You can also use docker-composethe installation , save the following content as docker-compose.ymla file

version: '3'

services:
  traccar:
    image: traccar/traccar:latest
    container_name: traccar
    restart: unless-stopped
    ports:
      - 8082:8082
    volumes:
      - ./logs:/opt/traccar/logs
      - ./traccar.xml:/opt/traccar/conf/traccar.xml:ro

Then execute the following command

# 新建文件夹 traccar 和 子目录
mkdir -p /volume2/docker/traccar/logs

# 进入 traccar 目录
cd /volume2/docker/traccar

# 将 docker-compose.yml 放入当前目录

# 一键启动
docker-compose up -d

run

Enter in the browser http://群晖IP:8082, the first time you need to register

After successful registration, you can log in

set map

enter 设置--> 首选项--> 地图-->已选地图

Among them, the red map needs it key, and the black one doesn't need it;

The system has checked 3the type of , you can choose again 高德地图, after saving, you can switch on the home page

+/-dot to scale

mobile app

Download address of the mobile terminal: https://www.traccar.org/client/

Lao Su is still on the download Androidplatform

Openapp

Modify server address

After saving, directly enable定位服务

Pay attention to your device code, which will be used when adding a device;

add device

Click on Webthe main interface +to add注册您的第一台设备

Fill in the name and device number

After returning to the home page, there will be a newly added device on the left

The location of the device will also be shown on the map

Then you can do operations such as tracking tracks, setting fences, etc.

reference documents

Traccar
address: https://github.com/traccar/

Source Code - Traccar
address: https://www.traccar.org/source-code/

traccar/traccar-docker: Traccar Docker
地址:https://github.com/traccar/traccar-docker

Guess you like

Origin blog.csdn.net/wbsu2004/article/details/131119885