Friday, June 17, 2011

Setting up PostgreSQL as Service

Method 1 (Simple start using rc.local):

    Simply add the following line in to your /etc/rc.local file and reboot the system once. This will start the server at each boot.
    su -c ‘/usr/local/pgsql/bin/pg_ctl start -l /usr/local/pgsql/data/log/logfile -D /usr/local/pgsql/data’ postgres

Method 2 (Register postgresql as a service in debian based linux systems):

    1. Copy shell script called linux as postgres into init.d folder from the source package folder,
        $ scp /usr/local/src/postgres*/contrib/start-scripts/linux /etc/init.d/postgresql
              $ chmod a+x /etc/init.d/postgresql
    2. To make the avail of service at all runlevel do,
              $ /etc/init.d/update-rc.d postgresql defaults
    3. To start the server now,
        $ /etc/init.d$ ./postgresql start
        This will take effect after you reboot the system once.

Method 3 (Register postgresql as a service. Check whether 'chkconfig' command installed.):

    1. Copy shell script called linux as postgres into init.d folder from the source package folder,
        $ scp /usr/local/src/postgres*/contrib/start-scripts/linux /etc/init.d/postgresql
              $ chmod a+x /etc/init.d/postgresql
    2. To make the avail of service at all runlevel do,
              $ cd /etc/init.d/
        Add postgresql service
        $ chkconfig --add postgresql
        $ chkconfig –list
        Do the following to start the postgresql service as automatic at all level
        $ chkconfig --levels 012345 postgresql on
    3. To start the server now,
        $ /etc/init.d/postgresql start
        and reboot the system once.

No comments:

Post a Comment