- Pg_ctl Utility & Postgresql Service to do the same thing: Start the postgres server in the background. Without PGDATA set, “pg_ctl start” needs needs the additional -D /datadir argument in order to start.
- you can start/stop the postgresql server as root user as well as postgres user
root user:
- “service postgresql start“
- “/etc/init.d/postgresql start“, or “systemctl start postgresql-10” – this is for redhat linux above version 6
postgres or edb user:
Pg_ctl is only applicable for postgres user or edb user if you are a Enterprisedb
- su – postgres
./pg_ctl start -D /opt/PostgreSQL/9.3/data
By using following anyone methods you can start,stop,reload else restart the postgresql server
- By using Pg_ctl Utility
- Postgresl -9.3 Script
- By using Postgresql Service
1. pg_ctl utility – as postgres user:
using pg_ctl you can start/stop/reload/restart the postgresql server this utility can only permitted to access as postgres user
using pg_ctl you can start/stop/reload/restart the postgresql server this utility can only permitted to access as postgres user
./pg_ctl stop -D /opt/PostgresPlus/9.3AS/data/./pg_ctl start -D /opt/PostgresPlus/9.3AS/data/./pg_ctl reload -D /opt/PostgresPlus/9.3AS/data/./pg_ctl status -D /opt/PostgresPlus/9.3AS/data/
Starting the Server:
$ pg_ctl start -D /data_directory_path/
To stop the server, waiting until the server is accepting connections:
$ pg_ctl -w stop -D /data_directory_path/
To start the server using port 5433, and running without
fsync
, use:$ pg_ctl -o "-F -p 5432" start -D /data_directory_path/[postgres@r1 bin]$ ./pg_ctl start -m fast -D /opt/PostgreSQL/9.3/dataserver starting[postgres@r1 bin]$ 2017-01-25 17:06:07 EST LOG: redirecting log output to logging collector process2017-01-25 17:06:07 EST HINT: Future log output will appear in directory "pg_log".
Stopping the Server:
To stop the server, use
To stop the server, use
$ pg_ctl stop -D /data_directory_path/
The -m option allows control over how the server shuts down its like a oracle force shutdown it will not wait for untill session disconnect
[postgres@r1 bin]$ ./pg_ctl stop -m fast -D /opt/PostgreSQL/9.3/datawaiting for server to shut down... doneserver stopped
Restarting the Server:
Restarting the server is almost equivalent to stopping the server and starting it again, except that pg_ctl saves and reuses the command line options that were passed to the previously running instance. To restart the server in the simplest form, use
Restarting the server is almost equivalent to stopping the server and starting it again, except that pg_ctl saves and reuses the command line options that were passed to the previously running instance. To restart the server in the simplest form, use
$ pg_ctl restart -D /data_directory_path/
To restart the server, waiting for it to shut down and restart
[postgres@r1 bin]$ ./pg_ctl -w restart -D /opt/PostgreSQL/9.3/datawaiting for server to shut down... doneserver stopped2017-01-25 17:03:54 EST LOG: redirecting log output to logging collector process2017-01-25 17:03:54 EST HINT: Future log output will appear in directory "pg_log".waiting for server to start.... doneserver started
To restart using port 5433, disabling
fsync
upon restart[postgres@r1 bin]$ ./pg_ctl -o "-F -p 5432" restart -D /opt/PostgreSQL/9.3/datawaiting for server to shut down.... doneserver stopped2017-01-25 17:01:41 EST LOG: redirecting log output to logging collector process2017-01-25 17:01:41 EST HINT: Future log output will appear in directory "pg_log".server starting
Checking postgresql Server status:
you can check the postgresql server status whether stopped or started using following command
you can check the postgresql server status whether stopped or started using following command
[postgres@r1 bin]$ ./pg_ctl statuspg_ctl: no database directory specified and environment variable PGDATA unsetTry "pg_ctl --help" for more information.
Solution:
[postgres@r1 bin]$ ./pg_ctl status -D /opt/PostgreSQL/9.3/datapg_ctl: server is running (PID: 5188)/opt/PostgreSQL/9.3/bin/postgres "-D" "/opt/PostgreSQL/9.3/data"
2. postgresql server stop/start/reload/status – as root user
/etc/init.d/postgresql-9.3 start/etc/init.d/postgresql-9.3 stop/etc/init.d/postgresql-9.3 restart/etc/init.d/postgresql-9.3 reload/etc/init.d/postgresql-9.3 status
Examples /etc/init.d/postgres:
Here i am trying to start the postgres server as a postgres user using “/etc/init.d/postgres” command you will get permission denied error and it will work only as a root user
Here i am trying to start the postgres server as a postgres user using “/etc/init.d/postgres” command you will get permission denied error and it will work only as a root user
[postgres@r1 bin]$ /etc/init.d/postgresql-9.3 startStarting PostgreSQL 9.3: Password: waiting for server to start.... doneserver startedtouch: cannot touch `/var/lock/subsys/postgresql-9.3': Permission deniedPostgreSQL 9.3 started successfully
starting server as root user:
[root@r1 ]# /etc/init.d/postgresql-9.3 startStarting PostgreSQL 9.3: waiting for server to start.... doneserver startedPostgreSQL 9.3 started successfully
3. By using Postgresql service – as root user:
you can start/stop/reload/restart the postgresql server using postgresql service ,it will work only on root user path not good for postgres user as defaulty. before accessing you have to setup the service
you can start/stop/reload/restart the postgresql server using postgresql service ,it will work only on root user path not good for postgres user as defaulty. before accessing you have to setup the service
Set Up “service postgresql”on RedHat Linux
Examples :
Service postgresql startService postgresql stopService postgresql restartService postgresql status
0 comments:
Post a Comment