我正在尝试使用以下命令在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会返回无法识别的服务
发布评论