我在CentOS 5.5上以非常标准的方式安装了PostgreSQL:
rpm -ivh http://yum.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm yum install postgresql90-server postgresql90-contrib chkconfig postgresql-90 on /etc/init.d/postgresql-90 initdb
但由于某种原因,我不能使用它的service命令,因为它没有名称,。如果我service --status-all我回来了以下内容:
master (pid 3095) is running... (pid 3009) is running... rdisc is stopped
甚至只是/etc/init.d/postgresql-90 status :
(pid 3009) is running...
那么我怎样才能给它一个名字,这样我就不必每次input整个init脚本path呢?
服务名称只是脚本的名称,即postgresql-90 。
不过,我刚刚安装了postgres之后,你的命令上面的init脚本实际上叫做postgresql-9.0 ,而不是postgresql-90 。
$ sudo /sbin/service postgresql-9.0 status (pid 16670) is running...
我相信你很想知道为什么它不告诉你服务的名字,是不是? 这是因为/etc/rc.d/init.d/postgresql-9.0不能正确调用函数status :
status -p /var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid
从/etc/rc.d/init.d/functions :
status() { local base pid pid_file= # Test syntax. if [ "$#" = 0 ] ; then echo $"Usage: status [-p pidfile] {program}" return 1 fi ...
因此/etc/rc.d/init.d/postgresql-9.0应该是
status -p /var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid $0
并且输出是正确的:
$ sudo /sbin/service postgresql-9.0 status postgresql-9.0 (pid 16670) is running...