Zabbix frontend Error connecting to database - database-connection

I am having a problem at zabbix web interface, it won't connect to the database as I receive this error: Error connecting to database.
Here are two screenshots from both files:
/etc/zabbix/zabbix_server.conf
/usr/share/zabbix/conf/zabbix.conf.php.example
Any help?
Thanks!

Can you access to a shell and connect to the zabbix database directly ?
In your configuration files, it seems that you use PostgreSQL.
It is written that you have to indicate the DBSchema variable if you use PostgreSQL.
However you didn't declare it.

In your case, the password should be in quotation marks: DBPassword="zabbix"

I faced the same problem. It is resolved by changing "Database host" from localhost to 127.0.0.1 in DB connection and changing the pg_hba.conf as below
host all all 127.0.0.1/32 password
Zabbix GUI

I have same problem with Centos+Postgre+Zabbix stack. And problem was with ident auth:
You need go to /var/lib/pgsql/data/pg_hba.conf (default path)
and change ident in this:
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
to md5
After this restart postgresql service and you can check connection by command:
psql -h localhost -U <your_zabbixdb_user> <your_zabbix_db>

Related

Unable to get through Postgres connection with ActiveRecord

For sake of Lord, I'm unable to understand why postgres is complaining about password authentication(using ActiveRecord).
sudo -u postgres psql rdb
This work (no password is asked)
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
But when connecting with an ORM like ActiveRecord it complains.
ActiveRecord::Base.establish_connection(adapter: 'postgresql', username: 'postgres', database: 'rdb')
The server requested password-based authentication, but no password was provided.
This a basic setup and I was expecting this to work all the time. My last resort would be to allow trust or md5(on pg_hba.conf) but before I move ahead with that can some please provide me with some pointer as to why the above did not work.
Just an update postgres is running at localhost
The sudo command is triggering the local all postgres peer restriction, not asking for a password. The ActiveRecord configuration with the postgresql adapter uses this:
:host - Defaults to a Unix-domain socket in /tmp. On machines without
Unix-domain sockets, the default is to connect to localhost.
Do you have working sockets on your machine? Is /tmp writeable? It might be the case that a TCP connection to 127.0.0.1 is used, triggering the password check as indicated by md5.

PG Restore function not working on localhost

I'm trying to restore a backup to my localhost machine to review the data - so that I can actually make sure the backup is working. I'm using Heroku, postgres, and rails.
I clean installed the app, so there is no data in the localhost database. I ran db:reset, and db:migrate.
Here is the string I'm trying to use for pg_restore:
pg_restore --verbose --clean --no-acl --no-owner -h localhost -p 3000 -U ian -d backup_production latest.dump
The error I receive says:
"connection to database "backup_production" failed: server closed the connection unexpectedly"
I've never had to do this before, so any help would be appreciated. I assume that development is what localhost uses (instead of test or production)?
I'm not sure what I'm missing, but I'll answer any question you may have.
Thanks a lot.
edit,. Here is a question, for this database string I assumed that I need to to use all the localhost information, because I created a backup using heroku capture/download. Am I wrong in that assumption? Should I instead be using the database name and port, etc, from the heroku credentials?
Turns out, I shouldn't have added the port. Removing -p 3000 , made this command work.
Try this
Edit the postgre configuration file typing in terminal
sudo gedit /etc/postgresql/POSTGRE_VERSION/main/pg_hba.conf
Then change your configuration to this
# Database administrative login by Unix domain socket
local all all trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Restart your postgre server
sudo /etc/init.d/postgresql restart
This should be the solution to access without password

host can not recognized in postgres

