Why I can't do anything with postgres? - postgresql

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.

Related

Postgresql psql: FATAL: role "username" does not exist

I have looked over all the questions posted previously and surprisingly NONE of them could resolve my problem. Can someone pls help me with this issue. I can post the outputs of the commands if someone can really help me. I am on MacOS BigSur 11.6
Here are the outputs of the common commands I tried from previous questions.
Command: psql or psql -l
Output: psql: FATAL: role "harshit" does not exist
Command: sudo psql
Output: psql: FATAL: role "root" does not exist
Command: su - postgres
Output: After entering the password , it says su: Sorry
Command: ps ax | grep postgres
Output:
47592 ?? S 0:00.12 /usr/local/opt/postgresql#9.6/bin/postgres -D /usr/local/var/postgresql#9.6
47599 ?? Ss 0:00.21 postgres: checkpointer process
47600 ?? Ss 0:00.11 postgres: writer process
47601 ?? Ss 0:00.08 postgres: wal writer process
47602 ?? Ss 0:00.07 postgres: autovacuum launcher process
47603 ?? Ss 0:00.38 postgres: stats collector process
49153 ?? Ss 0:00.03 postgres: stark m3_india ::1(65520) idle
49710 s002 S+ 0:00.01 grep postgres
Command: initdb /usr/local/var/postgresql#9.6
Output:
The files belonging to this database system will be owned by user "harshit".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: C
CTYPE: UTF-8
MESSAGES: C
MONETARY: C
NUMERIC: C
TIME: C
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "UTF-8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
initdb: directory "/usr/local/var/postgresql#9.6" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgresql#9.6" or run initdb
with an argument other than "/usr/local/var/postgresql#9.6".
I thought after the above one, it shown user as "harshit" but still using this username, psql doesn't work. I can't remove the existing db as it has some useful information. Is there no way to access it now?
Edit:
Command: sudo -u postgres psql
Output:
sudo: unknown user: postgres
sudo: error initializing audit plugin sudoers_audit
Command: ps aux | grep postgres
Output:
harshit 52614 0.0 0.1 4490468 24964 ?? Ss 4:50PM 0:00.47 postgres: stark m3_india ::1(50059) idle
harshit 52593 0.0 0.1 4489636 16320 ?? Ss 4:49PM 0:00.33 postgres: stark m3_india ::1(50052) idle
harshit 52290 0.0 0.1 4488464 8688 ?? Ss 4:39PM 0:00.04 postgres: stark m3_india ::1(50004) idle
harshit 51265 0.0 0.0 4342116 1140 ?? Ss 3:49PM 0:01.64 postgres: stats collector process
harshit 51264 0.0 0.0 4487076 2504 ?? Ss 3:49PM 0:00.28 postgres: autovacuum launcher process
harshit 51262 0.0 0.0 4487012 4896 ?? Ss 3:49PM 0:00.15 postgres: wal writer process
harshit 51261 0.0 0.0 4487012 1812 ?? Ss 3:49PM 0:00.14 postgres: writer process
harshit 51260 0.0 0.1 4487140 14444 ?? Ss 3:49PM 0:00.45 postgres: checkpointer process
harshit 51217 0.0 0.1 4487304 14068 ?? S 3:49PM 0:00.30 /usr/local/opt/postgresql#9.6/bin/postgres -D /usr/local/var/postgresql#9.6
_postgres 49645 0.0 0.0 4334640 1136 ?? S 3:35PM 0:00.03 /usr/sbin/distnoted agent
harshit 53335 0.0 0.0 4268424 616 s002 R+ 5:26PM 0:00.00 grep postgres
Command: whoami
Output: harshit
Command: psql -U postgres
Output: psql: FATAL: role "postgres" does not exist
Command: psql -U stark
Output: psql: FATAL: database "stark" does not exist
Edit: Trying to create users
Command: sudo -u postgres createuser harshit -s with password "123" or sudo -u postgres psql -c "ALTER ROLE harshit WITH PASSWORD '123';" or sudo -u postgres createuser -s -i -d -r -l -w harshit or sudo -u postgres -i
Output:
sudo: unknown user: postgres
sudo: error initializing audit plugin sudoers_audit

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.

Celery periodic tasks getting picked up too many times

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.

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

postgresql start db

I have postgresql running (/opt/local/lib/postgresql90/bin).
The data base is set up # /Users/demet8/postgres/data.
I check to make sure postgresql is running with
ps aux | grep postgres
demet8 9851 0.0 0.1 614276 1184 ?? Ss 12:40PM 0:00.24 postgres: autovacuum launcher process
demet8 9850 0.0 0.0 614020 436 ?? Ss 12:40PM 0:00.91 postgres: wal writer process
demet8 9849 0.0 0.0 614020 496 ?? Ss 12:40PM 0:01.22 postgres: writer process
demet8 9847 0.0 0.1 614020 2248 s002 S 12:40PM 0:00.61 /opt/local/lib/postgresql90/bin/postgres -D /Users/demet8/postgres/data
demet8 11127 0.0 0.0 599820 468 s002 S+ 2:05PM 0:00.00 grep postgres
demet8 9852 0.0 0.0 610092 368 ?? Ss 12:40PM 0:00.26 postgres: stats collector process
I go back into: /opt/local/lib/postgresql90/bin & now try to start the db with ./pg_ctl start. This is the error msg I get:
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
Any suggestions on to what I can be doing wrong. I googled around the web for answers & I haven't found a solution.
$ su -
# su - postgres
Proceed from there.
I know this question is already answered but, if you are new to Postgres and seeing similar issues, try the below commands to resolve the error pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information.
1. su - postgres
2. find / -name pg_ctl --> gives you the location where pg_ctl present, in my case it is there in `/usr/lib/postgresql/11/bin/`
3. /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main