tunnel-bastion-client service cannot start - postgresql

I am trying to establish tunnel bastion connection between two ec2 instance. The client side is allowing Lambda to reach server side RDS. I checked the client side ec2 and find the service tunnel-bastion-client cannot start.
Aug 17 23:07:49 ip-172-31-25-38 systemd[1]: tunnel-bastion-client.service: Scheduled restart job, restart counter is>
Aug 17 23:07:49 ip-172-31-25-38 systemd[1]: Stopped Maintain connection with tunnel bastion.
Aug 17 23:07:49 ip-172-31-25-38 systemd[1]: Started Maintain connection with tunnel bastion.
Aug 17 23:07:50 ip-172-31-25-38 ssh[186032]: Host key verification failed.
Aug 17 23:07:50 ip-172-31-25-38 systemd[1]: tunnel-bastion-client.service: Main process exited, code=exited, status=>
Aug 17 23:07:50 ip-172-31-25-38 systemd[1]: tunnel-bastion-client.service: Failed with result 'exit-code'
For some reason, the tunnel-bastion-client service cannot be started manually. I can connect RDS from server side ec2. So, it is not the database issue.
# psql -h xxxx-xxxx-xxxxxxx.xxxxxxxxxxxxx.us-west-1.rds.amazonaws.com -p 5432 postgres
Password:
psql (10.18 (Ubuntu 10.18-0ubuntu0.18.04.1), server 11.9)
WARNING: psql major version 10, server major version 11.
Some psql features might not work.
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=>
I used the terraform to standup the both ec2 and grabbing from parameter store. Please help me find out where exactly is the issue. Appreciate in advance.

work around, execute "ExecStart" line from /etc/systemd/system/tunnel-bastion-client.service file.

Related

What is NGINX Expecting To See Here?

I've been working on trying to integrate onlyoffice with my working nextcloud app. I've attempted this many times and in many different ways. I believe I understand "most" of the mistakes I've made previously...but there always seems to be one more.
Nextcloud is running on a Ubuntu 22.04 VM. I have another VM operating nginx reverse proxy for this and the other apps I want to expose to the outside. I've decided on this attempt to also run onlyoffice on the nextcloud server but using different ports from that app.
Using the modified template suggested for SSL enabled nginx, when I attempt to start the service, I get:
bonzo#cloud:/etc/nginx/conf.d$ systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-08-05 15:12:02 CDT; 8s ago
Docs: man:nginx(8)
Process: 7990 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 26ms
Aug 05 15:12:02 cloud systemd[1]: Starting A high performance web server and a reverse proxy
server...
Aug 05 15:12:02 cloud nginx[7990]: nginx: [emerg] host not found in upstream "docservice" in
/etc/nginx/includes/ds-docservice.conf:74
Aug 05 15:12:02 cloud nginx[7990]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 05 15:12:02 cloud systemd[1]: nginx.service: Control process exited, code=exited,
status=1/FAILURE
Aug 05 15:12:02 cloud systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 05 15:12:02 cloud systemd[1]: Failed to start A high performance web server and a reverse
proxy server.*
When I looked at the line 74 in ds-docservice.conf, it shows this:
location / {
proxy_pass http://docservice;
}
And, I'm not exactly sure what it is expecting to see there. I haven't included it in this first post but I'd be happy to share my ds.conf or any other logs/configs that would be required for help with this. I also realize this is probably going to be something silly that I've missed or messed up, I'm still new to nginx and integrating onlyoffice has been a lot more difficult than you'd think, from the literature and yt vids I've seen!
Thanks for any help

When i am trying to register pemagent in anotherhost using pemworker command iam getting error like No route to host

