1. Run pg_ctl
pg_ctl
[root@teguhth ~]# su - postgres
Last login: Sun May 12 08:18:13 WIB 2024 on pts/1
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$
2. add path
export PATH=/usr/lib/postgresql/15/bin:$PATH
export PATH=/usr/pgsql-15/bin:$PATH
3. stop and start using pg_ctl
su - postgres
pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl -D /var/lib/pgsql/15/data stop
pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl -D /var/lib/pgsql/15/data start
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: server is running (PID: 2381)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data/"
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
waiting for server to shut down.... done
server stopped
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: no server running
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
waiting for server to start....2024-05-12 08:20:11.166 WIB [2493] LOG: redirecting log output to logging collector process
2024-05-12 08:20:11.166 WIB [2493] HINT: Future log output will appear in directory "log".
done
server started
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: server is running (PID: 2493)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data"
-bash-4.2$
4. sample stop and restart using pg_ctl
su - postgres
pg_ctl status
pg_ctl stop
pg_ctl status
pg_ctl start
pg_ctl
[root@teguhth ~]# su - postgres
Last login: Sun May 12 08:18:13 WIB 2024 on pts/1
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$
2. add path
export PATH=/usr/lib/postgresql/15/bin:$PATH
export PATH=/usr/pgsql-15/bin:$PATH
3. stop and start using pg_ctl
su - postgres
pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl -D /var/lib/pgsql/15/data stop
pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl -D /var/lib/pgsql/15/data start
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: server is running (PID: 2381)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data/"
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
waiting for server to shut down.... done
server stopped
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: no server running
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
waiting for server to start....2024-05-12 08:20:11.166 WIB [2493] LOG: redirecting log output to logging collector process
2024-05-12 08:20:11.166 WIB [2493] HINT: Future log output will appear in directory "log".
done
server started
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
pg_ctl: server is running (PID: 2493)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data"
-bash-4.2$
4. sample stop and restart using pg_ctl
su - postgres
pg_ctl status
pg_ctl stop
pg_ctl status
pg_ctl start
5. example using root access
su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data stop"
su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data status"
su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data start"
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data status"
pg_ctl: server is running (PID: 1959)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data/"
[root@teguhth ~]#
[root@teguhth ~]# systemctl status postgresql-15 | grep Active
Active: active (running) since Sun 2024-05-12 08:15:52 WIB; 20s ago
[root@teguhth ~]#
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data stop"
waiting for server to shut down.... done
server stopped
[root@teguhth ~]#
[root@teguhth ~]# systemctl status postgresql-15 | grep Active
Active: inactive (dead) since Sun 2024-05-12 08:16:18 WIB; 3s ago
[root@teguhth ~]#
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data status"
pg_ctl: no server running
[root@teguhth ~]#
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data start"
waiting for server to start....2024-05-12 08:16:34.066 WIB [2127] LOG: redirecting log output to logging collector process
2024-05-12 08:16:34.066 WIB [2127] HINT: Future log output will appear in directory "log".
done
server started
[root@teguhth ~]#
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data status"
pg_ctl: server is running (PID: 2127)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data"
[root@teguhth ~]#
[root@teguhth ~]# su - postgres -c "/usr/pgsql-15/bin/pg_ctl -D /var/lib/pgsql/15/data status"
pg_ctl: server is running (PID: 2127)
/usr/pgsql-15/bin/postgres "-D" "/var/lib/pgsql/15/data"
[root@teguhth ~]# systemctl status postgresql-15 | grep Active
Active: inactive (dead) since Sun 2024-05-12 08:16:18 WIB; 26s ago
[root@teguhth ~]#
No comments:
Post a Comment