CentOSのPostgSQLでデータベースクラスタを作成したいと思います。
「initdb」コマンドを入力すると、結果は次のようになります。
[root@cll agensgraph]# initdb
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.
答え1
PostgreSQLデータベースは、実際にはデータベースプロセスを実行するユーザーで、初期化が必要です。このユーザーはそうではありません。あなたpostgres
ただし、類似または類似のシステムユーザーアカウントpostgresql
。
CentOSでは、PostgreSQL Wikiのガイドライン、ルートとして次のいずれかを実行できます。
service postgresql-9.6 initdb
または
/usr/pgsql-9.6/bin/postgresql96-setup initdb
(PostgreSQL 9.6を設定すると仮定)。
sudo postgresql-setup initdb
お使いのコンピュータ上のPostgreSQLパッケージにドキュメントが付属している場合(必ず必要です)、このドキュメントではデータベースのバージョンを初期化する方法を正確に説明します。
答え2
[root@cll ~]# sudo chown jessica:jessica /usr/local/agdata/
[root@cll ~]# cd /usr/local/
[root@cll local]# ll
total 8
drwxr-xr-x. 2 jessica jessica 6 Feb 26 18:06 agdata
drwxr-xr-x. 6 root root 56 Feb 26 03:31 agensgraph
drwxr-xr-x. 2 root root 4096 Feb 24 21:01 bin
drwxr-xr-x. 2 root root 6 Nov 5 2016 etc
drwxr-xr-x. 2 root root 6 Nov 5 2016 games
drwxr-xr-x. 4 root root 160 Feb 24 21:01 include
drwxr-xr-x. 6 root root 4096 Feb 24 21:01 lib
drwxr-xr-x. 2 root root 6 Nov 5 2016 lib64
drwxr-xr-x. 2 root root 6 Nov 5 2016 libexec
drwxr-xr-x. 2 root root 6 Nov 5 2016 sbin
drwxr-xr-x. 13 root root 169 Feb 24 21:01 share
drwxr-xr-x. 2 root root 6 Nov 5 2016 src
[root@cll local]# cd agdata/
[root@cll agdata]# initdb
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
[root@cll agdata]# su -l jessica
Last login: Mon Feb 26 23:31:29 CST 2018 from 192.168.109.1 on pts/2
[jessica@cll ~]$ cd /usr/local/agensgraph/
[jessica@cll agensgraph]$ initdb
The files belonging to this database system will be owned by user "jessica".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/agdata ... 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:
ag_ctl -D /usr/local/agdata -l logfile start
[jessica@cll agensgraph]$