CentOS7安装PostgreSQL启动问题

为了在服务器上运行odoo,所以参照[odoo文档](https://www.odoo.com/documentation/12.0/setup/install.html)在CentOS7上安装了PostgreSQL数据库:

$ sudo dnf install -y postgresql-server
$ sudo postgresql-setup --initdb --unit postgresql
$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql

其中,到第二条命令打算创建postgresql.service时报错:

systemctl: unrecognized option ‘–unit.service’
failed to find PGDATA setting in --unit.service

而后,执行第三条命令设置开机启动时就失败了:

Job for postgresql.service failed because the control process exited with error code. See “systemctl status postgresql.service” and “journalctl -xe” for details.

执行journalctl -xe查看当前日志,发现启动失败:

Failed to start PostgreSQL database server.

报错/var/lib/pgsql/data” is missing or empty.,最终解决方案,先执行以下命令即可:

	$ sudo service postgresql initdb

亲测可用!

Ref: How to Fix “/var/lib/pgsql/data is missing. Use “service postgresql initdb” to initialize the cluster first” Error On Linux CentOS 6.2 Server

你可能感兴趣的:(Server)