View Issue Details

IDProjectCategoryView StatusLast Update
0000267Bacula-Webbugpublic2018-11-17 10:51
ReporterjrtaaffeAssigned Todavide 
PrioritynormalSeverityblockReproducibilityalways
Status assignedResolutionopen 
Product Version8.0.1 
Target VersionFixed in Version 
Summary0000267: Unable to connect to Bacula catalog (MySQL)
DescriptionI have been unsuccessful getting bacula-web up and running. After logging is as "admin" I get an error:

Problem: SQLSTATE[HY000] [2002] Connection refused

I am running php7.0, apache2, sqlite on ubuntu. Here is the full error page that I see:


Database error
Details

A problem with the description below happen
Problem: SQLSTATE[HY000] [2002] Connection refused
Help
Have you tried to run the test page ?
Check the online documentation on Bacula-Web project site
Rebort a bug or suggest a new feature in the Bacula-Web's bugtracking tool
Debug
File: /var/www/html/bacula-web/core/db/cdb.class.php
Line: 42
Code: 2002
Exception trace
File: /var/www/html/bacula-web/core/db/cdb.class.php on line 42 in function PDO->__construct
File: /var/www/html/bacula-web/core/app/cmodel.class.php on line 46 in function CDB->connect
File: /var/www/html/bacula-web/application/views/dashboard.view.php on line 32 in function CModel->__construct
File: /var/www/html/bacula-web/core/app/webapplication.class.php on line 106 in function DashboardView->prepare
File: /var/www/html/bacula-web/index.php on line 21 in function WebApplication->run
TagsNo tags attached.

Activities

davide

2018-10-30 21:14

manager   ~0000866

Last edited: 2018-10-30 21:15

View 2 revisions

Hello,

Thanks for reporting this bug.
Can you check if web server (I guess Apache) has enough permissions on Bacula SQLite database file ?

P.S: I've to admit that SQLite db support deserve some improvements with Bacula-Web.

Thanks for your feedback

jrtaaffe

2018-10-31 19:57

reporter   ~0000867

How do I go about getting that information? I am very new to this - sorry.

davide

2018-11-01 02:44

manager   ~0000868

Can you send me your config file please ?

jrtaaffe

2018-11-01 06:44

reporter   ~0000869

Thank you so very much for your help. You are very kind and I appreciate your patience.

config.php (2,247 bytes)

davide

2018-11-01 09:50

manager   ~0000870

First of all, try to connect to Bacula database using mysql client.
$ mysql -u bacula -p -h localhost bacula


If the mysql connection using bacula account doesn't work, you'll need to fix this first.

A part of that, please provide output of this command
$ find /var/www/bacula-web/application/assets/protected -ls

You can adapt path of Bacula-Web folder is needed

Thanks for your feedback

jrtaaffe

2018-11-01 15:16

reporter   ~0000871

The mysql connection using bacula does NOT work. I'm trying to figure that out now, but any tips would be welcome.

Here's the output from the 'find' command. Notice that my setup has an 'html' directory inside of 'www'.

$ find /var/www/html/bacula-web/application/assets/protected -ls
   652273 4 drwxrwxr-x 2 www-data www-data 4096 Oct 30 09:17 /var/www/html/bacula-web/application/assets/protected
   652274 4 -rwxrwxrwx 1 www-data www-data 98 Jun 22 10:50 /var/www/html/bacula-web/application/assets/protected/.htaccess
   656519 12 -rwxrwxrwx 1 www-data www-data 12288 Oct 30 09:17 /var/www/html/bacula-web/application/assets/protected/application.db

davide

2018-11-02 08:00

manager   ~0000872

Just a quick remark

You mentioned this
I am running php7.0, apache2, sqlite on ubuntu. ...

But your config.php file doesn't contain any SQLite catalog defined. Is it a typo in your initial request ?

To troubleshoot your MySQL connection problem, try to use the password defined in Bacula configuration.
You should find it in bacula-dir.conf file in the Catalog ressource
Catalog {
 Name = MyCatalog
 dbname = "bacula"; DB Address = ""; dbuser = "bacula"; dbpassword = "XXXXXXX"
}

Use the dbpassword value to connect to MySQL.

Also make sure you have installed SQLite support for PHP
$ php -i | grep -i SQLite


Hope it helps

jrtaaffe

