Centos 7 MariaDB/MySQL Java

steve7 years ago
[root@chi bin]# ./traccar start
Starting traccar...
Waiting for traccar.......
WARNING: traccar may have failed to start.
[root@chi bin]# 

I modified the traccar.xml file to reflect I am using mariadb/mysql database
/opt/traccar/conf/traccar.xml

<!-- DATABASE CONFIG -->

<entry key='database.driver'>com.mysql.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost:3306/traccar?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>root</entry>
<entry key='database.password'>password</entry>

logs:

2017-03-11 18:43:53  INFO: Operating System name: Linux version: 3.10.0-514.10.2.el7.x86_64 architecture: amd64
2017-03-11 18:43:53  INFO: Java Runtime name: OpenJDK 64-Bit Server VM vendor: Oracle Corporation version: 24.131-b00
2017-03-11 18:43:53  INFO: Memory Limit heap: 643mb non-heap: 214mb
2017-03-11 18:43:53  INFO: Version: 3.1-SNAPSHOT
2017-03-11 18:51:10  INFO: Operating System name: Linux version: 3.10.0-514.10.2.el7.x86_64 architecture: amd64
2017-03-11 18:51:10  INFO: Java Runtime name: OpenJDK 64-Bit Server VM vendor: Oracle Corporation version: 24.131-b00
2017-03-11 18:51:10  INFO: Memory Limit heap: 643mb non-heap: 214mb
2017-03-11 18:51:10  INFO: Version: 3.1-SNAPSHOT

Java was installed right after MySQL was done.
The script was run to install traccar but there are no tables in MySQL and traccar will start then fail.

Any help would be appreciated.

  1. make sure the dbname, user and password is correct
  2. user service to start - /opt/traccar/bin/startDaemon.sh
steve7 years ago

Thanks for the tip. Once I created the database, I logged in then. I just tried it again to see that it didn't create and tables.

What is the next step you would recommend?

[root@chi ~]# mysql -uroot -ppassword traccar
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [traccar]> show tables ;
Empty set (0.00 sec)
steve7 years ago

BTW, I just downloaded and the bin file for traccar is now a little different:

  1. user service to start – /opt/traccar/bin/startDaemon.sh

the directory doesn't contact a startDaemon.sh. It now contains:

/opt/traccar/bin/traccar
/opt/traccar/bin/wrapper

but no startDaemon.sh.

follow simple steps

  1. create db in mysql
  2. assign a user to the db
  3. update the default.xml file with db name, user and password
  4. restart the service

it will create tables and dump data automatically

steve7 years ago

I have done this 3 times now. Each time I had to modify the /opt/traccar/conf/traccar.xml adding this information to use mysql:

<entry key='database.driver'>com.mysql.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost:3306/traccar?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>root</entry>
<entry key='database.password'>password</entry>

It still doesn't create the tables in the database traccar.

I have to be missing something but I don't know what it is.

I am able to log in using the above credentials to the database, of course there is no tables to see, is the modified .xml file correct as I have pasted?

steve7 years ago

I tried it again NOT modifying the traccar.xml file to use mysql and traccar started.

The issue I believe is with the modifications I made to the traccar.xml file to use mysql. I want to use mysql. I copy and pasted the section as the documentation says to do but it is not working creating the mysql tables or allowing traccar to start.

Can anyone tell me what is wrong with the modified file so that I can run traccar using mysql?

<entry key=’database.driver’>com.mysql.jdbc.Driver</entry>
<entry key=’database.url’>jdbc:mysql://localhost:3306/traccar?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=”</entry>
<entry key=’database.user’>root</entry>
<entry key=’database.password’>password</entry>
Anton Tananaev7 years ago

@steve, why are using old version of Traccar? I would recommend getting the latest one.

steve7 years ago

I didn't know that I was. I got it from github.

Thank you, I will look for the latest one and install.

Thanks very much for your help.

I am looking forward to using Traccar.

Steve

Anton Tananaev7 years ago

Even on GitHub the latest version is always on the top:

https://github.com/tananaev/traccar/releases

steve7 years ago

I have version 3.10 now installed. I want to use MySQL. I assume the instructions:

"By default Traccar Server uses embedded H2 database. If you want to use MySQL database engine you need to replace following lines in configuration file:" means /opt/traccar/config/traccar.xml?

I want to make sure I cam doing this correct.

Anton Tananaev7 years ago

Yes, correct.

steve7 years ago

It was obviously right. Thanks for your help. This is an awesome program. I have it installed using MySQL. It built the tables and installed as expected once I had the latest version install.

Awesome!

Thanks again.

steve7 years ago

I have no idea how I got that old version, thanks for pointing that out. I appreciate it.