I installed Centos 7, 64 bit. Installed postgresql-9.4.
Initialized postgresql with command
/usr/pgsql-9.4/bin/postgresql94-setup initdb
then used this command to start postgresql
systemctl start postgresql-9.4
and showed error like this:
service failed because the control process exited with error code. See "systemctl status postgresql-9.4.service" and "journalctl -xe" for details.
entered command
systemctl status postgresql-9.4.service
● postgresql-9.4.service - PostgreSQL 9.4 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-03-02 18:09:27 CST; 1min 59s ago
Process: 31266 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)
Process: 31261 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >LOG: could not bind IPv6 socket: Address already in use
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >HINT: Is another postmaster already running on...retry.
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >LOG: could not bind IPv4 socket: Address already in use
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >HINT: Is another postmaster already running on...retry.
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >WARNING: could not create listen socket for "localhost"
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >FATAL: could not create any TCP/IP sockets
Mar 02 18:09:27 localhost.localdomain systemd[1]: postgresql-9.4.service: control process exited, code=exited status=1
Mar 02 18:09:27 localhost.localdomain systemd[1]: Failed to start PostgreSQL 9.4 database server.
Mar 02 18:09:27 localhost.localdomain systemd[1]: Unit postgresql-9.4.service entered failed state.
Mar 02 18:09:27 localhost.localdomain systemd[1]: postgresql-9.4.service failed.
1 - install psmisc package to give a killall on Postgres
# yum install psmisc
2 - Run the kill
# killall -9 postgres
3 - Start / Stop
# systemctl stop postgresql- 9.4
# systemctl start postgresql- 9.4
4 - to check if the service is in execution,
# ps -aux | grep postgres
Related
I was deploying my Django project on fedora 33 nginx server. But domain and localhost tell me 502 bad gateway. I made diagnostic and learned that:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2021-01-08 01:34:08 +04; 1min 17s ago
Process: 4348 ExecStart=/home/robot/venv/bin/gunicorn --workers 3
--bind unix:/home/robot/plagiat/plagiat.sock plagiat.wsgi:application (code=exited, status=203/EXEC)
Main PID: 4348 (code=exited, status=203/EXEC) CPU: 5ms
Jan 08 01:34:10 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:10 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:10 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:10 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:11 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:11 baku systemd[1]: Failed to start gunicorn daemon.
I'm trying a deploy simple Django application on Digital Ocean by following this [link][1] I follow every work step by step and successfully run that project via python manage.py runserver where it's not throwing any error but when I try to implement it with gunicorn its throw following error
gunicorn.service: Failed with result 'exit-code'.
Here is my following configuration:
sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=pos
Group=www-data
WorkingDirectory=/home/pos/pos
ExecStart=/home/pos/env/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
pos.wsgi:application
[Install]
WantedBy=multi-user.target
sudo systemctl status gunicorn.socket
● gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: active (listening) since Tue 2019-11-26 07:39:39 UTC; 12min ago
Listen: /run/gunicorn.sock (Stream)
CGroup: /system.slice/gunicorn.socket
Nov 26 07:39:39 POS systemd[1]: Listening on gunicorn socket.
When I try to start gunicorn it's throwing this error
sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-11-26 07:39:43 UTC; 13min ago
Process: 718 ExecStart=/home/pos/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock pos.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 718 (code=exited, status=1/FAILURE)
Nov 26 07:39:43 POS gunicorn[718]: Arbiter(self).run()
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 198, in run
Nov 26 07:39:43 POS gunicorn[718]: self.start()
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 155, in start
Nov 26 07:39:43 POS gunicorn[718]: self.LISTENERS = sock.create_sockets(self.cfg, self.log, fds)
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/sock.py", line 172, in create_sockets
Nov 26 07:39:43 POS gunicorn[718]: sock_name = sock.getsockname()
Nov 26 07:39:43 POS gunicorn[718]: OSError: getsockaddrlen: bad family
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Anyone helps me to solve this issue?
[1]: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
The latest version of gunicorn (20.0.3) can cause this problem.
Try installing an older version of gunicorn:
pip install gunicorn==20.0.2
It seems that you are trying to listen to unix:/run/gunicorn.sock in ExecStart, but the socket is at run/gunicorn.socket. Try changing this and run systemctl daemon-reload to see if it makes a difference.
I changed the postgres data directory following these steps:
systemctl stop postgresql-11.service
cp -r /var/lib/pgsql/11/data /home/eshel/pgsql-11/
chown -R postgres:postgres /home/eshel/pgsql-11/
chmod 700 /home/eshel/pgsql-11/
vi /usr/lib/systemd/system/postgresql-11.service
Environment=PGDATA=/home/eshel/pgsql-11/data/
systemctl daemon-reload
systemctl start postgresql-11.service
So far, the postgres-11 is normal.
After I changed the new data_directory's postgres.conf.
1. vim pgsql-11/data/postgresql.conf
data_directory = '/home/eshel/pgsql-11/data'
I can't start postgres-11. I don't know how to handle this.
The error follows:
[root#localhost 11]# systemctl start postgresql-11.service
* Job for postgresql-11.service failed because the control process exited with error code. See "systemctl status postgresql-11.service" and "journalctl -xe" for details.
[root#localhost 11]# systemctl status postgresql-11.service
● postgresql-11.service - PostgreSQL 11 database server
* Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled; vendor preset: disabled)
* Active: failed (Result: exit-code) since Fri 2019-10-11 23:05:00 CST; 27s ago
* Docs: https://www.postgresql.org/docs/11/static/
* Process: 12758 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
* Main PID: 11582 (code=exited, status=0/SUCCESS)
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
[root#localhost 11]# journalctl -xe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Activating service name='org.freedesktop.problems' (using servicehe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Successfully activated service 'org.freedesktop.problems'
* Oct 11 23:04:51 localhost.localdomain nautilus-deskto[9318]: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simpl
* Oct 11 23:05:00 localhost.localdomain polkitd[6478]: Registered Authentication Agent for unix-process:12752:1022414 (system bu
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* -- Subject: Unit postgresql-11.service has begun start-up
* -- Defined-By: systemd
* -- Unit postgresql-11.service has begun starting up.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: "/home/eshel/pgsql-11/data/" is missing or empty.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: Use "/usr/pgsql-11/bin/postgresql-11-setup initdb" to
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: See /usr/share/doc/postgresql11-11.4/README.rpm-dist
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* -- Subject: Unit postgresql-11.service has failed
* -- Defined-By: systemd
* -- Unit postgresql-11.service has failed.
* -- The result is failed.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
Process: 10839 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
The postgres can't read the PGDATA direcotry.With the help of someone else, We solved this by following:
Before modification:
drwx------. 19 eshel eshel 4096 Oct 12 21:00 eshel
After modification:
[root#localhost eshel]# chmod 755 ../eshel/
[root#localhost eshel]# ll ../
drwxr-xr-x. 19 eshel eshel 4096 Oct 12 21:00 eshel
Then I start postgres11, and it's OK!
systemctl start postgresql-11
I am trying to setup a Flask App on DigitalOcean but I'm facing the same error each time I run the below commands, I tried everything mentioned online but it didn't work
$ sudo systemctl start testflask
$ sudo systemctl enable testflask
$ sudo systemctl status testflask
That's the error I'm getting when running the command
● testflask.service - uWSGI instance to serve testflask
Loaded: loaded (/etc/systemd/system/testflask.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2018-11-09 14:47:04 UTC; 126ms ago
Main PID: 30495 (code=exited, status=203/EXEC)
Nov 09 14:47:04 aipi systemd[1]: Started uWSGI instance to serve testflask.
Nov 09 14:47:04 aipi systemd[1]: testflask.service: Main process exited, code=exited, status=203/EXEC
Nov 09 14:47:04 aipi systemd[1]: testflask.service: Unit entered failed state.
Nov 09 14:47:04 aipi systemd[1]: testflask.service: Failed with result 'exit-code'.
testflask.service file
[Unit]
Description=uWSGI instance to serve testflask
After=network.target
[Service]
User=alexy
Group=www-data
WorkingDirectory=/home/alexy/testflask
Environment="PATH=/home/alexy/testflask/venv/bin"
ExecStart=/home/alexy/testflask/venv/bin/uwsgi --log-level debug --ini uwsgi.ini
[Install]
WantedBy=multi-user.target
uwsgi.ini inside /home/alexy/testflask/
[uwsgi]
http-socket = :$(PORT)
socket = wsgi.sock
chmod-socket = 660
vacuum = true
processes = 5
master = true
die-on-term = true
module = wsgi:app
memory-report = true
wsgi-disable-file-wrapper = true
Thank you for your help
Can someone check what's wrong with this configuration?
AWS info:
EC2: Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-45-generic x86_64)
Security Group:
HTTP TCP 80 0.0.0.0/0
SSH TCP 22 0.0.0.0/0
ubuntu#ip-172-31-58-168:~$ tor --version
Tor version 0.2.8.9 (git-cabd4ef300c6b3d6).
ubuntu#ip-172-31-58-168:~$ nginx -v
nginx version: nginx/1.10.2
ubuntu#ip-172-31-58-168:~$ sudo service tor status
● tor.service - Anonymizing overlay network for TCP (multi-instance-master)
Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2016-10-20 10:03:51 ART; 1h 2min ago
Process: 667 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 667 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/tor.service
Oct 20 10:03:50 ip-172-31-58-168 systemd[1]: Starting Anonymizing overlay network for TCP (multi-instance-master)...
Oct 20 10:03:51 ip-172-31-58-168 systemd[1]: Started Anonymizing overlay network for TCP (multi-instance-master).
ubuntu#ip-172-31-58-168:~$ sudo service nginx status
● nginx.service - LSB: Stop/start nginx
Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
Active: active (running) since Thu 2016-10-20 10:04:23 ART; 1h 2min ago
Docs: man:systemd-sysv-generator(8)
Process: 1284 ExecStart=/etc/init.d/nginx start (code=exited, status=0/SUCCESS)
Tasks: 2
Memory: 2.6M
CPU: 14ms
CGroup: /system.slice/nginx.service
├─1332 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
└─1333 nginx: worker process
Oct 20 10:04:23 ip-172-31-58-168 systemd[1]: Starting LSB: Stop/start nginx...
Oct 20 10:04:23 ip-172-31-58-168 systemd[1]: Started LSB: Stop/start nginx.
torrc (Tor configuration file)
ubuntu#ip-172-31-58-168:~$ cat /etc/tor/torrc
HiddenServiceDir /var/lib/tor/sitio1
HiddenServicePort 80 127.0.0.1:81
hostname and private_key files:
root#ip-172-31-58-168:/home/ubuntu# cat /var/lib/tor/sitio1/hostname
zptym3k5xi2dyngl.onion
root#ip-172-31-58-168:/home/ubuntu# cat /var/lib/tor/sitio1/private_key
-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQDPVfcNF7uaBTqgLZqfr9zOQKCXF4g5FsMFa+u8I46d4/UAgODD
w+DxpUf/wPM7ibSLPuuVU/WTq2+fMu8QXTX+AuMboca0REeSuxb+NUOQxpEBxKHy
vqKB6emRA3D6X1e2X1i2f/dC2kqa/8nkuTOw+nUJthGYHHlN5xlAyVl72QIDAQAB
AoGARIzDlcyW9iFsdLEfQlS+yGKNtebN3zIrYIuB8T5AVOudgYEazx7gLITc/S4q
PlalalallalalalalalalalalalalalalalalalalaxTsb3lKt1EAyF049lX9MKj
qPDLOyAFFW9SQq/HCe5stnQl1zLfRIbbhTX6esArvLnv7VECQQD9PsT8AnVvh9J4
ybzJr5M2KZxy90rGmeWCZLB0l3UHxX2AKOIWC9qekeAURqHRN9Ys9iWY4TgEQunN
vRK+4YM3AkEA0ZdZKsx/s1DDaaieSn4h7zez7bpXYCTnSGzYTelPaiRMrpo9Lmyu
3GFsW9zOWzJmHNxsSczxQWDeLx3t/FShbwJARtppApktgibeHC1VRJh694xs2T2X
DjnAnNrPA8/cTnBSzKijmMd4QyVNLF8Wpxputoelqueleeat84IS3JT7wQJAEICC
HMSNKWkqeZ81F1hnA5a3K/iH+KHvM9yeC0RbZFgHUZgDSSx1eBSTm4f/F18Yex0/
yW/BbwxZcgxBOKTRholaZHM2UZ3TG6DfdYxY/Pur9/rlbXMGhx1RJnbdWFkC1CnW
9D9i6oto0iWHS9c46o3phYDceWC9/tuh04NboXBsKg==
-----END RSA PRIVATE KEY-----
nginx site configuration file
root#ip-172-31-58-168:/home/ubuntu# cat /etc/nginx/conf.d/sitio1.onion
server {
listen 81;
server_name zptym3k5xi2dyngl.onion;
root /directorio/carpeta/sitio1;
index index.php index.html index.htm;
access_log /directorio/de/los/logs/hidden-access.log;
error_log /directorio/de/los/logs/hidden-error.log;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Finally, syslog and tor log
root#ip-172-31-58-168:/home/ubuntu# cat /var/log/syslog
Oct 20 10:04:21 ip-172-31-58-168 systemd[1]: Starting Anonymizing overlay network for TCP...
Oct 20 10:04:22 ip-172-31-58-168 tor[1162]: Oct 20 10:04:22.078 [notice] Tor v0.2.8.9 (git-cabd4ef300c6b3d6) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.2g and Zlib 1.2.8.
Oct 20 10:04:22 ip-172-31-58-168 tor[1162]: Oct 20 10:04:22.079 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Oct 20 10:04:22 ip-172-31-58-168 tor[1162]: Oct 20 10:04:22.080 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
Oct 20 10:04:22 ip-172-31-58-168 tor[1162]: Oct 20 10:04:22.080 [notice] Read configuration file "/etc/tor/torrc".
Oct 20 10:04:22 ip-172-31-58-168 tor[1162]: Configuration was valid
Oct 20 10:04:22 ip-172-31-58-168 tor[1168]: Oct 20 10:04:22.215 [notice] Tor v0.2.8.9 (git-cabd4ef300c6b3d6) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.2g and Zlib 1.2.8.
Oct 20 10:04:22 ip-172-31-58-168 tor[1168]: Oct 20 10:04:22.229 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Oct 20 10:04:22 ip-172-31-58-168 tor[1168]: Oct 20 10:04:22.229 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
Oct 20 10:04:22 ip-172-31-58-168 tor[1168]: Oct 20 10:04:22.229 [notice] Read configuration file "/etc/tor/torrc".
Oct 20 10:04:22 ip-172-31-58-168 tor[1168]: Oct 20 10:04:22.241 [notice] Opening Socks listener on 127.0.0.1:9050
Oct 20 10:04:22 ip-172-31-58-168 systemd[1]: Started Anonymizing overlay network for TCP.
root#ip-172-31-58-168:/home/ubuntu# cat /var/log/tor/log
Oct 20 10:04:22.000 [notice] Tor 0.2.8.9 (git-cabd4ef300c6b3d6) opening log file.
Oct 20 10:04:22.215 [notice] Tor v0.2.8.9 (git-cabd4ef300c6b3d6) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.2g and Zlib 1.2.8.
Oct 20 10:04:22.229 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Oct 20 10:04:22.229 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
Oct 20 10:04:22.229 [notice] Read configuration file "/etc/tor/torrc".
Oct 20 10:04:22.241 [notice] Opening Socks listener on 127.0.0.1:9050
Oct 20 10:04:22.000 [notice] Parsing GEOIP IPv4 file /usr/share/tor/geoip.
Oct 20 10:04:22.000 [notice] Parsing GEOIP IPv6 file /usr/share/tor/geoip6.
Oct 20 10:04:22.000 [notice] Bootstrapped 0%: Starting
Oct 20 10:04:22.000 [notice] Bootstrapped 80%: Connecting to the Tor network
Oct 20 10:04:22.000 [notice] Signaled readiness to systemd
Oct 20 10:04:23.000 [notice] Opening Socks listener on /var/run/tor/socks
Oct 20 10:04:23.000 [notice] Opening Control listener on /var/run/tor/control
Oct 20 10:04:24.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
Oct 20 10:04:24.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
Oct 20 10:04:24.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
Oct 20 10:04:24.000 [notice] Bootstrapped 100%: Done
Traffic gets to my hidden service but "Unable to connect"
arm - screenshot
This exact configuration works on a server at my home.