Celery periodic tasks getting picked up too many times - celery

I'm running Celery 3.0.24, and Celery-with-redis 3.0 in an app that uses periodic tasks to poll a json feed, and automate tasks based on it.
Celery is correctly putting out that a due task is occurring every 1 minute. However, it appears that the task is being picked up 2-3 times, which is resulting in duplicate and triplicate runs of the app behind it.
The problem typically doesn't occur for a day or a week, but then begins, and won't go away despite stopping and restarting the app.
Details:
Running it with Supervisor
Queue is on Redis (not RabbitMQ)
When it's running, the process (ps aux style) shows up as this:
[celeryd#sky04:MainProcess] -active- (worker --config celeryconfig --beat --schedule=/mnt/services/my_app/var/lib/celerybeat --loglevel=INFO --autoreload --app=my_app.queue.tasks --events --queues=my_app)
celerybeat.conf:
[program:celerybeat]
command=/mnt/services/my_app/bin/celery worker --config celeryconfig --beat --schedule=/mnt/services/my_app/var/lib/celerybeat --loglevel=INFO --autoreload --app=my_app.queue.tasks --events --queues=my_app
environment=PYTHONPATH=/mnt/services/my_app/conf
autostart=false
autorestart=true
startsecs=5
startretries=1
stopwaitsecs=300
numprocs=1
stopsignal=TERM
killasgroup=true
stdout_logfile=/mnt/services/my_app/var/log/celerybeat.log
stderr_logfile=/mnt/services/my_app/var/log/celerybeat.err
tasks.py contains this task:
#periodic_task(
run_every=datetime.timedelta(seconds=60),
name='tasks.my_app_fetch_and_parse_feed',
max_retries=0,
queue='my_app',
options={'queue': 'my_app'},
)
def my_app_fetch_and_parse_feed():
"""
Runs every minute and checks for
matches that need notifications sent.
"""
# some code that's getting run multiple times
pass
Any help and tips anyone could give on this would be greatly appreciated! I've troubleshooted through all my ideas on how to fix it. Thank you so much!
Added info - - -
The processes related to celery are:
$ ps xuf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
507 29554 0.0 0.0 12768 4828 pts/4 S+ 2013 0:00 -bash
507 22921 0.0 0.0 12920 5408 pts/0 S 19:22 0:00 -bash
507 25582 0.0 0.0 8584 812 pts/0 R+ 19:41 0:00 \_ ps xuf
507 13968 0.0 0.0 12804 5376 pts/1 S+ Feb04 0:00 -bash
507 7617 0.0 0.1 106536 12284 ? Ss 2013 60:06 python2.7 /mnt/services/my_app/bin/supervisord
507 23894 13.0 0.3 154644 25168 ? Rl 19:29 1:32 \_ [celeryd#sky03:MainProcess] -active- (worker --beat --schedule=/mnt/services/my_app/var/lib/celerybeat --loglevel=INFO --autoreload --app=my_app
507 23901 0.0 0.2 147852 22608 ? S 19:29 0:00 \_ [celerybeat]
507 23902 6.2 0.3 143476 26288 ? S 19:29 0:44 \_ [celeryd#sky03:PoolWorker-2]
507 23903 6.3 0.3 143980 26712 ? S 19:29 0:44 \_ [celeryd#sky03:PoolWorker-3]
Or for a more verbose output of all the processes related to celery on the box:
$ ps aux | grep celery
APP_TWO 22229 0.0 0.3 164808 26244 ? Sl 2013 2:01 python2.6 /mnt/services/APP_TWO-john/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E
APP_TWO 22266 0.0 0.3 153868 25536 ? S 2013 2:08 python2.6 /mnt/services/APP_TWO-john/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E
APP_TWO 22267 0.0 0.3 153312 24112 ? S 2013 2:05 python2.6 /mnt/services/APP_TWO-john/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E
APP_TWO 22000 0.0 0.0 3820 528 pts/2 S+ 2013 0:01 tail -n 30 -F var/log/celeryd.err
APP_FOUR 22055 0.0 0.0 3820 516 pts/3 S+ 2013 0:00 tail -F var/log/celeryd.err
APP_TWO 12190 0.0 0.3 159004 24316 ? Sl Jan06 0:53 python2.6 /mnt/services/APP_TWO/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E -Q APP_TWO
APP_TWO 12212 0.0 0.2 140736 20252 ? S Jan06 0:39 python2.6 /mnt/services/APP_TWO/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E -Q APP_TWO
APP_TWO 12215 0.0 0.2 140760 20260 ? S Jan06 0:48 python2.6 /mnt/services/APP_TWO/bin/celeryd --loglevel=INFO --autoreload -A APP_TWO.queue.tasks -E -Q APP_TWO
flume-ng 27903 0.0 0.0 3816 524 ? S Jan24 0:00 tail -F /mnt/services/APP_TWO/var/log/celeryd.err
flume-ng 27904 0.0 0.0 3816 524 ? S Jan24 0:00 tail -F /mnt/services/APP_FOUR/var/log/celeryd.log
flume-ng 27927 0.0 0.0 3820 576 ? S Jan24 0:00 tail -F /mnt/services/APP_THREE/var/log/celeryd.err
flume-ng 27945 0.0 0.0 3812 564 ? S Jan24 0:00 tail -F /mnt/services/APP_THREE/var/log/celerybeat.err
flume-ng 27951 0.0 0.0 3812 564 ? S Jan24 0:00 tail -F /mnt/services/MY_APP/var/log/celeryd.log
flume-ng 27967 0.0 0.0 3816 580 ? S Jan24 0:00 tail -F /mnt/services/APP_THREE/var/log/celeryd.log
flume-ng 27969 0.0 0.0 3820 528 ? S Jan24 0:00 tail -F /mnt/services/MY_APP/var/log/celerybeat.log
flume-ng 27970 0.0 0.0 3820 528 ? S Jan24 0:00 tail -F /mnt/services/APP_FOUR/var/log/celeryd.err
flume-ng 27974 0.0 0.0 3816 568 ? S Jan24 0:00 tail -F /mnt/services/APP_THREE/var/log/celerybeat.log
flume-ng 27977 0.0 0.0 3812 564 ? S Jan24 0:00 tail -F /mnt/services/MY_APP/var/log/celeryd.err
flume-ng 28050 0.0 0.0 3816 520 ? S Jan24 0:00 tail -F /mnt/services/APP_TWO/var/log/celeryd.log
508 9256 0.0 0.3 197348 29076 ? Sl Feb08 0:04 python2.7 /mnt/services/APP_THREE/bin/celery worker -B -Q APP_THREE --loglevel=INFO --autoreload -A APP_THREE.queue.tasks -E
508 9264 0.0 0.3 200584 27656 ? S Feb08 0:00 python2.7 /mnt/services/APP_THREE/bin/celery worker -B -Q APP_THREE --loglevel=INFO --autoreload -A APP_THREE.queue.tasks -E
508 9265 0.0 0.3 202092 28060 ? S Feb08 0:48 python2.7 /mnt/services/APP_THREE/bin/celery worker -B -Q APP_THREE --loglevel=INFO --autoreload -A APP_THREE.queue.tasks -E
508 9266 0.0 0.3 206420 29880 ? S Feb08 0:46 python2.7 /mnt/services/APP_THREE/bin/celery worker -B -Q APP_THREE --loglevel=INFO --autoreload -A APP_THREE.queue.tasks -E
APP_FOUR 14512 0.0 0.3 153144 23736 ? Sl 18:23 0:00 python2.7 /mnt/services/APP_FOUR/bin/celeryd --loglevel=INFO --autoreload -A APP_FOUR.queue.tasks -E -Q APP_FOUR
APP_FOUR 14545 0.0 0.2 136212 19868 ? S 18:23 0:00 python2.7 /mnt/services/APP_FOUR/bin/celeryd --loglevel=INFO --autoreload -A APP_FOUR.queue.tasks -E -Q APP_FOUR
APP_FOUR 14547 0.0 0.2 136232 19872 ? S 18:23 0:00 python2.7 /mnt/services/APP_FOUR/bin/celeryd --loglevel=INFO --autoreload -A APP_FOUR.queue.tasks -E -Q APP_FOUR
507 23894 14.6 0.3 154644 25168 ? Sl 19:29 2:08 [celeryd#sky03:MainProcess] -active- (worker --beat --schedule=/mnt/services/MY_APP/var/lib/celerybeat --loglevel=INFO --autoreload --app=MY_APP.queue.tasks --events --queues=MY_APP)
507 23901 0.0 0.2 147852 22640 ? S 19:29 0:00 [celerybeat]
507 23902 6.1 0.3 143500 26312 ? S 19:29 0:53 [celeryd#sky03:PoolWorker-2]
507 23903 6.1 0.3 143660 26452 ? S 19:29 0:54 [celeryd#sky03:PoolWorker-3]
507 25859 0.0 0.0 6040 676 pts/0 S+ 19:43 0:00 grep celery

Upon conversation with the lovely folks in the Celery IRC (ionelmc), this is likely happening because more than one instance of beat is running on my machine.
You can see when you 'ps aux | grep celery' on the box, my_app is using beat, and so is APP_THREE. I should be able to resolve it by shutting one of these down.
http://docs.celeryproject.org/en/latest/reference/celery.bin.worker.html?highlight=#cmdoption-celery-worker-B

Also, it may have been that the --schedule parameter wasn't set on one instance of beat, but it was on the other. Or, it could have been that the redis queues on both were using db 0. I haven't definitively found the fix, but the --schedule parameter one is working currently.

I have the same issue with beat, it turns out that I had incorrect beat database file permissions.
I used docker-compose installation with plugged local database file as volume.
I ran beat and locally and from docker, from different users (custom local and root in docker).
It seems that once I first ran beat locally, docker installation wasn't able to read the database, cause it was owned by local user.

Related

Supervisord sometimes starts celery, sometimes not

I'm deploying my flask api on Kubernetes. The executed command when the container is started is the following:
supervisord -c /etc/supervisor/conf.d/celery.conf
gunicorn wsgi:app --bind=0.0.0.0:5000 --workers 1 --threads 12 --log-level=warning --access-logfile /var/log/gunicorn-access.log --error-logfile /var/log/gunicorn-error.log
You see above that I'm starting celery first with supervisor and after that I'm running the gunicorn server. Content of celery.conf:
[supervisord]
logfile = /tmp/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
umask = 022
identifier = supervisor
directory = /tmp
nocleanup = true
[program:celery]
directory = /mydir/app
command = celery -A celery_worker.celery worker --loglevel=debug
When logged into my pods I can see that sometimes the process of starting celery is working (example in pod 1):
> more /tmp/supervisord.log
2021-06-08 18:19:46,460 CRIT Supervisor running as root (no user in config file)
2021-06-08 18:19:46,462 INFO daemonizing the supervisord process
2021-06-08 18:19:46,462 INFO set current directory: '/tmp'
2021-06-08 18:19:46,463 INFO supervisord started with pid 9
2021-06-08 18:19:47,469 INFO spawned: 'celery' with pid 15
2021-06-08 18:19:48,470 INFO success: celery entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Sometimes it's not (in pod 2):
> more /tmp/supervisord.log
2021-06-08 18:19:42,979 CRIT Supervisor running as root (no user in config file)
2021-06-08 18:19:42,988 INFO daemonizing the supervisord process
2021-06-08 18:19:42,988 INFO set current directory: '/tmp'
2021-06-08 18:19:42,989 INFO supervisord started with pid 9
2021-06-08 18:19:43,992 INFO spawned: 'celery' with pid 11
2021-06-08 18:19:44,994 INFO success: celery entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
>>>> 2021-06-08 18:19:58,642 INFO exited: celery (exit status 2; expected) <<<<<HERE
In my pod 1, a ps command shows the following:
> ps aux | grep celery
root 9 0.0 0.0 55308 16376 ? Ss 18:45 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/conf.d/celery.conf
root 23 2.2 0.8 2343684 352940 ? S 18:45 0:05 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 37 0.0 0.5 2341860 208716 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 38 0.0 0.5 2341864 208716 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 39 0.0 0.5 2341868 208716 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 40 0.0 0.5 2341872 208724 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 41 0.0 0.5 2341876 208728 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 42 0.0 0.5 2341880 208728 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 43 0.0 0.5 2341884 208736 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
root 44 0.0 0.5 2342836 211384 ? S 18:46 0:00 /usr/bin/python3 /usr/local/bin/celery -A celery_worker.celery worker --loglevel=debug
In my pod 2, I can see that supervisord/celery process is still there but I don't have all the individual /usr/local/bin/celery processes that I have in pod 1:
> ps aux | grep celery
root 9 0.0 0.0 55308 16296 ? Ss 18:19 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/conf.d/celery.conf
This behavior is not always the same. Sometimes when pods are restarted the two succeed to launch celery, sometimes none of them succeed. In this last scenario if I make a request to my API that is supposed to launch a celery task, I can see on my broker console (RabbitMQ) that a task is created but there is no message "activity" and nothing is written is my database table (the end result of my celery task).
If I start celery manually in my pods:
celery -A celery_worker.celery worker --loglevel=debug
everything works.
What could explain such a behavior?
Following the comments above, the best solution is to have two containers, the first having the entrypoint gunicorn and the other celery celery-worker. If the second is the same image as the first it works very well and I can scale on Kubernetes each container independently. The only thing is that the code sourcing is more difficult, each time I make a code change on the first I must apply the same changes manually on the second, maybe there is a better way to address this specific issue of the code sourcing.

docker-compose postgres volume changes ownership to gitlab-runner

I have a very strange problem, and cannot find why this happens. I installed gitlab-runner on my computer a several months ago, maybe a year and didn't use it anymore .
I have a docker-composer.yml:
version: '2'
services:
db:
image: postgres:9.5
#restart: always
environment:
POSTGRES_PASSWORD: password
volumes:
- ./storage:/var/lib/postgresql/data
I create ./storage, a ls gives me:
drwxrwxr-x 2 pierre-emmanuel pierre-emmanuel 4096 jui 31 23:33 storage
When I run docker-compose up -d , the user is changed to gitlab-runner ... I don't understand this AT ALL. It should have never happened.
Here is the ls I have:
drwx------ 19 gitlab-runner pierre-emmanuel 4096 jui 31 23:35 storage
Now I repeated this and with ps -aux | grep gitlab was able to see this:
gitlab-+ 2404 11.5 0.0 19704 3456 ? Ss 23:34 0:00 bash /usr/local/bin/docker-entrypoint.sh postgres
gitlab-+ 2514 6.0 0.0 19904 3912 ? S 23:35 0:00 initdb --username=postgres --pwfile=/dev/fd/63
gitlab-+ 2536 0.0 0.0 4280 712 ? S 23:35 0:00 sh -c "/usr/lib/postgresql/9.5/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 >/dev/null
gitlab-+ 2537 0.0 0.3 281888 28572 ? R 23:35 0:00 /usr/lib/postgresql/9.5/bin/postgres --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1
Then after it stays like this until I call docker-composer stop:
gitlab-+ 2404 0.0 0.2 274528 23304 ? Ss 23:34 0:00 postgres
gitlab-+ 2618 0.0 0.0 274528 3780 ? Ss 23:35 0:00 postgres: checkpointer process
gitlab-+ 2619 0.0 0.0 274528 5400 ? Ss 23:35 0:00 postgres: writer process
gitlab-+ 2620 0.0 0.0 274528 3780 ? Ss 23:35 0:00 postgres: wal writer process
gitlab-+ 2621 0.0 0.0 274956 6252 ? Ss 23:35 0:00 postgres: autovacuum launcher process
gitlab-+ 2622 0.0 0.0 129512 2828 ? Ss 23:35 0:00 postgres: stats collector process
My own user and gitlab-runner do have the docker group, but I can't figure out why this is producing. Do you have any idea ?
EDIT: when I remove the app, remove the volume from docker-compose.yml and re-create the app, the user gitlab-runner is still used to run the container which contains postgres.
Processes and files are owned by numeric user and group IDs. There's a file, /etc/passwd, that maps between user names and user IDs; but the nature of Docker is that each container has its own isolated filesystem space, which means it has its own /etc/passwd file.
If you look at the Docker Hub postgresql page there is a link to the image's Dockerfile and you can see that includes a command
RUN useradd ... --uid=999 ... postgres
You should be able to verify that the user IDs on your local system and inside the container match up
grep gitlab-runner /etc/passwd
docker run --rm postgres:9.5 grep postgres /etc/passwd
I would expect both of these to show a uid of 999 in the third field. The files are owned by that uid, but it happens to translate to a different name inside and outside the container.

Why I can't do anything with postgres?

I am using Linux Mint 17. I installed postgres with apt-get. I got postgres user account, I didn't have to create it. Then I login as postgres and followed these steps:
$ initdb -D /usr/local/pgsql/data
...
Success.
You can now start the database server of the Postgres-XC coordinator using:
postgres --coordinator -D /usr/local/pgsql/data
or
pg_ctl start -D /usr/local/pgsql/data -Z coordinator -l logfile
You can now start the database server of the Postgres-XC datanode using:
postgres --datanode -D /usr/local/pgsql/data
or
pg_ctl start -D /usr/local/pgsql/data -Z datanode -l logfile
Then I issued these 2 commands:
$ pg_ctl start -D /usr/local/pgsql/data -Z coordinator -l logfile
$ pg_ctl start -D /usr/local/pgsql/data -Z datanode -l logfile
I didn't get any response.
Then I tried createdb and createuser but I can't. Her you can see some informations, I hope it helps.
darko#darko-Lenovo-G570 ~ $ ps aux | grep postgres
postgre+ 1332 0.0 0.3 53304 6800 ? S 07:59 0:00 /usr/bin/postgres --datanode -D /var/lib/postgres-xc/DN1
postgre+ 1363 0.0 0.3 53304 6808 ? S 07:59 0:00 /usr/bin/postgres --datanode -D /var/lib/postgres-xc/DN2
postgre+ 1372 0.0 0.0 53304 1224 ? Ss 07:59 0:00 postgres: checkpointer process
postgre+ 1373 0.0 0.0 53304 1456 ? Ss 07:59 0:00 postgres: writer process
postgre+ 1374 0.0 0.0 53304 1224 ? Ss 07:59 0:00 postgres: wal writer process
postgre+ 1375 0.0 0.1 53724 2220 ? Ss 07:59 0:00 postgres: autovacuum launcher process
postgre+ 1376 0.0 0.0 23256 1256 ? Ss 07:59 0:00 postgres: stats collector process
postgre+ 1419 0.0 0.0 53304 1232 ? Ss 07:59 0:00 postgres: checkpointer process
postgre+ 1420 0.0 0.0 53304 1464 ? Ss 07:59 0:00 postgres: writer process
postgre+ 1421 0.0 0.0 53304 1232 ? Ss 07:59 0:00 postgres: wal writer process
postgre+ 1423 0.0 0.1 53724 2228 ? Ss 07:59 0:00 postgres: autovacuum launcher process
postgre+ 1424 0.0 0.0 23256 1264 ? Ss 07:59 0:00 postgres: stats collector process
postgre+ 1440 0.0 0.3 53304 6856 ? S 07:59 0:00 /usr/bin/postgres --coordinator -D /var/lib/postgres-xc/CN
postgre+ 1451 0.0 0.0 53304 1224 ? Ss 07:59 0:00 postgres: pooler process
postgre+ 1453 0.0 0.0 53304 1712 ? Ss 07:59 0:00 postgres: checkpointer process
postgre+ 1454 0.0 0.0 53304 1464 ? Ss 07:59 0:00 postgres: writer process
postgre+ 1455 0.0 0.0 53304 1456 ? Ss 07:59 0:00 postgres: wal writer process
postgre+ 1456 0.0 0.5 63548 11736 ? Ss 07:59 0:00 postgres: autovacuum launcher process
postgre+ 1457 0.0 0.0 23256 1264 ? Ss 07:59 0:00 postgres: stats collector process
postgre+ 1481 0.0 0.1 16412 2716 ? S 07:59 0:00 /usr/bin/gtm -D /var/lib/postgres-xc/GTM -l /var/log/postgres-xc/datanode.log
darko 8426 0.0 0.0 5908 856 pts/0 S+ 18:34 0:00 grep --colour=auto postgres
darko#darko-Lenovo-G570 ~ $ sudo -u postgres -i
[sudo] password for darko:
postgres#darko-Lenovo-G570 ~ $ createuser darko
createuser: could not connect to database postgres: FATAL: role "postgres" does not exist
I was confused with roles, databases and privilegies so I decided to remove postgresql and install it again. Actually I think that I didn't install it correctly at first because first installation was
$ sudo apt-get install postgresql
and nothing worked for me, as I described in question. So I decided to kill all postgres processes:
$ sudo pkill postgres
remove postgresql
$ sudo apt-get remove postgresql
and build postgresql form source as described in manual postgresql-9.6-A4.pdf (you can download it from internet). This manual is great, you can find everything there.
MAYBE SOME OF MY COMMANDS ARE NOT 100% CORRECT BECAUSE IT HAS PASSED FEW DAYS SINCE I SOLVED MY PROBLEM.

Correct way to start mysqld_safe

I've been searching around a lot but could not figure out how to start mysqld in "safe mode".
This is what I got so far:
[root#localhost bin]# service mysqld_safe start
mysqld_safe: unrecognized service
I'm running CentOS, this is my mysql version:
[root#localhost ~]# mysql --version
mysql Ver 14.12 Distrib 5.0.95, for redhat-linux-gnu (i686) using readline 5.1
Any help would be appreciated!
Starting mysqld should do the trick:
[root#green-penny ~]# service mysqld start
Starting mysqld: [ OK ]
[root#green-penny ~]# ps axu | grep mysql
root 7540 0.8 0.0 5112 1380 pts/0 S 09:29 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 7642 1.5 0.7 135480 15344 pts/0 Sl 09:29 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 7660 0.0 0.0 4352 724 pts/0 S+ 09:29 0:00 grep mysql
(Note that mysqld_safe is running.)

zabbix How to complete installation successfully? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
CentOS 6.4
postgres 9.2
zabbix 2.0
ps
1761 ? Ss 0:00 postgres: logger process
1763 ? Ss 0:00 postgres: checkpointer process
1764 ? Ss 0:00 postgres: writer process
1765 ? Ss 0:00 postgres: wal writer process
1766 ? Ss 0:00 postgres: autovacuum launcher process
1767 ? Ss 0:00 postgres: stats collector process
2257 ? Ss 0:00 /usr/sbin/httpd
2259 ? S 0:00 /usr/sbin/httpd
2260 ? S 0:00 /usr/sbin/httpd
2261 ? S 0:00 /usr/sbin/httpd
2262 ? S 0:00 /usr/sbin/httpd
2263 ? S 0:00 /usr/sbin/httpd
2264 ? S 0:00 /usr/sbin/httpd
2265 ? S 0:00 /usr/sbin/httpd
2266 ? S 0:00 /usr/sbin/httpd
2280 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2282 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2283 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2284 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2285 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2286 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2287 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2288 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2289 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2290 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2291 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2292 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2293 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2294 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2295 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2296 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2298 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51084) idle
2299 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2300 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2301 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2302 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2303 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2304 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2305 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2306 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2307 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51085) idle
2308 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51086) idle
2309 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51087) idle
2310 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51088) idle
2311 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51089) idle
2312 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51090) idle
2313 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51091) idle
2315 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51093) idle
2316 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51094) idle
2317 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51095) idle
2318 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51096) idle
2319 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51097) idle
2320 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51098) idle
2321 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2322 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2323 ? S 0:00 zabbix_server -c /etc/zabbix/zabbix_server.conf
2324 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51099) idle
2325 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51100) idle
2326 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51101) idle
2327 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51102) idle
2328 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51103) idle
2329 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51104) idle
2330 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51105) idle
2331 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51106) idle
2332 ? Ss 0:00 postgres: zabbix zabbix 127.0.0.1(51107) idle
pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 0.0.0.0/0 trust
local zabbix zabbix md5
postgresql.conf
# - Connection Settings -
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
zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/.s.PGSQL.5432
I can connect and observe zabbix database in pgAdmin wihout any problem. But during zabbix installation in "3. Configure DB connection" I get:
pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
Permission denied Is the server running on host
"localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
[include/db.inc.php:99]
Error connecting to database
How to complete installation successfully?
Permission denied when establishing a network connection is likely to be due to SELinux. Check error messages in /var/log/audit/audit.log
Also note that DBSocket is for MySQL, it's ignored for PostgreSQL.
To have zabbix connect to PostgresQL through a Unix local domain socket, this would be:
DBHost=/tmp # instead of localhost