在Amazon Linux上启动Postgres SQL 9.6 Server会返回无法识别的服务

编程入门 行业动态 更新时间:2024-10-23 09:28:24
本文介绍了在Amazon Linux上启动Postgres SQL 9.6 Server会返回无法识别的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用以下命令在Amazon Linux上启动Postgres SQL服务器

I am attempting to start a Postgres SQL server on amazon Linux using the command

sudo service postgresql start

我使用此方法。我为简单起见在这里添加了它

I installed the server using this method. I have added it here for simplicity

sudo rpm -i download.postgresql/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm

然后

sudo yum install postgresql96-server.x86_64

之后,我这样做是为postgres安装命令行工具

after which i did this to install the command line tools for postgres

sudo yum install postgresql96.x86_64 postgresql96-libs.x86_64

关于如何开始的任何建议服务器 ?我通常使用命令启动服务器

Any suggestions on how I can start the server ? I usually start the server using the command

sudo service postgresql start

但是在这种情况下它不起作用,因为它说无法识别的服务 ,然后我尝试了此

however its not working in this case as it says "Unrecognized service" I then tried this

postgres -D /usr/local/pgsql/data postgres: could not access directory "/usr/local/pgsql/data": No such file or directory. Run initdb or pg_basebackup to initialize a PostgreSQL data directory.

推荐答案

存在相同或相似的问题。可能是我从源代码安装了pgsql,不记得了。我们可以制作自己的服务启动文件。怎么样?找出答案吧! >> RTFM<<从我们已经知道的内容开始:

Having the same issue, or similar. May be I installed pgsql from source, don't remember. We could make our own service start files. How? Let's find out! >>RTFM<< starting with what we already know:

man service

导致我们进入chkconfig(8),所以

which leads us to chkconfig(8), so

man chkconfig

,它为我们提供了一个选择

and it gives us an option

chkconfig --add ${svcname}

添加全新的服务

但是在我们这样做之前,我们可能实际上想检查一下已经存在的东西。使用

But before we do, we might actually want to check what's already there. With

service --status-all

我们将获得所有已知服务及其运行状态的列表。我在列表中找到了 postmaster,并且您可能知道,要连接的PostgreSQL主服务器以前称为 postmaster。但是,当我尝试

we get a list of all known services and their run status. And I found "postmaster" in my list, and as you might know, the PostgreSQL master server to connect to used to be called "postmaster". Yet, when I try

service postmaster status

它也告诉我它不知道这样的服务。好的,算了吧-现在-让我们继续自己做吧!但是我仍然想看看运行级别3(正常服务器运行级别)中有什么。所以我去

it also tells me it doesn't know such service. OK, forget it -- for now -- just let's move on with making our own! But I still want to peek what there is in run-level 3 (normal server run level). So I go

ls -1 /etc/rc.d/rc3.d |fgrep post

在那里,我发现: K36postgresql95!因此,因此我们的服务名称应为 postgresql95。尝试:

and there I find: "K36postgresql95"! So, accordingly our service name should be "postgresql95". Trying that:

service postgresql95 status

现在说 postmaster已停止。令人困惑的是,该服务在service --status-all和我们单独查询时为自己报告的名称与在service命令中实际寻址该名称的名称不同。很高兴知道。足够容易地在/etc/rc.d中搜索感兴趣的名称。

it says now "postmaster is stopped". Confusingly the name the service reports for itself both in service --status-all and when we individually inquire for it is different than the name used to actually address it in the service command. Good to know. Easy enough to search /etc/rc.d for the name of interest.

service postgresql95 start

现在启动服务。并检查

psql -U ${pguser} ${pgdb}

,我发现它可以正常工作。所以现在我需要做的就是在系统启动时启用该服务以自动启动

and I find that working. So now all I need to do is enable that service at system boot to auto-start

chkconfig --levels 3 postgresql95 on

那行得通,不是吗?

PS:我碰巧运行版本9.5没关系

PS: It doesn't matter that I happen to run version 9.5

更多推荐

在Amazon Linux上启动Postgres SQL 9.6 Server会返回无法识别的服务

本文发布于:2023-10-16 16:20:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498079.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法识别   Postgres   Linux   Amazon   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!