Linux上的PostgreSQL"initdb"(数据库初始化)

Ash*_*her 4 postgresql postgresql-9.2 centos7

我正在开发一个在Linux系统上运行的PostgreSQL 9.x中的数据库集群(单个数据库)(CentOS - RedHat - Fedora).我已经安装了正确的PostgreSQL包(服务器和客户端)但是,我无法创建数据库并获得某种类型的初始化依赖性错误:总线错误/退出代码135.我用"su postgres"将我的用户改为"postgres",然后尝试用"initdb"初始化数据库(这可能是问题)

Installed: postgresql-libs-9.2.13-1.el7_1.x86_64
Installed: postgresql-9.2.13-1.el7_1.x86_64
Installed: postgresql-server-9.2.13-1.el7_1.x86_64

$ initdb -D /usr/local/pgsql/data
Run Code Online (Sandbox Code Playgroud)

http://www.postgresql.org/docs/9.2/interactive/creating-cluster.html

错误:

$ initdb -D /usr/local/pgsql/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.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... sh: line 1: 12616 Bus error               (core dumped) "/usr/bin/postgres" --single -F -O -c search_path=pg_catalog -c exit_on_error=true template1 > /dev/null
child process exited with exit code 135
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Ash*_*her 6

安装PostgreSQL(服务器和客户端工具)后,需要运行以下命令作为ROOT("su").关键步骤是启动"service postgresql initdb"并让它初始化你的PostgreSQL数据库.

如果您有任何错误,则需要删除空安装"data"目录并仔细读取所有日志文件.

# service postgresql initdb
# systemctl enable postgresql
# systemctl start postgresql
Run Code Online (Sandbox Code Playgroud)

完成上述操作后,验证postgres是在/ var/lib/pgsql中运行的进程是否为"ps -ef | grep postgres"(在端口5432上)

如果您遇到任何其他问题,您可能需要创建或修改postgres用户/密码或清理postgres数据目录.

  • 刚刚收到一条信息消息,说“service postgresql initdb”已更改为“postgresql-setup initdb”。 (2认同)
  • `# service postgresql initdb ... 用法:/etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [版本..]` (2认同)