如何让 PostgreSQL 在 Open BSD 7.0 上运行

如何让 PostgreSQL 在 Open BSD 7.0 上运行

尝试在 openbsd 7.0 上启动 postgresql,但似乎无法让它工作。到目前为止,我尝试过本教程 并在 Google 上搜索了一下。我是 OpenBSD 的新手。

# rcctl -df start postgresql 
doing _rc_parse_conf
doing _rc_quirks
postgresql_flags empty, using default >-D /var/postgresql/data -w -l /var/postgresql/logfile<
doing rc_check
pg_ctl: no server running
postgresql
doing rc_start
doing _rc_wait start
doing rc_check
pg_ctl: no server running
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
doing _rc_rm_runfile
(failed)
# ls -al /var/run
total 176
drwxr-xr-x   3 root  wheel      512 Jan 17 01:30 .
drwxr-xr-x  24 root  wheel      512 Jan 16 17:30 ..
srw-rw----   1 root  crontab      0 Jan 16 16:57 cron.sock
-rw-r--r--   1 root  wheel    49152 Jan 16 16:57 dev.db
-rw-r--r--   1 root  wheel     5945 Jan 16 16:57 dmesg.boot
-r--r--r--   1 root  wheel    14592 Jan 16 17:30 ld.so.hints
srw-rw----   1 root  wheel        0 Jan 16 16:57 ntpd.sock
drwxr-xr-x   2 root  wheel      512 Jan 16 18:48 rc.d
srw-rw-rw-   1 root  wheel        0 Jan 16 16:57 smtpd.sock
-rw-r--r--   1 root  wheel        6 Jan 16 16:57 sshd.pid
-rw-r--r--   1 root  wheel        6 Jan 16 16:57 syslog.pid
-rw-rw-r--   1 root  utmp      7296 Jan 18 19:26 utmp

答案1

您只需按照教程中的以下步骤即可成功启动postgresql

# mkdir /var/postgresql/data
# chown _postgresql:_postgresql /var/postgresql/data
# su -l _postgresql
$ initdb -D /var/postgresql/data
The files belonging to this database system will be owned by user "_postgresql".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

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

initdb: 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/postgresql/data -l logfile start

开始使用打印的命令initdb,但更好的是到exit用户会话并使用教程推荐的命令:

# rcctl start postgresql

请务必仔细遵循本教程的其余部分,否则postgresql重启后将无法启动。

答案2

运行后,pkg_add postgresql-server系统将指向您应该阅读的软件包自述文件:

New and changed readme(s):
        /usr/local/share/doc/pkg-readmes/postgresql-server

本自述文件包含在 OpenBSD 机器上启动和运行 postgresql 的其余说明。

相关内容