Message: Unable to connect to PostgreSQL server - but everything seems working. Why?

169 views
Skip to first unread message

DUCARROZ Birgit

unread,
Nov 29, 2019, 10:25:39 AM11/29/19
to bareos...@googlegroups.com
Hi,

Just did a fresh installation. Everything seems working. I can run
bconsole, backup, restore and schedule jobs via the webUI.

But when running bareos-dir -t I get the following message:

bareos-dir: dird/dird.cc:927-0 Could not open Catalog "MyCatalog",
database "bareos".
bareos-dir: dird/dird.cc:932-0 cats/postgresql.cc:254 Unable to connect
to PostgreSQL server. Database=bareos User=bareos
Possible causes: SQL server not running; password incorrect;
max_connections exceeded.
bareos-dir ERROR TERMINATION
Please correct the configuration in /etc/bareos/bareos-dir.d/*/*.conf


This is my /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf

Catalog {
Name = MyCatalog
#dbdriver = ""
dbdriver = postgresql
dbname = bareos
dbuser = bareos
dbpassword = xxx
}



/usr/sbin/bareos-dbcheck -c /etc/bareos -B

gives me output:

catalog=MyCatalog
db_name=bareos
db_driver=postgresql
db_user=bareos
db_password=xxx
db_address=
db_port=0
db_socket=
db_type=PostgreSQL
working_dir=/var/lib/bareos

and
systemctl restart bareos-dir

shows no errors.


The service is started without errors:

service bareos-dir status
● bareos-director.service - Bareos Director Daemon service
Loaded: loaded (/lib/systemd/system/bareos-director.service;
enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-11-29 15:13:17 CET; 13s ago
Docs: man:bareos-dir(8)
Process: 59122 ExecStart=/usr/sbin/bareos-dir (code=exited,
status=0/SUCCESS)
Process: 59116 ExecStartPre=/usr/sbin/bareos-dir -t -f (code=exited,
status=0/SUCCESS)
Main PID: 59125 (bareos-dir)
Tasks: 4
Memory: 1.7M
CPU: 57ms
CGroup: /system.slice/bareos-director.service
└─59125 /usr/sbin/bareos-dir

Nov 29 15:13:17 diufnas26 systemd[1]: Starting Bareos Director Daemon
service...
Nov 29 15:13:17 diufnas26 systemd[1]: bareos-director.service: PID file
/var/lib/bareos/bareos-dir.9101.pid not
Nov 29 15:13:17 diufnas26 systemd[1]: Started Bareos Director Daemon
service.

These are my DB grants:
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
bareos | | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
| {}

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access
privileges
-----------+----------+-----------+-------------+-------------+-----------------------
bareos | postgres | SQL_ASCII | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres +
| | | | |
postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres +
| | | | |
postgres=CTc/postgres
(4 rows)

Changing the PW did not help.

postgres=# ALTER USER bareos WITH PASSWORD 'xxx';


Is this message relevant since everything seems running correctly?

Thank you for any help
Regards
Birgit




Vitaly Solntsev

unread,
Dec 2, 2019, 1:33:43 AM12/2/19
to DUCARROZ Birgit, bareos...@googlegroups.com
Hi

it caused by incorrect or incomplete settings in /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf

Check with postgresql client, if you're able to connect to bareos database with this credentials.

Also, add dbaddress = <hostname> option and dbport = <port> (if needed)




--
You received this message because you are subscribed to the Google Groups "bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bareos-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bareos-users/73f55e38-35bc-12ab-c9e1-340cd49bcbcc%40unifr.ch.

Andreas Rogge

unread,
Dec 2, 2019, 2:11:55 AM12/2/19
to bareos...@googlegroups.com
Hi,

depending on your PostgreSQL configuration (I don't know the defaults of
every Linux distribution) it may be possible that bareos-dir runnidn as
a service from systemd can connect to PostgreSQL while "bareos-dir -t"
from the commandline cannot.

So if everything works correctly (and you can still start your
bareos-dir after you stopped it) you can ignore that problem.

If you want to figure it out you can try to run bareos with user bareos
(i.e. "bareos-dir -u bareos -t") and/or try to increase the debug level
to get more information (i.e. "bareos-dir -t -d 100").

Best Regards,
Andreas

Am 29.11.19 um 16:25 schrieb 'DUCARROZ Birgit' via bareos-users:
--
Andreas Rogge andrea...@bareos.com
Bareos GmbH & Co. KG Phone: +49 221-630693-86
http://www.bareos.com

Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
Komplementär: Bareos Verwaltungs-GmbH
Geschäftsführer: S. Dühr, M. Außendorf, J. Steffens, Philipp Storz

signature.asc
Message has been deleted

Heike Jurzik

unread,
Dec 2, 2019, 8:49:01 AM12/2/19
to bareos...@googlegroups.com
Heya,

just an idea ...

On Mon, Dec 02, 2019 at 02:36:23PM +0100, 'DUCARROZ Birgit' via bareos-users wrote:

> root@diufnas26:/etc/bareos# bareos-dir -u bareos -t --> no error
> root@diufnas26:/etc/bareos# bareos-dir -t
>
> --> Error:
> "
> bareos-dir: dird/dird.cc:927-0 Could not open Catalog "MyCatalog", database
> "bareos".

[...]

It looks like you're trying to test this as user "root", have you tried
user "bareos" instead? A quick copy&paste from my test machine (Debian):

root@bareos-test:# bareos-dir -t
bareos-dir: dird/dird.cc:927-0 Could not open Catalog "MyCatalog", database "bareos".
bareos-dir: dird/dird.cc:932-0 cats/postgresql.cc:254 Unable to connect to PostgreSQL server. Database=bareos User=bareos
...

# su - bareos -s /bin/bash
bareos@bareos-test:~$ bareos-dir -t
-su: bareos-dir: Kommando nicht gefunden.
bareos@bareos-test:~$ /usr/sbin/bareos-dir -t
bareos@bareos-test:~$

Maybe that helps ...

Best,
Heike

--
Heike Jurzik heike....@bareos.com
Bareos GmbH & Co. KG pr...@bareos.com
http://www.bareos.com Phone: +49 177 2780503

Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
Komplementär: Bareos Verwaltungs-GmbH
Geschäftsführer: S. Dühr, M. Außendorf, J. Steffens, P. Storz

DUCARROZ Birgit

unread,
Dec 2, 2019, 8:53:37 AM12/2/19
to bareos...@googlegroups.com
Hi,

Yes, that's it:

The problem comes from the fact that I run bareos-dir -t as root user
and that the bareos user has no problem to connect but the root user has.

bareos-dir -u bareos -t works.

Thank you a lot!!

Kind regards,
Birgit

Vitaly Solntsev

unread,
Dec 2, 2019, 9:44:21 AM12/2/19
to DUCARROZ Birgit, bareos...@googlegroups.com
Hi, Birgit

as I said before, it's because you missed dbaddress part in your MyCatalog config.
(so bareos-dir -t -u bareos works, but bareos-dir -t doesn't work)

If you add dbaddress to MyCatalog.conf, both forms (with and without -u bareos) will not work 😀

So, I recommend to add dbaddress to catalog config file and check other connection parameters - all should work fine.






--
You received this message because you are subscribed to the Google Groups "bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bareos-users...@googlegroups.com.

DUCARROZ Birgit

unread,
Dec 2, 2019, 10:03:18 AM12/2/19
to Vitaly Solntsev, bareos...@googlegroups.com
Hi,

Thank you for responding again.
ok I added dbaddress and dport but it does not work. Same error if
trying just as root user:

Catalog {
Name = MyCatalog
#dbdriver = ""
dbdriver = postgresql
dbname = bareos
dbaddress = 192.168.1.126
dbport = 5432
dbuser = bareos
dbpassword = xxxxxx
}

but anyway, starting and restarting services work, bconsole, backup and
restoring also.

On 02/12/19 15:44, Vitaly Solntsev wrote:
> Hi, Birgit
>
> as I said before, it's because you missed dbaddress part in your
> MyCatalog config.
> (so bareos-dir -t -u bareos works, but bareos-dir -t doesn't work)
>
> If you add dbaddress to MyCatalog.conf, both forms (with and without -u
> bareos) will not work 😀
>
> So, I recommend to add dbaddress to catalog config file and check other
> connection parameters - all should work fine.
>
>
>
>
>
>
> On Mon, Dec 2, 2019 at 3:53 PM 'DUCARROZ Birgit' via bareos-users
> <bareos...@googlegroups.com <mailto:bareos...@googlegroups.com>>
> <mailto:bareos-users%2Bunsu...@googlegroups.com>.

Vitaly Solntsev

unread,
Dec 2, 2019, 10:28:41 AM12/2/19
to DUCARROZ Birgit, bareos...@googlegroups.com
did you try
psql -h 192.168.1.126  -U bareos bareos -p 5432
to check if your credentials correct to access bareos DB?




DUCARROZ Birgit

unread,
Dec 3, 2019, 10:19:04 AM12/3/19
to Vitaly Solntsev, bareos...@googlegroups.com
You're right. I used the wrong dbaddress.

Using dbaddress = 127.0.0.1 works!!

Thank you a lot!
Regards
Birgit
> <mailto:bareos...@googlegroups.com
> >     <mailto:bareos-users%2Bunsu...@googlegroups.com
> <mailto:bareos-users%252Buns...@googlegroups.com>>.
Reply all
Reply to author
Forward
0 new messages