db query error: failed to connect to server - please inspect Grafana server log for details - sql-server

I'm new to Grafana and trying to connect Grafana to Microsoft SQL Server. I run both Grafana and SQL server on the same machine with Windows OS. In Grafana, I selected SQL Server data source and provided Host and DB name. I created a user in SQL server and granted reader permission to the user as per https://grafana.com/docs/grafana/latest/datasources/mssql/. Either for SQL server Authentication or Windows Authentication, I get the error db query error: failed to connect to server - please inspect Grafana server log for details.
I checked then Grafana log file: lvl=eror msg="query error" logger=tsdb.mssql err="Unable to open tcp connection with host 'servername:1433': dial tcp [2a02:908:1391:9e80:c180:xxxx:xxxx:xxxx]:1433: connectex: No connection could be made because the target machine actively refused it."
How can I force SQL server to give access to Grafana?
I should mention that, I haven't changed Grafana conf file. Do I need to change the default conf or create another conf file?
The default DB configuration in Grafana conf file is:
[database]
# You can configure the database connection by specifying type, host, name, user and password
# as separate properties or as on string using the url property.
# Either "mysql", "postgres" or "sqlite3", it's your choice
type = sqlite3
host = 127.0.0.1:3306
name = grafana
user = root
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password =
# Use either URL or the previous fields to configure the database
# Example: mysql://user:secret#host:port/database
url =
# Max idle conn setting default is 2
max_idle_conn = 2
# Max conn setting default is 0 (mean not set)
max_open_conn =
# Connection Max Lifetime default is 14400 (means 14400 seconds or 4 hours)
conn_max_lifetime = 14400
# Set to true to log the sql calls and execution times.
log_queries =
# For "postgres", use either "disable", "require" or "verify-full"
# For "mysql", use either "true", "false", or "skip-verify".
ssl_mode = disable
# Database drivers may support different transaction isolation levels.
# Currently, only "mysql" driver supports isolation levels.
# If the value is empty - driver's default isolation level is applied.
# For "mysql" use "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ" or "SERIALIZABLE".
isolation_level =
ca_cert_path =
client_key_path =
client_cert_path =
server_cert_name =
# For "sqlite3" only, path relative to data_path setting
path = grafana.db
# For "sqlite3" only. cache mode setting used for connecting to the database
cache_mode = private

The settings in Grafana's configuration file refer to its internal database so you do not need to change any of these to connect to MS SQL Server.
Try using "localhost" or "127.0.0.1" as the host name
Make sure authentication is SQL Server Authentication
Make sure Encrypt is false
Check the SQL server logs for any errors

Docker host using IP address of your machine follow below steps:
Open the CMD
IPCONFIG /ALL
Look for the IPV4 address under WiFi or
vEtherner; in my case, it's 192.168.1.24 and 172.45.202.1, respectively
Then try accessing the app hosted in the Docker container with the mapped port (e.g., 1433/5436)
It simply worked using 192.168.1.24:1433 and 172.45.202.1:1433 in the same way to access all container apps hosted using Docker

Related

Problem connecting with Listener server in High Availability

Recently I set up AG and server X is Primary and Server Y is secondary and Z is listener server. Ag is running fine. If I do RDP to Primary Server I can connect to Listener but Can't connect through Secondary server and from my local SSMS,I can't connect to listener at all.
We have Azure environment and I set up load balancer, Front end ip and health probe.
I checked all configurations are correct or not. There are no firewall issues.
compared with other listeners also.
can someone please help me, what I am missing..
I found the Solution.DNS was not able to communicate with Listener server.So need to run this powershell script and It worked.I am attaching link for reference.
$ClusterNetworkName = "<MyClusterNetworkName>" # the cluster network name (Use Get-ClusterNetwork on Windows Server 2012 of higher to find the name)
$IPResourceName = "<IPResourceName>" # the IP Address resource name
$ListenerILBIP = "<n.n.n.n>" # the IP Address of the Internal Load Balancer (ILB). This is the static IP address for the load balancer you configured in the Azure portal.
[int]$ListenerProbePort = <nnnnn>
Import-Module FailoverClusters
Get-ClusterResource $IPResourceName | Set-ClusterParameter -Multiple #{"Address"="$ListenerILBIP";"ProbePort"=$ListenerProbePort;"SubnetMask"="255.255.255.255";"Network"="$ClusterNetworkName";"EnableDhcp"=0}
enter link description here

