SCADA-LTS / Scada-LTS

Scada-LTS is an Open Source, web-based, multi-platform solution for building your own SCADA (Supervisory Control and Data Acquisition) system.
GNU General Public License v2.0
727 stars 292 forks source link

Docker database connection conf #2892

Closed Lumevana closed 4 months ago

Lumevana commented 4 months ago

I'm trying to run Scada-LTS with docker compose on Ubuntu server. In yml file I changed database user and passwords because I didnt want to use defaults. But how I can change database user and password in Scada-LTS?

In documentation is described context.xml file change in /config directory but I can see /conf directory and file content is only three lines about watched resources and no database configuration info.

Currently Tomcat will give 404 and saying that "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

If I looked into container then the content is there in Scada-LTS directory. Is it problem that database user and password is out of sync between app and database that there is no web app error message?

Limraj commented 4 months ago

Hi @Lumevana,

  1. Here's how to install the client so you can run these queries: MySQL Client Windows MySQL Client Linux

  2. I have now created a wiki page about creating a new user in the database: Added-User-MySQL-Database-Server

Does this solve your problem?

Regards, Kamil Jarmusik

Lumevana commented 4 months ago

Actually my question is that I didnt find the place where I can enter database user and password in Scada-LTS container.

In my yml file the database section is following: **database: container_name: mysql image: mysql/mysql-server:8.0.32 restart: unless-stopped ports:

Now I assume that I must put newuser and newpassword to context.xml but there is no database section. Only three lines about watched resources. Where I write these new user and password in Scada-LTS?

Limraj commented 4 months ago

Hi @Lumevana, First, you need to login to the MySQL server as root, i.e. according to the default configuration, then create a new user according to the instructions. To do this you need a MySQL database client, I recommend DBeaver. After installation and connecting client to the database server from the docker container, you can execute the queries from the instructions.

Steps:

  1. Come back to default configuration in docker compose file;
  2. Run container with MySQL server; (in console execute command: docker-compose up database)
  3. Install DBeaver MySQL client and configuration connection client to server MySQL: MySQL Client Windows MySQL Client Linux
  4. Executed queries from instructions; Added-User-MySQL-Database-Server

These are links to our wiki, so it's worth taking a look there. :)

Configuration in tomcat

  1. Start container with scadalts, and login to console container:

    docker container ps
    docker exec -it scadalts_container_id /bin/bash

    And next execute command:

    mkdir /usr/local/tomcat/logs/conf
    cp -ar /usr/local/tomcat/conf/* /usr/local/tomcat/logs/conf/
  2. Stop container, added volume tomcat_conf for scadalts docker services; image

  3. Start container and copy files from docker/tomcat_log/conf to docker/tomcat_conf;

  4. Restart container;

  5. Now you can modify the configuration file on the host side; ./tomcat_conf/context.xml; image https://raw.githubusercontent.com/SCADA-LTS/Scada-LTS/develop/docker/config/context.xml

  6. After changed configuration restart tomcat (=restart container);

Regards, Kamil Jarmusik

Lumevana commented 4 months ago

Currently the context.xml file looks like this (comments from beginning are excluded):

**

<!-- Default set of monitored resources. If one of these changes, the    -->
<!-- web application will be reloaded.                                   -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

**

Do I have to manually add section <Resource name="jdbc/scadalts" etc ?

Limraj commented 4 months ago

Hi @Lumevana, Yes. Here is an default file for docker: https://raw.githubusercontent.com/SCADA-LTS/Scada-LTS/develop/docker/config/context.xml

We have an installer for Linux, where you configure everything during installation, you to do min manually. https://github.com/SCADA-LTS/linux-installer

Also remember that docker requires specific configuration to be used in a production environment.

Regards, Kamil Jarmusik

Lumevana commented 4 months ago

OK! I was afraid that I made something totally wrong because context.xml file was empty.

Now I added database section and Scada-LTS is up and running and I was able to log in.

One last question. There is classical BR version UI and modern UI. Modern UI shows that its offline. I'm running it through Cloudflare tunnel. What ports modern UI is using or what is principally different from classical UI?

I'm testing it later next to server without Cloudflare to be sure that everything is OK locally.

Limraj commented 4 months ago

@Lumevana, the greatest functionality is on the old UI, here we focus on developing functions and additionally try to transfer them to the new UI. The new UI is in the experimental phase. I understand that I can close the issue?

Lumevana commented 4 months ago

Yes, this can be closed. Database is changed and connected.

Limraj commented 4 months ago

@Lumevana If you are not familiar with using Docker, we do not recommend using it in production. Better to use the installer.