Daily.sh with database on separate server

I have been having trouble with performance with having all services on one server. I decided to move my database to its own server. There are two lines of code that are in my .env file that I have removed because it breaks the connection to the database:

DB_PORT=3306
DB_SOCKET=/run/mysqld/mysqld.sock

After removal, Librenms is functioning. In the evening though or manually, if if daily.sh runs, it adds the above two lines into the file. The file is not replaced because if I comment out the two lines, they are added back. That leads me to two questions.

Is this by design that this happens and where does it come from?

If the above values are needed to operate, does it need to be added to the external database server or does the value just need to be changed and where?

===========================================

Component Version
LibreNMS 24.3.0-5-g6b2be73a3 (2024-04-02T07:06:25-05:00)
DB Schema 2021_02_09_122930_migrate_to_utf8mb4 (290)
PHP 8.1.2-1ubuntu2.14
Python 3.10.12
Database MariaDB 11.3.2-MariaDB-1:11.3.2+maria~deb12
RRDTool 1.7.2
SNMP 5.9.1
===========================================

[OK] Composer Version: 2.7.2
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQL and PHP time match
[OK] Active pollers found
[OK] Dispatcher Service not detected
[OK] Locks are functional
[OK] Python poller wrapper is polling
[OK] Redis is unavailable
[OK] rrdtool version ok
[OK] Connected to rrdcached
[WARN] Your install is over 24 hours out of date, last update: Tue, 02 Apr 2024 12:06:25 +0000
[FIX]:
Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.

This is the daily.sh results:
Updating to latest codebase OK
Updating Composer packages OK
Updating SQL-Schema FAIL

In Connection.php line 829:

SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: update cache_locks set owner = OByBwRFqTQfUmtGM, expiration = 1712176354 where key = l
aravel_cache_framework/command-migrate and (owner = OByBwRFqTQfUmtGM or expiration <= 1712172754))

In Connector.php line 65:

SQLSTATE[HY000] [2002] No such file or directory

Updating submodules OK
Cleaning up DB OK
Fetching notifications OK
Caching PeeringDB data OK

After this, I have to remove the two lines and everything begins to function.

Thanks

Hello,
have you tired taking a look in the config.php and check if the database connections are correct in there?

Both of those setting are in that config file. Do those setting overwrite what is in the .env file?

What do you mean with “Both of those setting are in that config file”?
In the config there should be only one connection to the database:
$config[‘db_host’] = ‘’;
$config[‘db_port’] = ‘’;
$config[‘db_user’] = ‘’;
$config[‘db_pass’] = ‘’;
$config[‘db_name’] = ‘’;

if you have a $config[‘db_socket’] set comment it out and try again

In the config.php, these two setting are set:

$config[‘db_host’] = “XX.XX.XX.XX”;
$config[‘db_port’] = ‘3306’;
$config[‘db_user’] = ‘librenms’;
$config[‘db_pass’] = ‘XXXXXXXXXXXXXXXXXXXXX’;
$config[‘db_name’] = ‘librenms’;
$config[‘distributed_poller’] = true;
$config[‘distributed_poller_name’] = php_uname(‘n’);
$config[‘distributed_poller_group’] = ‘0’;

$config[‘db_socket’] = ‘/run/mysqld/mysqld.sock’;

but in the .env file, if the two lines below are present with the DB settings:
DB_PORT=3306
DB_SOCKET=/run/mysqld/mysqld.sock

when I ./validate.php, it will say it can not connect to the DB.

I will try commenting out the socket in the config.php file.

Okay, it seems what is in the config.php file will add itself to the .env file. It is just the value below that causes problems if it is not commented out in the config.php file:

$config[‘db_socket’] = ‘/run/mysqld/mysqld.sock’;

It will put this entry into the .env file break the DB connection.

I must have set this setting because of this document:

./daily.sh seems to run fine now.

Glad to hear its working. I think the documentation mean the socket option as another option if you don’t want to use the host, not to use them at the same time

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.