|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: Dealing with Database Instance connectivity issues |
| 4 | + description: Troubleshoot Database Instance connectivity issues for Managed Databases for MySQL and PostgreSQL. |
| 5 | +content: |
| 6 | + h1: Dealing with Database Instance connectivity issues |
| 7 | + paragraph: Troubleshoot Database Instance connectivity issues for Managed Databases for MySQL and PostgreSQL. |
| 8 | +tags: disk-full databases |
| 9 | +dates: |
| 10 | + validation: 2025-01-29 |
| 11 | + posted: 2025-01-29 |
| 12 | +categories: |
| 13 | + - managed-databases |
| 14 | + - postgresql-and-mysql |
| 15 | +--- |
| 16 | + |
| 17 | +## Public access |
| 18 | + |
| 19 | +### Problem |
| 20 | + |
| 21 | +I cannot connect to my Database Instance through the public network. |
| 22 | + |
| 23 | +### Possible causes |
| 24 | + |
| 25 | +- The Database Instance TLS certificate is outdated |
| 26 | +- Your allowed IPs are not properly configured |
| 27 | +- You have reached the maximum number of connections |
| 28 | +- You have a high memory usage |
| 29 | + |
| 30 | +### Solution |
| 31 | + |
| 32 | +You can check the following points to identify and act on what might be causing the issue: |
| 33 | + |
| 34 | +1. If TLS is enabled on the Database Instance, make sure the certificate is up-to-date, and that your client application is properly configured. |
| 35 | +2. Make sure your [ACLs](/managed-databases-for-postgresql-and-mysql/concepts/#allowed-ips) are [properly configured](/managed-databases-for-postgresql-and-mysql/how-to/manage-allowed-ip-addresses). |
| 36 | +3. Make sure your Database Instance does not reach the maximum number of connections stipulated in the advanced settings of the Database Instance. You can monitor the number of connections on [Cockpit](/managed-databases-for-postgresql-and-mysql/how-to/monitor-databases-cockpit). You can also [adjust the advances settings](/managed-databases-for-postgresql-and-mysql/how-to/configure-advanced-settings) to accept a higher number of connections. |
| 37 | +4. [Monitor other usage metrics on Cockpit](/managed-databases-for-postgresql-and-mysql/how-to/monitor-databases-cockpit) to: |
| 38 | + |
| 39 | + - Check if the memory usage is regular. High memory usage could trigger OOM Kills and cause disconnection |
| 40 | + - Check Database Instance logs and look for anything else that could explain the issue |
| 41 | + |
| 42 | +## Private access |
| 43 | + |
| 44 | +### Problem |
| 45 | + |
| 46 | +I cannot connect to my Database Instance through a Private Network. |
| 47 | + |
| 48 | +### Possible causes |
| 49 | + |
| 50 | +- The Database Instance TLS certificate is outdated |
| 51 | +- Your allowed IPs are not properly configured |
| 52 | +- You have reached the maximum number of connections |
| 53 | +- You have a high memory usage |
| 54 | + |
| 55 | +### Solution |
| 56 | + |
| 57 | +You can carry out the following actions: |
| 58 | + |
| 59 | +1. Check if you are you able to connect to the Database Instance from the public endpoint, if one is available. |
| 60 | +2. [Use Cockpit](/managed-databases-for-postgresql-and-mysql/how-to/monitor-databases-cockpit) to check database logs and look for any activity or behavior that could explain the issue. |
| 61 | +3. Create a support ticket if the first two steps do not help troubleshoot the issue. In the body of the ticket, make sure you provide: |
| 62 | + |
| 63 | + - The resource ID of resource from which the connection was attempted |
| 64 | + - The output of the `rdb_troubleshoot.sh` script, indicated below. Make sure you execute the script on the machine from which the connection was attempted. |
| 65 | + |
| 66 | +#### Database Instance connectivity check script |
| 67 | + |
| 68 | +`rdb_troubleshoot.sh`: |
| 69 | + |
| 70 | +```sh |
| 71 | +#!/bin/bash |
| 72 | + |
| 73 | +set -o nounset |
| 74 | + |
| 75 | +if [ -z "$INSTANCE_IP" ]; then |
| 76 | + echo "INSTANCE_IP is a mandatory environment variable." |
| 77 | + echo "e.g. export INSTANCE_IP=<xxx.xxx.xxx.xxx>" |
| 78 | + exit 1 |
| 79 | +fi |
| 80 | + |
| 81 | +if [ -z "$INSTANCE_PORT" ]; then |
| 82 | + echo "INSTANCE_PORT is a mandatory environment variable." |
| 83 | + echo "e.g. export INSTANCE_PORT=<xxxxx>" |
| 84 | + exit 1 |
| 85 | +fi |
| 86 | + |
| 87 | +function header() { |
| 88 | + echo -e "\n # ${1}" |
| 89 | + echo -e "---------------------------------\n" |
| 90 | +} |
| 91 | + |
| 92 | +echo -e "\nRDB troubleshooting script\nThis script will run for several minutes to get enough information." |
| 93 | +header "Host information" |
| 94 | +if ! [ -x "$(command -v uname)" ]; then |
| 95 | + echo 'Skipped: uname command is not availabe.' |
| 96 | +else |
| 97 | + uname -a |
| 98 | +fi |
| 99 | + |
| 100 | +header "Host connectivity check" |
| 101 | +if ! [ -x "$(command -v ping)" ]; then |
| 102 | + echo 'Skipped: ping command is not availabe.' |
| 103 | +else |
| 104 | + ping -c 5 ${INSTANCE_IP} |
| 105 | +fi |
| 106 | + |
| 107 | +header "Database connectivity check" |
| 108 | +if ! [ -x "$(command -v telnet)" ]; then |
| 109 | + # try to fallback on curl telnet |
| 110 | + if ! [ -x "$(command -v curl)" ]; then |
| 111 | + echo "Skipped: neither telnet nor curl command are availabe." |
| 112 | + else |
| 113 | + echo "(using curl)" |
| 114 | + timeout 2 curl -v telnet://$INSTANCE_IP:$INSTANCE_PORT |
| 115 | + fi |
| 116 | +else |
| 117 | + echo "(using telnet)" |
| 118 | + echo -n | telnet ${INSTANCE_IP} ${INSTANCE_PORT} |
| 119 | +fi |
| 120 | + |
| 121 | +header "Ip configuration check" |
| 122 | +if ! [ -x "$(command -v ip)" ]; then |
| 123 | + echo 'Skipped: ip command is not availabe.' |
| 124 | +else |
| 125 | + echo -e "Interfaces:\n- \n" |
| 126 | + ip a |
| 127 | + echo -e "\nNeighbour:\n- \n" |
| 128 | + |
| 129 | + TEST_ITERATION=30 |
| 130 | + TEST_INTERVAL=10 # seconds |
| 131 | + |
| 132 | + # Iterate a few times to try to catch relevant info |
| 133 | + for ((i=1;i<=$TEST_ITERATION;i++)); do |
| 134 | + echo -e "\nIteration $i:\n" |
| 135 | + ip neighbour show |
| 136 | + echo -e "\nWaiting ${TEST_INTERVAL}s...\n" |
| 137 | + sleep $TEST_INTERVAL |
| 138 | + done |
| 139 | + echo -e "\nRoute:\n-\n" |
| 140 | + ip route |
| 141 | +fi |
| 142 | +``` |
| 143 | +Run the script in a terminal: |
| 144 | + |
| 145 | +``` |
| 146 | +export INSTANCE_IP=<xxx.xxx.xxx.xxx> |
| 147 | +export INSTANCE_PORT=<xxxxx> |
| 148 | +./troubleshoot.sh |
| 149 | +``` |
0 commit comments