We have seen a issue in log
FATAL: lock file "/tmp/.s.PGSQL.5432.lock" already exists
HINT: Is another postmaster (PID 4696) using socket file "/tmp/.s.PGSQL.5432"?
LOG: could not bind IPv4 socket: Address already in use
We have deleted /tmp/.s.PGSQL.5432.lock
We restarted the postgres service the service restarted
But the psql -h localhost -d database -U newuser
shows error role 'newuser' does not exists
but if we connect without host
psql -d database -U newuser
It worked, How can We work with host options ?
Is there we ,missing somthing after deleting tmp file?
Same as the last one, you have two instances of PostgreSQL running on the machine.
You delete the socket file rather than shutting down the instance. This allows your second instance to start, but it's only listening on the unix socket. Presumably listen_addresses is unset/empty so it doesn't attempt to bind to a TCP/IP socket, since it'd fail if it tried and port 5432 was already in use.
The other instance is still running and still listening on port 5432 for TCP/IP connections. When you specify -h localhost you get a TCP/IP connection instead of the default unix socket connection, so you are connecting to the other instance of PostgreSQL on your system.
All your problems are caused by going around deleting and killing things rather than identifying the underlying problem - the second PostgreSQL instance - and addressing that.

create connection to localhost postgres server

I am creating a rails app and want to use postgresql. I have installed pgadmin, postgres sever on Ubuntu 14.04. I've tried creating a connection through pgAdmin but not able to create it. I am unable to configure pgadmin to create a connection to pg server.
I've tried editing the /etc/postgresql/9.3/main/pg_hba.conf file, but I get the following error:
FATAL: Peer authentication failed for user "postgres"
here is 'pg_hba.conf' file
Database administrative login by Unix domain socket
local all postgres peer
TYPE DATABASE USER ADDRESS METHOD
"local" is for Unix domain socket connections only
local all all peer
IPv4 local connections:
host all all 127.0.0.1/32 md5
IPv6 local connections:
host all all ::1/128 md5
Allow replication connections from localhost, by a user with the
replication privilege.
local replication postgres peer
host replication postgres 127.0.0.1/32 md5
host replication postgres ::1/128 md5
I would be grateful if someone could provide some help with configuration.
This is a VERY common error when you first install postgres, it defaults to using "postgres" as the user. You need to add your current user as a user in Postgres: Postgresql: password authentication failed for user "postgres"
First, you can reset the password for postgres:
sudo -u postgres psql
ALTER USER postgres PASSWORD 'newPassword';
But I would also/instead create a user for your current account (As a Superuser):
CREATE ROLE user_name WITH LOGIN SUPERUSER CREATEDB CREATEROLE REPLICATION;
Edit: The above command must be run from psql, so doing "sudo -u postgres psql" to access postgres is required either way.
Source: https://www.digitalocean.com/community/tutorials/how-to-use-roles-and-manage-grant-permissions-in-postgresql-on-a-vps--2
you can also try connecting through pgAdmin with the following configuration..

Postgres pg_hba.conf

There is server being set-up for one of my client, after installations of postgres when we run
the server we are encountering the error below. When I goggled for it there were a few solutions available but none worked for me, could you look into it and say what's happening.
Status: 500 Internal Server Error
FATAL: no pg_hba.conf entry for host "127.0.0.1", user "syr_admin", database "allprosh_production", SSL off
My pg_hba.conf file:
local all all md5
host samerole all 127.0.0.200 255.255.255.255 pam pamservice=postgresql_cpses
host samerole all 127.0.0.1 255.255.255.255 md5
local all postgres md5
host all postgres 127.0.0.1 255.255.255.255 md5
local all all trust
Thanks in Advance.
I figured it out myself, though it took a long time. The solution was simple, I just had to add an entry in the pg_hba.conf file for that particular user. This is what I did:
local all syr_admin md5
host all syr_admin 127.0.0.1 255.255.255.255 md5
Hope this helps others... :-)
I think that the just configuration is:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
If you want connect by other network use:
host all all network address/32 md5
use the two octet 192.159.0.0 for example
I reply here cause I can't comment your solution.
It is not mandatorry to add the entry to that specific user only. You can replace the option "samerole" with the database or all.
I'm seeing that 2 of the lines that you have are collisioning each other.
local all all md5
local all all trust
In this case, last line wins, so be careful to add unexpected behaviors on your access methods. If you want to ask the password for the universe on local, you must delete the last line.
Hope that this helps !
For the localhost authentification on PostgreSQL with the user postgres , your hba.conf must have this line :
# IPv6 local connections:
host all postgres ::1/128 trust
For to be sure, you can add this other line :
# IPv4 local connections:
host all postgres 127.0.0.1/32 trust
Note : You can change the method ao authentification from trust to md5 .

Resources