2018-11-05 15:52

reporter   ~0000873

I've been sick for the past few days, but I'm back now. Here's where things stand. The bacula-web test page is now running correctly (thanks to your help) but the dashboard throws the following error:


Details
A problem with the description below happen

Problem: SQLSTATE[HY000]: General error: 1 no such table: Job
Help
Have you tried to run the test page ?
Check the online documentation on Bacula-Web project site
Rebort a bug or suggest a new feature in the Bacula-Web's bugtracking tool
Debug
File: /var/www/html/bacula-web/core/app/cmodel.class.php
Line: 112
Code: HY000
Exception trace
File: /var/www/html/bacula-web/core/app/cmodel.class.php on line 112 in function PDO->prepare
File: /var/www/html/bacula-web/application/models/jobs.model.php on line 104 in function CModel->run_query
File: /var/www/html/bacula-web/application/views/dashboard.view.php on line 82 in function Jobs_Model->count_Jobs
File: /var/www/html/bacula-web/core/app/webapplication.class.php on line 106 in function DashboardView->prepare
File: /var/www/html/bacula-web/index.php on line 21 in function WebApplication->run

davide

2018-11-06 07:42

manager   ~0000874

Hi,
This doesn't look to be Bacula-Web related, but Bacula's instead.
Did you initialize your Bacula catalog ?. I guess you've never run a job on it, right ?

Bacula.org 9.2 manual
http://www.bacula.org/9.2.x-manuals/en/main/Installing_Configuring_MySQ.html

Hope it helps

jrtaaffe

2018-11-06 11:33

reporter   ~0000875

I will see what I can find in the Bacula config and documentation, but it IS running nightly (successfully as far as I can tell - I haven’t actually restored anything yet, but I have plenty of data indicating successful jobs)

davide

2018-11-07 07:43

manager   ~0000876

Can you try to run this command using the credentials you've in config.php ?
mysql -u bacula -p bacula -h localhost  -e "show tables"

This command should return the list of tables in Bacula database.

Also, a copy of Apache error log would be really helpful.

I'd need the output of this command

On RedHat,Centos,Fedora (rpm)
# rpm -qa | grep php


On Debian, Ubuntu
# dpkg -l | grep php


Thanks for your feedback

jrtaaffe

2018-11-07 08:16

reporter   ~0000878

ii libapache2-mod-php 1:7.0+49 all server-side, HTML-embedded scripting language (Apache 2 module) (default)
ii libapache2-mod-php7.0 7.0.30-0+deb9u1 armhf server-side, HTML-embedded scripting language (Apache 2 module) ii php 1:7.0+49 all server-side, HTML-embedded scripting language (default)
ii php-cli-prompt 1.0.2+dfsg-1 all tiny helper prompting for user input
ii php-common 1:49 all Common files for PHP packages
ii php-composer-ca-bundle 1.0.2-1 all utility library to find a path to the system CA bundle
ii php-composer-semver 1.4.2-1 all utilities, version constraint parsing and validation
ii php-composer-spdx-licenses 1.1.5-1 all SPDX licenses list and validation library
ii php-json-schema 1.6.1-2 all implementation of JSON schema
ii php-mysql 1:7.0+49 all MySQL module for PHP [default]
ii php-pgsql 1:7.0+49 all PostgreSQL module for PHP [default]
ii php-psr-log 1.0.0-4 all common interface for logging libraries
ii php-symfony-console 2.8.7+dfsg-1.3+deb9u1 all run tasks from the command line
ii php-symfony-filesystem 2.8.7+dfsg-1.3+deb9u1 all basic filesystem utilities
ii php-symfony-finder 2.8.7+dfsg-1.3+deb9u1 all find files and directories
ii php-symfony-polyfill-mbstring 1.2.0-1 all Symfony polyfill for the Mbstring extension
ii php-symfony-process 2.8.7+dfsg-1.3+deb9u1 all execute commands in sub-processes
ii php7.0 7.0.30-0+deb9u1 all server-side, HTML-embedded scripting language (metapackage)
ii php7.0-cli 7.0.30-0+deb9u1 armhf command-line interpreter for the PHP scripting language
ii php7.0-common 7.0.30-0+deb9u1 armhf documentation, examples and common module for PHP
ii php7.0-fpm 7.0.30-0+deb9u1 armhf server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.0-json 7.0.30-0+deb9u1 armhf JSON module for PHP
ii php7.0-mysql 7.0.30-0+deb9u1 armhf MySQL module for PHP
ii php7.0-opcache 7.0.30-0+deb9u1 armhf Zend OpCache module for PHP
ii php7.0-pgsql 7.0.30-0+deb9u1 armhf PostgreSQL module for PHP
ii php7.0-readline 7.0.30-0+deb9u1 armhf readline module for PHP
ii php7.0-sqlite3 7.0.30-0+deb9u1 armhf SQLite3 module for PHP

