I just installed PostgreSQL (9.3) on my Linux Fedora (21) - Shown below
yum installer returns 'already installed' as this is the second time I run it, to get a screengrab for you.
systemctl enable postgresq, seems to work. At least it returns no errors.
systemctl start postgresql fails. The log says "data directory "/ConfigDir" does not exist" So I guess that's the key.
But the /ConfigDir do exis. It's /usr/local/pgsql/data as is default on a Fedora PostgreSQL instalation. It is tough owned by user:postgres
I guess that the start of the postgres server service fails because it somehow can't see the directory, likely because it's not trying as user:postgres.
But I don't know how to check this, nor how to mend it.
[martin#helium ~]$ sudo yum install postgresql-server postgresql-contrib
[sudo] password for martin:
Loaded plugins: langpacks
Package postgresql-server-9.3.9-1.fc21.x86_64 already installed and latest version
Package postgresql-contrib-9.3.9-1.fc21.x86_64 already installed and latest version
Nothing to do
[martin#helium ~]$ sudo systemctl enable postgresql
[martin#helium ~]$ sudo systemctl start postgresql
Job for postgresql.service failed. See "systemctl status postgresql.service" and "journalctl -xe" for details.
[martin#helium ~]$ journalctl -xn
-- Logs begin at Fri 2014-12-26 16:16:25 CET, end at Sun 2016-02-07 14:35:11 CET. --
Feb 07 14:35:06 helium.hvidberg.net sudo[3466]: martin : TTY=pts/0 ; PWD=/home/martin ; USER=root ; COMMAND=/bin/systemctl start postgresql
Feb 07 14:35:06 helium.hvidberg.net sudo[3466]: pam_unix(sudo:session): session opened for user root by martin(uid=0)
Feb 07 14:35:06 helium.hvidberg.net pg_ctl[3476]: FATAL: data directory "/ConfigDir" does not exist
Feb 07 14:35:11 helium.hvidberg.net pg_ctl[3476]: pg_ctl: could not start server
Feb 07 14:35:11 helium.hvidberg.net pg_ctl[3476]: Examine the log output.
Feb 07 14:35:11 helium.hvidberg.net systemd[1]: postgresql.service: control process exited, code=exited status=1
Feb 07 14:35:11 helium.hvidberg.net systemd[1]: Failed to start PostgreSQL database server.
-- Subject: Unit postgresql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has failed.
--
-- The result is failed.
Feb 07 14:35:11 helium.hvidberg.net systemd[1]: Unit postgresql.service entered failed state.
Feb 07 14:35:11 helium.hvidberg.net systemd[1]: postgresql.service failed.
Feb 07 14:35:11 helium.hvidberg.net sudo[3466]: pam_unix(sudo:session): session closed for user root
[martin#helium ~]$
Change to root to be able to see the postgresql data directory
[root#helium data]# pwd
/usr/local/pgsql/data
[root#helium data]# ls -l
total 100
drwx------. 5 postgres postgres 4096 Feb 6 19:00 base
drwx------. 2 postgres postgres 4096 Feb 6 19:03 global
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_clog
-rw-------. 1 postgres postgres 4476 Feb 6 19:00 pg_hba.conf
-rw-------. 1 postgres postgres 1636 Feb 6 19:00 pg_ident.conf
drwx------. 2 postgres postgres 4096 Feb 6 19:03 pg_log
drwx------. 4 postgres postgres 4096 Feb 6 19:00 pg_multixact
drwx------. 2 postgres postgres 4096 Feb 6 19:03 pg_notify
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_serial
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_snapshots
drwx------. 2 postgres postgres 4096 Feb 6 19:05 pg_stat
drwx------. 2 postgres postgres 4096 Feb 6 19:05 pg_stat_tmp
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_subtrans
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_tblspc
drwx------. 2 postgres postgres 4096 Feb 6 19:00 pg_twophase
-rw-------. 1 postgres postgres 4 Feb 6 19:00 PG_VERSION
drwx------. 3 postgres postgres 4096 Feb 6 19:00 pg_xlog
-rw-------. 1 postgres postgres 20733 Feb 7 10:26 postgresql.conf
-rw-------. 1 postgres postgres 47 Feb 6 19:03 postmaster.opts
[root#helium data]#
Related
I am trying to setup a replicaset for my dev environment, and have three machines running debian 9.3 stretch with a mongod service. The replicaset is working, and all seems okay.
But when I reboot one of the servers the mongod service doesn't come up. When I check the status it says it failed status=48
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2018-08-28 22:17:37 CEST; 10s ago
Docs: https://docs.mongodb.org/manual
Process: 392 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
Main PID: 392 (code=exited, status=48)
CPU: 33ms
aug 28 22:17:37 staging-manager-1 systemd[1]: Started MongoDB Database Server.
aug 28 22:17:37 staging-manager-1 mongod[392]: 2018-08-28T22:17:37.389+0200 I CONTROL [main] Automatically disabling TLS 1.0, to fo
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Unit entered failed state.
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Failed with result 'exit-code'.
I already enabled the service with systemctl enable mongod and in the status I can see that it is indeed enabled, but why does it fail after I reboot the machine?
update:
root#machine:/home/<user># journalctl -u mongod
-- Logs begin at Thu 2018-08-30 21:11:33 CEST, end at Thu 2018-08-30 21:26:42 CEST. --
aug 30 21:11:33 staging-manager-1 systemd[1]: Started MongoDB Database Server.
aug 30 21:11:33 staging-manager-1 mongod[398]: 2018-08-30T21:11:33.388+0200 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Unit entered failed state.
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Failed with result 'exit-code'.
root#machine:/home/<user># ll /etc/init
total 48
-rw-r--r-- 1 root root 278 mei 29 2017 anacron.conf
-rw-r--r-- 1 root root 1875 jul 18 21:01 docker.conf
-rw-r--r-- 1 root root 2493 jun 2 2015 networking.conf
-rw-r--r-- 1 root root 933 jun 2 2015 network-interface.conf
-rw-r--r-- 1 root root 530 jun 2 2015 network-interface-container.conf
-rw-r--r-- 1 root root 1756 jun 2 2015 network-interface-security.conf
-rw-r--r-- 1 root root 1359 mrt 14 2017 sddm.conf
-rw-r--r-- 1 root root 637 mrt 1 13:36 ssh.conf
-rw-r--r-- 1 root root 337 jun 13 22:20 udev.conf
-rw-r--r-- 1 root root 360 jun 13 22:20 udevmonitor.conf
-rw-r--r-- 1 root root 352 jun 13 22:20 udevtrigger.conf
-rw-r--r-- 1 root root 138 jan 23 2017 usb-modeswitch-upstart.conf
root#machine:/home/<user># ll /etc/init.d
total 168
-rwxr-xr-x 1 root root 5336 feb 1 2016 alsa-utils
-rwxr-xr-x 1 root root 2014 mei 29 2017 anacron
-rwxr-xr-x 1 root root 8181 apr 5 20:32 apache2
-rwxr-xr-x 1 root root 2489 mei 13 18:52 apache-htcacheclean
-rwxr-xr-x 1 root root 2401 jan 23 2017 avahi-daemon
-rwxr-xr-x 1 root root 2948 sep 13 2017 bluetooth
-rwxr-xr-x 1 root root 1904 nov 18 2015 cgroupfs-mount
-rwxr-xr-x 1 root root 1232 apr 7 2017 console-setup.sh
-rwxr-xr-x 1 root root 3049 okt 7 2017 cron
-rwxr-xr-x 1 root root 2816 jul 10 15:57 cups
-rwxr-xr-x 1 root root 1961 jan 19 2017 cups-browsed
-rwxr-xr-x 1 root root 2813 mrt 2 09:59 dbus
-rwxr-xr-x 1 root root 3843 jul 18 21:01 docker
-rwxr-x--- 1 root root 4285 jul 20 07:27 elasticsearch
-rwxr-xr-x 1 root root 3033 aug 9 21:30 gdm3
-rwxr-xr-x 1 root root 1604 feb 2 2017 gdomap
-rwxr-xr-x 1 root root 3809 mrt 7 19:29 hwclock.sh
-rwxr-xr-x 1 root root 1479 mei 19 2016 keyboard-setup.sh
-rwxr-xr-x 1 root root 2044 dec 26 2016 kmod
-rwxr-xr-x 1 root root 2241 apr 26 2017 minissdpd
-rwxr-xr-x 1 root root 4597 sep 16 2016 networking
-rwxr-xr-x 1 root root 1757 mrt 18 2017 network-manager
-rwxr-xr-x 1 root root 612 dec 4 2015 pppd-dns
-rwxr-xr-x 1 root root 1191 mei 17 12:56 procps
-rwxr-xr-x 1 root root 4355 dec 10 2017 rsync
-rwxr-xr-x 1 root root 2868 jan 18 2017 rsyslog
-rwxr-xr-x 1 root root 2330 mei 21 2017 saned
-rwxr-xr-x 1 root root 1222 apr 3 2017 screen-cleanup
-rwxr-xr-x 1 root root 1808 mrt 14 2017 sddm
-rwxr-xr-x 1 root root 2117 aug 2 2017 speech-dispatcher
-rwxr-xr-x 1 root root 2484 okt 12 2016 spice-vdagent
-rwxr-xr-x 1 root root 4033 mrt 1 13:36 ssh
-rwxr-xr-x 1 root root 731 jun 5 2017 sudo
-rwxr-xr-x 1 root root 6087 jun 13 22:20 udev
-rwxr-xr-x 1 root root 1391 mei 6 2017 unattended-upgrades
-rwxr-xr-x 1 root root 2757 nov 23 2016 x11-common
That is the whole output message?
Check if the default mongod port(27017) is not in use.
netstat -a
Or try starting in a different port
mongod --fork --port 8000
MongoDB defines exit code 48 as: "A newly started mongod or mongos could not start listening for incoming connections, due to an error."
You have pasted just the status output for the MongoDB service. For the full logs of a service on a systemd based system, you should review the systemd journal output:
journalctl -u mongod
As Lucca suggested, the problem may be something else is already running on the port when you are trying to start.
Check that you are't also trying to start MongoDB via Upstart or SysVInit by looking for MongoDB files in /etc/init and /etc/init.d. If any are found, move them somewhere else so that only the systemd service file is being used to start the service.
a#a-57:~$ sudo systemctl stop mongod.service
a#a-57:~$ sudo systemctl start mongod.service
a#a-57:~$ sudo systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-09 16:38:29 CST; 6s ago
Docs: https://docs.mongodb.org/manual
Main PID: 2205 (mongod)
CGroup: /system.slice/mongod.service
└─2205 /usr/bin/mongod --config /etc/mongod.conf
八 09 16:38:29 a-57 systemd[1]: Started MongoDB Database Server.
Somehow it's dangerous to edit the rc files under /etc in these modern days. And people would prefer to use system command API as we knew.
You need to edit etc/rc.local in order for it to start on boot up
Just add service mongod start to end of the rc.local file
I've added a service (Seafile, in this case) that I want to have running at all times to systemd with a service file. It works great, but every time the unattended updates run, the service gets shutdown properly - but never restarted.
Here's what the service file looks like:
[Unit]
Description=Seafile
Requires=mysql.service
After=mysql.service
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
User=root
Group=root
PermissionsStartOnly=true
ExecStart=/srv/start-seafile
TimeoutSec=600
Restart=on-failure
/srv/start-seafile looks like this:
#!/bin/bash
cd /srv/seafile/XXXX/seafile-server-latest && nohup ./seafile.sh start
Like I said - this works perfectly - systemd can enable / disable / start / stop the service, realize if it's started / running - so I must be doing something right.
# systemctl start seafile
# systemctl status seafile
* seafile.service - Seafile
Loaded: loaded (/etc/systemd/system/seafile.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-01-28 17:53:51 CET; 8s ago
Process: 6569 ExecStart=/srv/start-seafile (code=exited, status=0/SUCCESS)
CGroup: /system.slice/seafile.service
|-6598 /srv/seafile/XXXX/seafile-server-5.1.4/seafile/bin/seafile-controller -c /srv/seafile/XXXX/ccnet -d /volume1/Seafile -F /srv/seafile/XXXX/conf
|-6600 ccnet-server -F /srv/seafile/XXXX/conf -c /srv/seafile/XXXX/ccnet -f /srv/seafile/XXXX/logs/ccnet.log -d -P /srv/seafile/XXXX/pids/ccnet.pid
`-6602 seaf-server -F /srv/seafile/XXXX/conf -c /srv/seafile/XXXX/ccnet -d /volume1/Seafile -l /srv/seafile/XXXX/logs/seafile.log -P /srv/seafile/XXXX/pids/seaf-server.pid
Jan 28 17:53:48 XXXX systemd[1]: Starting Seafile...
Jan 28 17:53:48 XXXX start-seafile[6569]: [01/28/18 17:53:48] ../common/session.c(132): using config file /srv/seafile/XXXX/conf/ccnet.conf
Jan 28 17:53:48 XXXX start-seafile[6569]: Starting seafile server, please wait ...
Jan 28 17:53:51 XXXX start-seafile[6569]: Seafile server started
Jan 28 17:53:51 XXXX start-seafile[6569]: Done.
Jan 28 17:53:51 XXXX systemd[1]: Started Seafile.
However, every time the unattended updates come, this happens:
Jan 23 06:38:08 XXXX systemd[1]: Starting Daily apt activities...
Jan 23 06:40:13 XXXX systemd[1]: Reloading.
Jan 23 06:40:13 XXXX systemd[1]: Stopping Seahub...
Jan 23 06:40:14 XXXX systemd[1]: Stopped Seahub.
Jan 23 06:40:14 XXXX systemd[1]: Stopping Seafile...
Jan 23 06:40:15 XXXX systemd[1]: Stopped Seafile.
Jan 23 06:40:15 XXXX systemd[1]: Stopping MySQL Community Server...
Jan 23 06:40:16 XXXX systemd[1]: Stopped MySQL Community Server.
Jan 23 06:40:17 XXXX systemd[1]: Reloading.
Jan 23 06:40:17 XXXX systemd[1]: Stopped MySQL Community Server.
...
Jan 23 06:40:43 XXXX systemd[1]: Reloading.
Jan 23 06:40:44 XXXX systemd[1]: Stopped MySQL Community Server.
Jan 23 06:40:44 XXXX systemd[1]: Reloading.
Jan 23 06:40:44 XXXX systemd[1]: Reloading.
Jan 23 06:40:44 XXXX systemd[1]: Starting MySQL Community Server...
Jan 23 06:40:45 XXXX systemd[1]: Started MySQL Community Server.
Jan 23 06:40:47 XXXX systemd[1]: Reloading.
Jan 23 06:40:48 XXXX systemd[1]: Stopping MySQL Community Server...
Jan 23 06:40:49 XXXX systemd[1]: Stopped MySQL Community Server.
Jan 23 06:40:49 XXXX systemd[1]: Starting MySQL Community Server...
Jan 23 06:40:50 XXXX systemd[1]: Started MySQL Community Server.
(... continues with unrelated services )
So it realizes that Seafile needs to be stopped before MySQL, and does so, but no longer starts it after it restarts MySQL.
Does anyone have any experience as to what could be causing this? ie. under which circumstances systemd services will be stopped during an update, but not restarted?
Use Restart=always if you want it to run at all times. When mysql service update happens, this service does a clean stop and therefore systemd doesn't restart it. You have Restart=on-failure set, which only restarts if the stop has a return code other than 0.
Restart = always
RestartSec = 10
RestartSec
Configures the time to sleep before restarting a service (as configured with Restart=). Takes a unit-less value in seconds, or a time span value such as "5min 20s". Defaults to 100ms.
We have an application that is running on RHEL6/32 bit and RHEL6/64 bit. This application uses postgresql 8.4 from the beginning. Now, we want to provide support for this application on RHEL7/64 bit. RHEL7 comes with default postgresql 9.2 in its yum list and this is getting installed and its related services are running properly as well. But after installing postgresql 8.4 on RHEL7, it seems like the services are never running. Please find below the logs:
[root#linpubn218 postgres]# service postgresql status
postgresql.service - SYSV: PostgreSQL database server.
Loaded: loaded (/etc/rc.d/init.d/postgresql)
Active: failed (Result: resources) since Mon 2016-07-25 12:40:28 IST; 2h 0min ago
Docs: man:systemd-sysv-generator(8)
Jul 25 12:40:26 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server....
Jul 25 12:40:28 linpubn218.gl.avaya.com postgresql[26957]: Starting postgresql service: [ OK ]
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: PID file /var/run/postmaster-8.4.pid not readable (yet?) after start.
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: Failed to start SYSV: PostgreSQL database server..
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service entered failed state.
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: postgresql.service failed.
Jul 25 14:33:45 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service cannot be reloaded because it is inactive.
Jul 25 14:33:45 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service cannot be reloaded because it is inactive.
After looking at the logs in journalctl -xe
[root#linpubn218 postgres]# journalctl -xe
Jul 25 14:39:21 linpubn218.gl.avaya.com yum[29260]: Installed: postgresql84-libs-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:39:45 linpubn218.gl.avaya.com yum[29275]: Installed: postgresql84-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:40:01 linpubn218.gl.avaya.com useradd[29316]: failed adding user 'postgres', exit code: 9
Jul 25 14:40:02 linpubn218.gl.avaya.com CROND[29320]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 25 14:40:02 linpubn218.gl.avaya.com systemd[1]: Reloading.
Jul 25 14:40:03 linpubn218.gl.avaya.com systemd[1]: Configuration file /usr/lib/systemd/system/auditd.service is marked world-inaccessible. This has no effect as config
Jul 25 14:40:03 linpubn218.gl.avaya.com yum[29309]: Installed: postgresql84-server-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:42:05 linpubn218.gl.avaya.com polkitd[819]: Registered Authentication Agent for unix-process:29459:43987285 (system bus name :1.292 [/usr/bin/pkttyagent --not
Jul 25 14:42:05 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server....
Jul 25 14:42:06 linpubn218.gl.avaya.com runuser[29473]: pam_unix(runuser-l:session): session closed for user postgres
Jul 25 14:42:08 linpubn218.gl.avaya.com postgresql[29464]: Starting postgresql service: [ OK ]
Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: PID file /var/run/postmaster-8.4.pid not readable (yet?) after start.
Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: Failed to start SYSV: PostgreSQL database server..
Can postgresql 8.4 be installed on RHEL7, which is a systemd based OS? If yes, then what should I do to remove the above error?
I noticed that in /etc/init.d/postgresql-8.4 there is a declared variable:
pidfile="/var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid"
But in systemctl, PIDfile is not the same:
# systemctl show postgresql-8.4.service -p PIDFile
PIDFile=/var/run/postmaster-8.4.pid
So, to fix the problem edit /etc/init.d/postgresql-8.4 and replace
pidfile="/var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid"
with
pidfile="/var/run/postmaster-${PGMAJORVERSION}.pid"
then reload systemctl:
# systemctl daemon-reload
#/etc/init.d/postgresql-8.4 start
Starting postgresql-8.4 (via systemctl): [ OK ]
Generally permissions caused this type of error
su - postgres
After that:
chmod 700 -R <data_directory>
And you should check SELinux as well.
I was starting the postgresql service by
systemctl start postgresql.service
It was raising an error as below
Job for postgresql.service failed. See "systemctl status postgresql.service" and "journalctl -xn" for details.
Please help how to start the service through command line in linux?
Output for journalctl -xn
osboxes:/home/osboxes # journalctl -xn
-- Logs begin at Wed 2015-04-08 10:08:38 BST, end at Tue 2016-03-22 14:15:07 GMT. --
Mar 22 14:09:03 osboxes wickedd[824]: eno16777760: Notified neighbours about IP address 192.168
Mar 22 14:09:03 osboxes wickedd[824]: route ipv4 0.0.0.0/0 via 192.168.182.2 dev eno16777760 ty
Mar 22 14:09:04 osboxes wickedd[824]: Skipping hostname update, none available
Mar 22 14:15:01 osboxes cron[9120]: pam_unix(crond:session): session opened for user root by (u
Mar 22 14:15:01 osboxes systemd[9121]: pam_unix(systemd-user:session): session opened for user
Mar 22 14:15:01 osboxes CRON[9120]: pam_unix(crond:session): session closed for user root
Mar 22 14:15:01 osboxes systemd[9122]: pam_unix(systemd-user:session): session closed for user
Mar 22 14:15:07 osboxes postgresql[9160]: Initializing PostgreSQL 9.3.11 at location ~postgres/
Mar 22 14:15:07 osboxes postgresql[9160]: ..failed
Mar 22 14:15:07 osboxes postgresql[9160]: You can find a log of the initialisation in ~postgres
i have a server hp with ubuntu server
I want to know if my server was shutdown and time that is shutting down in
there are something to know a logs of my server
You can try the last reboot command to get some basic information about the most recent reboots and the uptime between them.
# last reboot
reboot system boot 2.6.32-431.3.1.e Fri Mar 14 07:02 - 01:51 (8+18:49)
reboot system boot 2.6.32-431.3.1.e Sun Feb 16 02:15 - 06:59 (26+03:44)
reboot system boot 2.6.32-431.3.1.e Sun Jan 26 16:21 - 06:59 (46+13:38)
reboot system boot 2.6.32-358.11.1. Sun Oct 13 18:53 - 16:18 (104+22:25)
reboot system boot 2.6.32-358.11.1. Sun Oct 6 10:10 - 18:50 (7+08:40)
reboot system boot 2.6.32-358.11.1. Sat Jun 29 09:28 - 10:06 (99+00:38)
reboot system boot 2.6.32-358.11.1. Sat Jun 29 09:06 - 09:25 (00:19)
reboot system boot 2.6.32-358.6.2.e Sat Jun 29 08:46 - 09:01 (00:15)