Problem connecting with Listener server in High Availability - sql-server

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

Related

Direct database connection on Oracle Cloud Infrastructure (OCI)

I got a free Oracle Cloud Infrastructure (OCI) service from Oracle for two months.
I would like to create an Oracle database and connect to it directly over the internet (I don't want to create a VPN tunnel).
Do you know how I should do it?
One way to do it, use this URL pattern:
jdbc:oracle:thin:/#OCI_DB_NAME_high?TNS_ADMIN=PATH_TO_THE_WALLET_FOLDER
user name and password as usual, the Wallet should be unzipped.
Properties info = new Properties();
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);
...
OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);
ods.setConnectionProperties(info);
OracleConnection connection = (OracleConnection) ods.getConnection();
I solved the problem myself.
To get to the database server without configuring a VPN link, you can create a virtual machine accessible via an external IP address and ssh from it to a local address from the 10.0.0.0 network
Here is the Spring Boot sample to connect to OCI managed autonomous database.
https://github.com/oracle-devrel/oci-sdk-java-samples/tree/main/usecases/connect-autonomous-database

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

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

Unable to connect to Azure Function App after integrating into VNET

Problem Outline
Azure Function App can not be accessed once it is integrated into a VNET and WEBSITE_VNET_ROUTE_ALL is set to 1.
This is required so that the Function App can securely connect to SQL without making the SQL publicly available.
Errors:
Unable to list Function App keys.
HTTP Request (CURL) from within VM in same network fails: 504 Gateway Timed out
Architectural Diagram
Steps to reproduce
Create a Resource Group
Create a VNET with 10.20.11.0/26 address space
Create a Subnet for the Function App to integrate into with address
range of 10.20.11.0/27
Create a Linux Function App and integrated in the VNET you created
in step 2.
See that App keys still loads as normal.
Create a Subnet for the database with address range of
10.20.11.32/27
Create SQL Server and SQL Database.
Create a Private Link with DNS Zone on the Database and restrict
public access.
Link DNS Zone to VNET created in step 2.
Function app resolved SQL private link as public IP address.
In the Function App configuration, add an Application setting
WEBSITE_VNET_ROUTE_ALL and set it to 1.
See that Function app now resolves SQL private link as private IP
address
See that Function App keys are not loading.
Attempt to connect to Azure Functions though a connection from the
network or from public link.
See that Function app gateway times out.
Through an SSH connection into the Function App and with nslookup we determined that the connection to the private link resolves the local IP address of the SQL database as expected.
Setting the WEBSITE_VNET_ROUTE_ALL flag to 0, nslookup resolves the public IP of the SQL database.
As the SQL database is restricted and only available on the network, it is vital that the WEBSITE_VNET_ROUTE_ALL setting is set to 1.
WEBSITE_VNET_ROUTE_ALL = 1
WEBSITE_VNET_ROUTE_ALL = 0
References
https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet
This was resolved by adding a "Microsoft.Storage" service endpoint to the Function App subnet.
When all of the traffic is sent into the vnet, it needs a service endpoint to Storage so that it can read the Function App configuration and functions.
Navigate to your Virtual Network resource
In the side menu, under Settings, select "Service endpoints"
Click on "Add"
Select "Microsoft.Storage" from the Service dropdown
Add policies if needed (I did not select any policies here)
Associate the Function App subnet
Add.

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

How to connect to database on NAS from Vagrant-box

I am currently developing a website with a virtual server based on Vagrant. Before that I always used my NAS-webserver to develop my sites.
I want to keep using my database on the NAS cause it's easy to handle through phpMyAdmin that is installed as an app on the NAS.
When ssh'ed into my virtualbox I can ping to the internal ip from my NAS, being 192.168.0.10. Making a database connection to it, does not work.
Usually I take static ip for my VirtualBox that does not belong to the range of my internal network, e.g. 192.168.33.23. I tried to change this to an ip that is in the range but then I get an error saying:
The specified host network collides with a non-hostonly network!
The specified host network collides with a non-hostonly network!
This will cause your specified IP to be inaccessible. Please change
the IP or name of your host only network so that it no longer matches that of a bridged or non-hostonly network.
What is the best method to solve this issue? I read the Vagrant Docs and other posts but I didn't get it up and running.
** UPDATE **
I added this line to my Vagrantfile:
config.vm.network 'public_network'
This invokes a bridged mode. After choosing 'en0: Wi-Fi (Airport)' as adapter when starting the VM, the ip of my VM is now 192.168.0.100 but I still can't connect to my database #192.168.0.10.
I already did a credential check by placing all files on the NAS-webserver and all worked well.
Solution:
set the network to bridged mode
grant the VM ip address access in the mysql users table
So I just added the same user in phpMyAdmin but now with the VM ip address as hostname.

Resources