jrtaaffe

2018-11-07 08:30

reporter   ~0000880

Here's something else that I've neglected to mention: Apache is running on port 8080 instead of just 80. (I have a proxy server using 80)

davide

2018-11-07 08:54

manager   ~0000881

Good point, but I don't think this explain your database connection issue.

What about SQL query output and Apache error log ?

Thanks for your feedback

jrtaaffe

2018-11-07 09:37

reporter   ~0000884

In my original post I believe that I indicated that I'm using "sqlite". Although I've installed support for sqlite and have tried some setups using it, I am in fact using mysql.

FYI - In the interested of just getting started, I'm using root privileges in my connections (obviously that should be changed eventually) But when I run the command that you requested I get:
#############################################################
$ mysql -u bacula -p bacula -h localhost -e "show tables"
Warning: World-writable config file '/etc/mysql/my.cnf' is ignored
Enter password:
ERROR 1044 (42000): Access denied for user 'bacula'@'localhost' to database 'bacula'
##############################################################

When I log into mysql as root and view the databases via "show databases" I get:

#######################################################
$ mysql -u root -p
Warning: World-writable config file '/etc/mysql/my.cnf' is ignored
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0

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

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

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)
##########################################

There's no 'bacula' db listed.

But I can access bacula using bconsole and view the latest backup runs:

#######################################################################
Scheduled Jobs:
Level Type Pri Scheduled Job Name Volume
===================================================================================
Incremental Backup 10 07-Nov-18 23:05 BackupLocalFiles BackupVolume1
Full Backup 11 07-Nov-18 23:10 BackupCatalog BackupVolume1
====

Running Jobs:
Console connected at 07-Nov-18 03:28
No Jobs running.
====

Terminated Jobs:
 JobId Level Files Bytes Status Finished Name
====================================================================
    29 Incr 395 16.00 M OK 02-Nov-18 23:05 BackupLocalFiles
    30 Full 1 50.68 M OK 02-Nov-18 23:10 BackupCatalog
    31 Incr 263 3.689 M OK 03-Nov-18 23:05 BackupLocalFiles
    32 Full 1 50.72 M OK 03-Nov-18 23:10 BackupCatalog
    33 Full 166,129 2.990 G OK 04-Nov-18 23:50 BackupLocalFiles
    34 Full 1 73.79 M OK 04-Nov-18 23:51 BackupCatalog
    35 Incr 292 5.243 M OK 05-Nov-18 23:05 BackupLocalFiles
    36 Full 1 73.84 M OK 05-Nov-18 23:10 BackupCatalog
    37 Incr 239 4.486 M OK 06-Nov-18 23:05 BackupLocalFiles
    38 Full 1 73.88 M OK 06-Nov-18 23:10 BackupCatalog

====
######################################################

So why can't I see the bacula db from within mysql?

davide

2018-11-07 10:16

manager   ~0000885

Hi,

This potentially means that you're not using MySQL (at least on localhost), but using a different database back end.

Please provide me the Catalog resource define in Bacula configuration file (should be defined in bacula-dir.conf).
I don't need clear password, just hide it with XXXXXX

Thanks for your feedback

jrtaaffe

2018-11-07 12:10

reporter  

bacula-dir.conf (8,565 bytes)

davide

2018-11-10 08:39

manager   ~0000888

Last edited: 2018-11-10 08:39

View 2 revisions

Hi,

Sorry, I've been busy other last few days.

I can't find any useful information in the config file you provided.

can you run this command with all bacula service up please ?
# netstat -ltapn


Thanks for your feedback

jrtaaffe

2018-11-10 09:34