[root#localhost bin]# ./pemworker --register-agent --pem-server 192.168.254.199 --pem-port 5432 --pem-user postgres --display-name MasterAgent --allow_server_restart true --allow-batch-probes true --enable-smtp true
Wed Jun 1 23:21:55 2022 WARNING: ConnectToPEM: unable to connect to PEM database: connection to server at "192.168.254.199", port 5432 failed: No route to host
Is the server running on that host and accepting TCP/IP connections?
Wed Jun 1 23:21:55 2022 ERROR: Unable to connect to Postgres Enterprise Manager Server

Postgresql "Cluster is not running" after running for a while

I set up a postgresql db on azure VM, Ubuntu server 18.04.
but it goes down after running for a while without any other error message.
Here is what I got from sudo systemctl status postgresql#10-main.service
Feb 18 08:08:52 server crontab[17689]: (postgres) LIST (postgres)
Feb 18 08:08:52 server crontab[17692]: (postgres) LIST (postgres)
Feb 18 08:08:52 server crontab[17695]: (postgres) LIST (postgres)
Feb 18 08:08:52 server crontab[17697]: (postgres) REPLACE (postgres)
Feb 18 08:08:52 server crontab[17698]: (postgres) LIST (postgres)
Feb 18 08:08:52 server crontab[17700]: (postgres) REPLACE (postgres)
Feb 18 08:08:52 server crontab[17701]: (postgres) LIST (postgres)
Feb 18 08:08:53 server postgresql#10-main[17704]: Cluster is not running.
Feb 18 08:08:53 server systemd[1]: postgresql#10-main.service: Control process exited, code=exited status=2
Feb 18 08:08:53 server systemd[1]: postgresql#10-main.service: Failed with result 'exit-code'.
sudo systemctl restart postgresql.service may temporarily resolve this problem, but may reoccur after a while.
Does anyone face the same issue?
Any advice?
Thank you.
In my case, postgresql was killed by the oom killer.

PG::ConnectionBad Postgres Cluster down

Digitalocean disabled my droplet's internet access. After fixing the error (rollback to older backup) they restored the internet access. But afterwards I constantly get an error when deploying, I can't seem to get my Postgres database up and running.
I'm getting an error each time I try to deploy my application.
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
So I used SSH to login to my server and check if my Postgres was actually running with:
pg_lsclusters
Results into:
Ver Cluster Port Status Owner Data directory Log file
9.5 main 5432 down postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Postgres server status
So my Postgres server seems to be down. I tried putting it 'up' again with:
pg_ctlcluster 9.5 main start After doing so I got the error: Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 403.
And /usr/bin/pg_ctlcluster on line 403 says:
system 'systemctl', 'is-active', '-q', "postgresql\#$version-$cluster";
But I'm not to sure what the problem could be here and how I could fix this.
Update
I also tried updating the permissions on /bin to 755 as mentioned here. Sadly that did not fix my problem.
Update 2
I changed the /usr/bin to 755. Now when I try pg_ctlcluster 9.5 main start, I get this:
Job for postgresql#9.5-main.service failed because the control process exited with error code. See "systemctl status postgresql#9.5-main.service" and "journalctl -xe" for details.
And inside the systemctl status postgresql#9.5-main.service:
postgresql#9.5-main.service - PostgreSQL Cluster 9.5-main
Loaded: loaded (/lib/systemd/system/postgresql#.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-01-28 17:32:38 EST; 45s ago
Process: 22473 ExecStart=postgresql#%i --skip-systemctl-redirect %i start (code=exited, status=1/FAILURE)
Jan 28 17:32:08 *url* systemd[1]: Starting PostgreSQL Cluster 9.5-main...
Jan 28 17:32:38 *url* postgresql#9.5-main[22473]: The PostgreSQL server failed to start.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Control process exited, code=exited status=1
Jan 28 17:32:38 *url* systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Unit entered failed state.
Jan 28 17:32:38 *url* systemd[1]: postgresql#9.5-main.service: Failed with result 'exit-code'.
Thanks!
You better not mix systemctl and pg_ctlcluster. Let systemctl makes the calls to pg_ctlcluster with the right user and permissions. You should start your postgresql instance with
sudo systemctl start postgresql#9.5-main.service
Also, check the errors in the startup log. You can post them too, to help you figure out what's going on.
Your systemctl status also outputs that the service is disable, so, when the server reboots, you will have to start the service manually. To enable it run:
sudo systemctl enable postgresql#9.5-main.service
I hope it helps
It is mainly because /etc/hosts file is somehow changed.I have removed extra space inside /etc/hosts file.Use cat /etc/hosts
Add these lines into the file
127.0.0.1 localhost
127.0.1.1 your-host-name
::1 ip6-localhost ip6-loopback
And I have given permission 644 to /etc/hosts file.It is working for me even after the reboot of the system.

Restart PostgreSQL without postgresql-server

I'm on CentOS 7 and I'm trying to get through the 'PG::ConnectionBad: FATAL: Peer authentication failed for user' error.
So I've already figured out that I should change pg_hba.conf (peer to md5) and I've done it. It seems that I have to restart postgres but it is not so easy as I thought.
I tried 'service postgresql restart' which resulted in 'Failed to restart postgresql.service: Unit not found.'
Then tried to install posgresql-server. Got:
oct 23 01:16:15 serverct1 pg_ctl[3280]: HINT: Is another postmaster already running on port 5432? If ...try.
oct 23 01:16:15 serverct1 pg_ctl[3280]: WARNING: could not create listen socket for "localhost"
oct 23 01:16:15 serverct1 pg_ctl[3280]: FATAL: could not create any TCP/IP sockets
oct 23 01:16:16 serverct1 pg_ctl[3280]: pg_ctl: could not start server
oct 23 01:16:16 serverct1 systemd[1]: postgresql.service: control process exited, code=exited status=1
oct 23 01:16:16 serverct1 systemd[1]: Failed to start PostgreSQL database server.
About 5432 port usage:
postgres 5432/tcp postgresql # POSTGRES
postgres 5432/udp postgresql # POSTGRES
So I'm curious:
1) Do postgresql and postgresql-server work separately?
2) Is it possible to restart posgresql without postgresql-server?
3) If not - how to get the port 5432 free in order to run postgresql-server?
You can avoid troubles with serverct1 if you use standard postgres pg_ctl, eg:
pg_ctl reload
Or if needed pg_ctl reload -D $PGDATA
You dont need to restart the postgres for pg_hba changes to apply: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
The pg_hba.conf file is read on start-up and when the main server
process receives a SIGHUP signal. If you edit the file on an active
system, you will need to signal the postmaster (using pg_ctl reload or
kill -HUP) to make it re-read the file.