PostgreSQL: could not connect to server - Connection refused error

I've failed to set up postgreSQL to work with my Ruby-on-Rails project for the past week. I've tried to uninstall and reinstall, postgreSQL, twice now.But when I try to launch postgreSQL I keep getting the error below:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?"
I've looked at many online resources, including stackoverflow and none seem helpful.The key parts of my pg_hba.conf file looks like this:
# TYPE DATABASE USER ADDRESS METHOD
# 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.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
And the key part of my postgresql.conf file is as follows:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
Most of the suggestions, I've seen so far, were based on those two files. (For my case, they were already configured correctly). I also tried disabling the firewall and restarting postgreSQL but it didn't help. Does anyone have any suggestions for me? Thanks!
Got the same issue while settings up PostgreSQL 9.6.16 to work with Python/Django, but this is purely a database issue.
The solution lies in the error: In fact, I found this error mentioned within the official PostgreSQL documentation thus it's a common error.
And here is how I resolved this issue:
Always first start the postgres database server, use postgres or the wrapper program pg_ctl.I used the command, below, on windows 10.Remember, whatever comes after -D should be the path to where you installed PostgreSQL, to the data folder, which holds the pg_hba.conf and postgresql.conf files.
> pg_ctl start -D "C:/Program Files/PostgreSQL/9.6/data"
If that runs well, you are ready to access the database server.Open another cmd shell, and type the command below.Remember the password you entered while installing PostgreSQL?Enter that password when asked Password for user postgres:
> psql -U postgres
Once done, you can now go ahead to CREATE ROLE and CREATE DATABASE accordingly.

enable JDBC connection to DB2 server database

I have a DB2 server setup ready (DB2 installed on a remote server that can be accessed via SSH).
Somewhere else I have an application. I would like that application to be able to connect to that DB2 database via jdbc.
The url looks like: jdbc:db2://xxxx.xxx.xxx.xxx:50000/mydb to which I add a user and password.
The command: db2 get db cfg for mydb | grep -i restrict returns Restrict access = NO
The details of the DB are
Database alias = MYDB
Database name = MYDB
Local database directory = /disk1
Database release level = 10.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
How can I connect to the database? I tried with root and other user but it fails.
The application returns:
Caused by: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][3.69.24] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: Reply.fill() - socketInputStream.read (-1). Message: Connection reset. ERRORCODE=-4499, SQLSTATE=08001

How to access Oracle database over network?

I am trying to accessing my Oracle database over Network. I have Google a lot and found many solutions, but those doesn't work for me.
The problem is that, I want to access my Oracle Database from One Computer to another Computer over my Local Network.
What I did is....
I found a Solution to modify listener.ora file with
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbp.devProject.com)(PORT=1521)))
When I modify this file and tried to run and access the Database nothing will happens, and it throws an Error, the port number you have specified is used by another listener, so i have changed port Number but I am not able to access Database.
2. I have configure a new listener with the help of oracle's tool Net Manager, which made a Listener for me, but it does not make accessible database over Network.
Here Some required results.
lsnrctl status : Listener using listener name LISTENER has already been started.
Connection String : jdbc:oracle:thin:#dbp.devProject.com:4541:myDB
Database Version :
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
status shows me this.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
Alias : LISTENER
Version : TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date : 14-MAY-2015 11:58:05
Uptime : 0 days 2 hr. 29 min. 50 sec
Trace Level : off
Security : ON: Local OS Authentication
SNMP : OFF
Listener Parameter File : product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File : \listener\alert\log.xml
Listening Endpoints Summary...
1. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
2. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Someone please Help me.
Thanks for your Help..
Whenever you encounter this kind of errors while creating remote access for you database, follow these steps beforehand.
Create a Listener using Net Manager tool of Oracle or create it Manually.
After generating Listener, check out "listener.ora"
[Located : ORACLE_INSTALLED_DIR\product\11.2.0\dbhome_1\NETWORK\ADMIN]
file, for your entry. (is there any Entry for the Listener which you have created just before. If you found your Entry than and than do next steps otherwise do it from FIRST step.)
If you found the Entry for your Listener, Open Command Prompt and fire command lsnrctl status. This will give you all currently running Listeners List, find out the one which you created just before.
Check out the Host Name and Port Number for your Listener.
Generate the Connection String as per the details you found in lsnrctl status
Connect with Database, and You can access the Database from anywhere in your Network.
If your host name and port number is listener then You could try this option by enabling port number in firewall settings.
Opening Ports in Windows Firewall
Open the Control Panel. ...
Open Windows Firewall. ...
Click the Advanced Settings link. ...
Select "Inbound Rules". ...
Create "New Rule" under "Inbound Rules". ...
Select "Port" from the first screen of the wizard. ...
Choose TCP or UDP. ...
Enter in the port range. ...
Finish the wizard.
Create an entry in TNSNAMES.ORA file on the system from which you are trying to connect to the database. (TNSNAMES.ORA is located in ORACLE_INSTALLATION_PATH/Network/Admin/ folder)
Sample entry:
DB_HOST_NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = DB_HOST_NAME)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
If you have more than one Oracle clients installed, you might need to update this in all those TNSNAMES.ORA