reporter   ~0000889

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 581/vncserver-x11-c
tcp 0 0 127.0.0.1:9101 0.0.0.0:* LISTEN 816/bacula-dir
tcp 0 0 127.0.0.1:9102 0.0.0.0:* LISTEN 604/bacula-fd
tcp 0 0 192.168.1.45:9103 0.0.0.0:* LISTEN 609/bacula-sd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 639/haproxy
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 645/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1255/exim4
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 639/haproxy
tcp 0 0 192.168.1.23:443 192.168.1.1:41670 ESTABLISHED 639/haproxy
tcp 0 0 192.168.1.45:5900 192.169.158.211:62840 TIME_WAIT -
tcp 0 196 192.168.1.45:22 192.168.1.40:62982 ESTABLISHED 1445/sshd: pi [priv
tcp 0 0 127.0.0.1:46085 127.0.0.1:59034 ESTABLISHED 1336/vncserverui
tcp 0 0 192.168.1.45:46478 192.168.1.31:3000 ESTABLISHED 639/haproxy
tcp 0 0 127.0.0.1:59034 127.0.0.1:46085 ESTABLISHED 581/vncserver-x11-c
tcp6 0 0 :::3306 :::* LISTEN 656/mysqld
tcp6 0 0 :::5900 :::* LISTEN 581/vncserver-x11-c
tcp6 0 0 :::8080 :::* LISTEN 688/apache2
tcp6 0 0 :::22 :::* LISTEN 645/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1255/exim4

davide

2018-11-10 10:05

manager   ~0000890

I can see that mysql is listening on ipv6 only.
tcp6 0 0 :::3306 :::* LISTEN 656/mysqld


I'm not a database expert at all and I might be wrong, but this might explain why you can't connect to it using localhost.

You can confirm this by running this command (should fail)
telnet localhost 3306

Check your MySQL server configuration to enable ipv4 too.

Hope it helps

Issue History

Date Modified Username Field Change
2018-10-30 10:39 jrtaaffe New Issue
2018-10-30 21:12 davide Assigned To => davide
2018-10-30 21:12 davide Status new => assigned
2018-10-30 21:14 davide Status assigned => feedback
2018-10-30 21:14 davide Note Added: 0000866
2018-10-30 21:15 davide Note Edited: 0000866 View Revisions
2018-10-31 19:57 jrtaaffe Note Added: 0000867
2018-10-31 19:57 jrtaaffe Status feedback => assigned
2018-11-01 02:44 davide Status assigned => feedback
2018-11-01 02:44 davide Note Added: 0000868
2018-11-01 06:44 jrtaaffe File Added: config.php
2018-11-01 06:44 jrtaaffe Note Added: 0000869
2018-11-01 06:44 jrtaaffe Status feedback => assigned
2018-11-01 09:50 davide Status assigned => feedback
2018-11-01 09:50 davide Note Added: 0000870
2018-11-01 15:16 jrtaaffe Note Added: 0000871
2018-11-01 15:16 jrtaaffe Status feedback => assigned
2018-11-02 08:00 davide Note Added: 0000872
2018-11-05 15:52 jrtaaffe Note Added: 0000873
2018-11-06 07:42 davide Note Added: 0000874
2018-11-06 07:43 davide Summary can not get test page working => Unable to connect to Bacula catalog (MySQL)
2018-11-06 11:33 jrtaaffe Note Added: 0000875
2018-11-07 07:43 davide Status assigned => feedback
2018-11-07 07:43 davide Note Added: 0000876
2018-11-07 08:16 jrtaaffe Note Added: 0000878
2018-11-07 08:16 jrtaaffe Status feedback => assigned
2018-11-07 08:30 jrtaaffe Note Added: 0000880
2018-11-07 08:54 davide Note Added: 0000881
2018-11-07 09:37 jrtaaffe Note Added: 0000884
2018-11-07 10:16 davide Status assigned => feedback
2018-11-07 10:16 davide Note Added: 0000885
2018-11-07 12:10 jrtaaffe File Added: bacula-dir.conf
2018-11-10 08:39 davide Note Added: 0000888
2018-11-10 08:39 davide Note Edited: 0000888 View Revisions
2018-11-10 09:34 jrtaaffe Note Added: 0000889
2018-11-10 09:34 jrtaaffe Status feedback => assigned
2018-11-10 10:05 davide Note Added: 0000890
2018-11-17 10:51 davide Category security-issue => bug