博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
postgres 中SELINUX
阅读量:7216 次
发布时间:2019-06-29

本文共 1638 字,大约阅读时间需要 5 分钟。

hot3.png

【转载:未测试, 通常操作是 关闭 SELINUX】

Linux Postgresql Log中出现Do you want to choose a different one?的解决方法

前几天,公司要装Postgresql 数据库,并且要加入Linux的Service里,部分脚本如下:
case $1 instart)echo -n "Starting PostgreSQL: "su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "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 "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "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 helpecho "Usage: $0 {start|stop|restart|reload|status}" 1>&2exit 1;; *)在 Linux系统里用service 命令启动都是正常,但是系统重启后该服务就是起不来。后来发现Postgresql 的log中有这么一句话:Do you want to choose a different one? 刚开始就是不能理解,后来发现系统启动了SELinux,在网上一查,有的Linux 发行版中的SELinux对于 su user -c 命令不是很友好。后来我改用runuser命令,问题就解决了。修改后的脚本如下:case $1 instart)echo -n "Starting PostgreSQL: "runuser -s /bin/bash $PGUSER -c "$DAEMON -i -D '$PGDATA' &" >>$PGLOG 2>&1echo "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>&1echo "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'";;*)

转载于:https://my.oschina.net/innovation/blog/155706

你可能感兴趣的文章
SCU 3132(博弈)
查看>>
正则表达式
查看>>
delete archivelog all 无法彻底删除归档日志?
查看>>
Redis五大数据类型
查看>>
大型分布式网站架构技术总结
查看>>
矩阵求导与投影梯度相关问题
查看>>
SVN
查看>>
C语言编程写的一个http下载程序(王德仙)2012-04-08
查看>>
CCF201409-3 字符串匹配(100分)
查看>>
UVALive2203 UVa10042 Smith Numbers【质因数分解+素数判定+数位之和】
查看>>
Project Euler Problem 9: Special Pythagorean triplet
查看>>
HDU5701 中位数计数【中位数】
查看>>
Python 深浅拷贝 (Shallow copy and Deep copy in Python)
查看>>
Axure
查看>>
屏幕截取工具
查看>>
C语言第七次作业---要死了----
查看>>
Jquery事件绑定冲突
查看>>
偶现bug如何处理?
查看>>
yum命令简介
查看>>
【Udacity】朴素贝叶斯
查看>>