Connecting to Remote DB2 Database (JSP)

Let me preface this by saying I am completely new at this kind of thing. Anyways..
I am trying to connect to a DB2 Database.
The server is running Ubuntu 12.04 and Apache Tomcat 7. The driver db2jcc.jar is included in the build path.
Here is my JSP code:
<%# page import="java.sql.*" %>
<% Class.forName("com.ibm.db2.jcc.DB2Driver");%>
<HTML>
<HEAD>
<TITLE>db2 connection</TITLE>
</HEAD>
<BODY>
<%
String url =
"jdbc:db2://IP_ADDR:60000/INST1" +
":user=USERNAME;password=PASSWORD;" +
"traceLevel=" +
(com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL) + ";";
Connection con = java.sql.DriverManager.getConnection(url);
%>
</BODY>
</HTML>
The error message I am getting:
The application server rejected establishment of the connection.
An attempt was made to access a database, INST1, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
I checked out the IBM Support page on the issue here:
http://www-01.ibm.com/support/docview.wss?uid=swg21443723
It mentions using the target directory name, found by issuing the db2 list dcs directory command.
On the server, mine was initially blank, but I created an entry using the db2 catalog dcs database DB2INST1 as INST1 command.
Now my output for using db2 list dcs directory` is as follows:
Database Connection Services (DCS) Directory
Number of entries in the directory = 1
DCS 1 entry:
Local database name = DB2INST1
Target database name = INST1
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100
I reset the database by doing db2stop and db2start
Finally, I ran netstat -tulpn and saw the database was listening on port 60000. Output below:
tcp 0 0 0.0.0.0:60000 0.0.0.0:* LISTEN
2949/db2sysc
This is as far as I got. From what I can tell I am using the target database name and trying to connect to the correct port number.
Am I barking up the right tree here? Any help is greatly appreciated.
** Edit: Formatted answer to mustaccio's response **
On the server, I go down a level after I ssh on. I get 4 directories named <USERNAME>, dasusr1, db2fenc1, db2inst1
From there I did sudo su db2inst1 then ran the db2 list dcs directory command to get:
Database Connection Services (DCS) Directory
Number of entries in the directory = 1
DCS 1 entry:
Local database name = DB2INST1
Target database name = INST1
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100
It's been a while but for other people looking for a solution to this db2 connectivity problem. If people want to test physical connectivity of their development machine to the db2 server use CLPPlus that comes with the DB2 driver and manually put in the connection parameters to make sure you have physical connectivity. My environment is quite different than Garret's above but I want to offer one more clue that might help people connect. I was using VS 2015 enterprise with SSIS. I used CLPPlus to confirm physical connectivity then started trying to connect and ADO.Net source to db2. I had to override the port for my server credential db2server.mydomain.com:523 to override the port to 523. Then something funny happened. SSIS was fussing about the connection and I started looking at the parameters. One of the parameters was Authentication, which you could probably code in jdbc. I put in DB2 (as opposed to ldap or some other wallet) as the value for Authentication and it worked.

Resources