axelmasok () — 2011-09-13T20:05:58-04:00 — #1
FreePBX Version: 2.7.0
Asterisk18 Version : 126.96.36.199
So it didn't break itself.... I installed vTigerCRM which installed a new database in mysql but didn't affect the asterisk database or freepbx:fpbx login. I did however stuff the permissions in /var/www/html/*. I recovered all the folders/files in html from good backups and restored ownership of the freepbx folders to asterisk:asterisk.
So I get the error : "DB Error: unknown error" and emails with "[FATAL] database connection failure failed trying to connect to the configured database"
I've run "mysqlcheck -r asterisk" and everything reports back "OK".
Any ideas? I thought reinstalling everything again was in order (I am loathed to do that, this is not a windows box far out) but reinstalling asterisk and freepbx from scratch is a PITA. So damned complex black magic.
Thanks for any help.
axelmasok () — 2011-09-14T20:31:12-04:00 — #2
OK, what about backing up the asterisk DB, removing it and importing a fresh/blank copy? Not sure where I would get that from?
billsimon () — 2011-09-14T21:29:04-04:00 — #3
Can you connect to the database with the credentials that FreePBX knows? (In other words, the username and password FreePBX would use to connect.) In FreePBX 2.7, these are in the /etc/amportal.conf file as AMPDBUSER and AMPDBPASS.
Type "mysql -u USERNAME -p PASSWORD asterisk"
change the USERNAME and PASSWORD to the right ones of course.
Does it connect?
If not, is MySQL running? (ps ax | grep mysqld)
Is it listening? (netstat -an | grep LISTEN | grep 3306) You should see a line for 0.0.0.0:3306 LISTEN or maybe 127.0.0.1:3306 LISTEN.
Any interesting errors in the web server's error_log?
axelmasok () — 2011-09-15T04:37:24-04:00 — #4
Hello, thanks for the reply.
I should have been more specific in the first post but yes MYSQL is running and yes can connect to database asterisk with username and password (AMPDBUSER=freepbx, AMPDBPASS=fpbx) as per the default install.
As for /var/log/httpd/error_log , no nothing interesting really. Everytime I try and access http://192.168.64.2/admin/ I get the fabled:
[Thu Sep 15 18:35:34 2011] [error] [client 192.168.64.2] File does not exist: /var/www/html/favicon.ico
... which is irrelevant.
axelmasok () — 2011-09-20T18:28:46-04:00 — #5
This still isn't resolved. The system is emailing be about the DB error every hour. Hour after hour....
There's obviously a corruption of the DB. Can anyone suggest some steps to create a new database?
billsimon () — 2011-09-21T10:49:40-04:00 — #6
The freepbx-cron-scheduler.php file is the one generating the alerts/e-mails to you.
It just does a database connectivity test. So it's got to be a permissions issue.
This is the code that runs:
/* datasource in in this style:
$db_user = $amp_conf["AMPDBUSER"];
$db_pass = $amp_conf["AMPDBPASS"];
$db_host = $amp_conf["AMPDBHOST"];
$db_name = $amp_conf["AMPDBNAME"];
$datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;
$db = DB::connect($datasource); // attempt connection
As you can see it seems to do nothing except attempt connection. Then if that doesn't work this is the notice you get:
fatal(_("database connection failure"),("failed trying to connect to the configured database"));
Why don't you try resetting privileges using commands like this (start with 'mysql -u root' or 'mysql -u root -p' and type the mysql root password):
mysql> grant all privileges on asteriskcdrdb.* to USERNAME@localhost identified by 'PASSWORD';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on asterisk.* to USERNAME@localhost identified by 'PASSWORD';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
(change USERNAME and PASSWORD to the right ones of course)
axelmasok () — 2011-09-21T18:49:14-04:00 — #7
Thanks again billsimon.
I ran the resetting privileges command you suggested - they ran fine without error. Restarted amportal, restarted httpd - same error, no progress.
Looking at that code snippet you showed me, I can verify this:
- Configuration file is /etc/amportal.conf. It is untouched by me from initial install and includes the following to prove the values are actually there.
I can run "mysql -u freepbx -p asterisk" with password "fpbx" and I get access to the database.
My asterisk runs fine, the web interface is obviously the issue. It urks me that something simple can render this interface unusable.
axelmasok () — 2011-10-06T01:17:46-04:00 — #8
OK, I've uninstalled everything FreePBX but left Asterisk installed.
Can anyone tell me how to stop the emails being sent to me every hour??
skykingoh () — 2011-10-06T02:10:01-04:00 — #9
How did you uninstall FreePBX? Sounds like the cron job is still running.
You could have just rerun the install_amp script.
My guess is that the db settings are declared again at the bottom of amportal.conf. Last declaration wins.
axelmasok () — 2011-10-07T01:13:46-04:00 — #10
Uninstall FreePBX? Sure, "yum remove freepbx" worked here Are you saying I could have run the install_amp script and it would have re-initialised the freepbx install, database and all? Perhaps I should delete the asterisk DB from MYSQL then run the script (if it exists here)?
There are no duplicates in my amportal.conf. It was never changed since the initial install. Absolute default. Somehow the database has corrupt or something...
Still getting an email every hour. I see no cron jobs anywhere for it.
skykingoh () — 2011-10-07T01:26:58-04:00 — #11
Gotta be a cron job. FreePBX does not produce an RPM, it is distributed as a tarball so I am not sure of where you got the RPM, maybe other distro's repackage it.
What happens if you use the command line tool to access the database:
mysql -u username -p
axelmasok () — 2011-10-09T19:26:04-04:00 — #12
Found it darn it. I had a brain fart and didn't look under /var/spool/cron/. There's an asterisk item there:
0 0 0 /var/lib/asterisk/bin/ampbackup.php 1
Should have just disabled that.
I'm in the process of removing all of asterisk and freepbx, databases, everything and reloading from scratch which I think is the ultimate cop out. I've been a Linux user since 1998 and it is rare I have been unable/unmotivated to work out why a package went mental. IMO, FreePBX is still poorly documented with the most bizzaar forum software/format I've ever seen. If I wasn't so lazy I would go back to running asterisk from .conf files.
Regarding RPMs. I'm using the asterisk-current repo under Centos 5.7.
skykingoh () — 2011-10-09T20:03:03-04:00 — #13
amalantony () — 2011-12-16T15:34:49-05:00 — #14
I had the same error in my centos 5.5