Linux 在CentOS 7上更改postgresql端口需要帮助吗

Linux 在CentOS 7上更改postgresql端口需要帮助吗,linux,postgresql,Linux,Postgresql,我刚刚安装了postgresql(正如它在postgresql上所说的),服务器运行得很好,一点问题也没有。 我刚刚尝试(想要)将默认端口(5432)更改为(9898)。 首先,我只是尝试通过/var/lib/pgsql/data/postgresql.conf下的postgresql.conf文件来实现 我只是删除了端口相关行的注释,并将其更改为端口=9898,但有一条注释说,在这里覆盖端口不会改变RHEL和deriven的任何内容,它还说,尝试通过服务配置文件覆盖端口配置(找不到它,它在哪里

我刚刚安装了postgresql(正如它在postgresql上所说的),服务器运行得很好,一点问题也没有。

我刚刚尝试(想要)将默认端口(5432)更改为(9898)。

首先,我只是尝试通过
/var/lib/pgsql/data/postgresql.conf

下的postgresql.conf文件来实现 我只是删除了
端口
相关行的注释,并将其更改为
端口=9898
,但有一条注释说,在这里覆盖端口不会改变RHEL和deriven的任何内容,它还说,尝试通过服务配置文件
覆盖端口配置(找不到它,它在哪里?

我还更改了
postmaster.opts
(不一样)。

最后如何更改CentOS 7上的Postgresql 9.2.7端口号?

登录到psql。试一试

show config_file ;
这是您应该更改的文件。更改端口后是否重新启动服务器?
如果PostgreSQL是作为服务运行的,您也可以在/etc/rc.d/init.d下尝试该文件。

最后我找到了它,服务文件是
/lib/systemd/system/PostgreSQL.service
,我只是更改了下面的行

Environment=PGPORT=9898
停止服务,因为

service postgresql stop
然后使用以下命令重新加载守护程序服务

systemctl daemon-reload
最后,使用以下命令启动postgresql

service postgresql start

现在它像charm:D一样工作了:From/lib/systemd/system/postgresql.service

# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades.  If you want to customize, the
# best way is to create a file "/etc/systemd/system/postgresql.service",
# containing
#       .include /lib/systemd/system/postgresql.service
#       ...make your changes here...
# For more info about custom unit files, see
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F

# For example, if you want to change the server's port number to 5433,
# create a file named "/etc/systemd/system/postgresql.service" containing:
#       .include /lib/systemd/system/postgresql.service
#       [Service]
#       Environment=PGPORT=5433
# This will override the setting appearing below.

我认为最好按照上面的步骤进行操作。

我将AmazonEC2实例与AmazonLinuxAMI版本(似乎是一种CentOS)结合使用。我需要更改/etc/init.d/postgresql文件中的PGPORT变量,并使用“servicepostgrestart”重新启动postgresql服务。而且很有效

PGPORT=some_new_port # /etc/init.d/postgresql

看起来它位于/etc/sysconfig/pgsql中。看见通常在/etc/init.d/…中查找。。。脚本也会产生很多信息。