SELINUX in postgres

Source: Internet
Author: User

Do you want to choose a different one? Solution a few days ago, the company needs to install the Postgresql database and add it to the Linux Service. Some scripts are as follows: case $1 in start) echo-n "Starting PostgreSQL: "su-$ PGUSER-c" $ DAEMON-D '$ pgdata' & ">>$ PGLOG 2> & 1 echo" OK "; stop) echo-n "Stopping PostgreSQL:" su-$ PGUSER-c "$ PGCTL stop-D '$ PGDATA'-s-m fast" echo "OK"; restart) echo-n "Restarting PostgreSQL: "su-$ PGUSER-c" $ PGCTL stop-D '$ PGDATA'-s-m fast-w "su-$ PGUSER-c" $ DAE MON-D '$ pgdata' & "> $ PGLOG 2> & 1 echo" OK "; reload) echo-n" Reload PostgreSQL: "su-$ PGUSER-c" $ PGCTL reload-D '$ PGDATA'-s "echo" OK "; status) su-$ PGUSER-c "$ PGCTL status-D '$ pgdata'"; *) # Print help echo "Usage: $0 {start | stop | restart | reload | status} "1> & 2 exit 1; *) in Linux, it is normal to start with the service command, however, the service cannot be started after the system is restarted. Later I found that Postgresql's log contains the following sentence: Do you want to choose a different one? At the beginning, I couldn't understand it. Later I found that the system started SELinux and checked it online. Some Linux releases of SELinux were not very friendly to the su user-c command. Later, I used the runuser command to solve the problem. The modified script is as follows: case $1 in start) echo-n "Starting PostgreSQL: "runuser-s/bin/bash $ PGUSER-c" $ DAEMON-I-D '$ pgdata' & ">>$ PGLOG 2> & 1 echo" OK ";; stop) echo-n "Stopping PostgreSQL: "runuser-s/bin/bash $ PGUSER-c" $ PGCTL stop-D '$ PGDATA'-s-m fast "echo" OK "; restart) echo-n "Restarting PostgreSQL: "runuser-s/bin/bash $ PGUSER-c" $ PGCTL stop-D '$ PGDATA'-s-m fast-w "runuser-s/bin/bash $ PGUSER- c "$ DAEMON-I-D '$ pgdata' &"> $ PGLOG 2> & 1 echo "OK ";; reload) echo-n "Reload PostgreSQL:" runuser-s/bin/bash $ PGUSER-c "$ PGCTL reload-D '$ PGDATA'-s" echo "OK ";; status) runuser-s/bin/bash $ PGUSER-c "$ PGCTL status-D '$ pgdata '";;*)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.