无法启动postgresql.service? [英] Unable to start postgresql.service?

查看:3336
本文介绍了无法启动postgresql.service?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Arch Linux(4.8.13-1-ARCH)。我正在尝试按照此处的指示设置PostgreSQL。

I'm using arch linux (4.8.13-1-ARCH). I'm trying to set up PostgreSQL as instructed here.

执行后

[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

成功后,我使用退出命令返回了我的常规用户。

successfully, I returned to the my regular user using exit command.

[postgres@BitBox ~]$ exit
logout

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

Then, while trying to start postgresql.service, I got the following error:

[code_master5@BitBox ~]$ sudo systemctl start postgresql.service
Failed to start postgresql.service: Unit postgresql.service not found.

我什至没有获得服务的状态:

I'm not even getting the status of the service:

[code_master5@BitBox ~]$ sudo systemctl status postgresql.service
Unit postgresql.service could not be found.

我被卡住了!

推荐答案

最后,我弄清楚了这一点。

Finally, I figured this one out. There was already a file present

/usr/lib/systemd/system/postgresql-9.6.service

因此,可能是由于该文件的存在,所以我无法启动postgresql.service。然后我尝试按以下方式启动postgresql-9.6.service:

So, may be due to the presence of this file, I was not able to start postgresql.service. Then I tried to start postgresql-9.6.service as follows:

[code_master5@BitBox ~]$ sudo systemctl start postgresql-9.6.service
Failed to start postgresql-9.6.service: Unit postgresql-9.6.service not found.

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

And, as you can see the output, again it failed.

我只是使用sudo删除了该文件,因为我认为可能是postgresql.service文件由于相关文件而未被相关程序创建。然后,我重新启动了系统。从那时起,它运行良好,如下面的输出所示:

I simply deleted the file using sudo as I thought may be postgresql.service file is not being created by relevant program due to the presence of this file. Then I restarted the system. It's working fine since then, as you can see the output below:

[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.

我当然想警告所有遇到相同问题的人。请做我做的一切,风险自负。由于这些是系统文件。烦这些可能会破坏您的周末!

I would surely like to warn all those having same problem. Please do whatever I did at your own risk. Since these are system files. Messing with these can spoil your weekend!

不过,我对此仍然有些困惑。欢迎解释!

I am still a bit confused on this though. Explanations are welcome!

这篇关于无法启动postgresql.service?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