首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法启动postgresql.service?

无法启动postgresql.service?
EN

Stack Overflow用户
提问于 2017-01-26 14:18:30
回答 6查看 113.4K关注 0票数 16

我使用的是arch linux (4.8.13-1-ARCH)。我正在尝试按照here的指示设置PostgreSQL。

在执行完

代码语言:javascript
运行
复制
[postgres@BitBox ~]$ initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgres/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgres/data -l logfile start

成功地,我使用exit命令返回到我的常规用户。

代码语言:javascript
运行
复制
[postgres@BitBox ~]$ exit
logout

然后,在尝试启动postgresql.service时,我得到了以下错误:

代码语言:javascript
运行
复制
[code_master5@BitBox ~]$ sudo systemctl start postgresql.service
Failed to start postgresql.service: Unit postgresql.service not found.

我甚至没有得到服务的状态:

代码语言:javascript
运行
复制
[code_master5@BitBox ~]$ sudo systemctl status postgresql.service
Unit postgresql.service could not be found.

我卡住了!

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2017-01-28 19:13:04

最后,我解决了这个问题。已存在一个文件

代码语言:javascript
运行
复制
/usr/lib/systemd/system/postgresql-9.6.service

所以,可能是由于这个文件的存在,我无法启动postgresql.service。然后我尝试启动postgresql-9.6.service,如下所示:

代码语言:javascript
运行
复制
[code_master5@BitBox ~]$ sudo systemctl start postgresql-9.6.service
Failed to start postgresql-9.6.service: Unit postgresql-9.6.service not found.

而且,正如您看到的输出,它再次失败。

我只是使用sudo删除了这个文件,因为我认为可能是由于这个文件的存在,相关程序没有创建postgresql.service文件。然后我重新启动了系统。从那时起,它工作得很好,您可以看到下面的输出:

代码语言:javascript
运行
复制
[code_master5@BitBox ~]$ sudo systemctl status postgresql.service
[sudo] password for code_master5: 
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor p
Active: active (running) since Sat 2017-01-28 09:31:30 IST; 7h ago
Main PID: 342 (postgres)
Tasks: 6 (limit: 4915)
CGroup: /system.slice/postgresql.service
       ├─342 /usr/bin/postgres -D /var/lib/postgres/data
       ├─358 postgres: checkpointer process   
       ├─359 postgres: writer process   
       ├─360 postgres: wal writer process   
       ├─361 postgres: autovacuum launcher process   
       └─362 postgres: stats collector process   

Jan 28 09:31:26 BitBox systemd[1]: Starting PostgreSQL database server...
Jan 28 09:31:28 BitBox postgres[340]: FATAL:  the database system is starting up
Jan 28 09:31:28 BitBox postgres[340]: LOG:  database system was shut down at 201
Jan 28 09:31:29 BitBox postgres[340]: FATAL:  the database system is starting up
Jan 28 09:31:29 BitBox postgres[340]: LOG:  MultiXact member wraparound protecti
Jan 28 09:31:29 BitBox postgres[340]: LOG:  database system is ready to accept c
Jan 28 09:31:29 BitBox postgres[340]: LOG:  autovacuum launcher started
Jan 28 09:31:30 BitBox systemd[1]: Started PostgreSQL database server.

我当然想警告所有有同样问题的人。请照我说的做,风险自负。因为这些是系统文件。摆弄这些东西会毁了你的周末!

不过,在这一点上我还是有点困惑。欢迎解释!

票数 16
EN

Stack Overflow用户

发布于 2018-06-19 01:33:33

试试这个:

代码语言:javascript
运行
复制
service postgresql-10.service restart
service postgresql-XX.service restart
票数 25
EN

Stack Overflow用户

发布于 2020-08-28 02:36:15

我发现这两个命令非常方便。虽然这篇文章很老了,但也许其他人将来会从中受益。

代码语言:javascript
运行
复制
systemctl list-units|grep postgresql
service postgresql-12.service restart
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41867841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档