Amazon LinuxでPostgresを設定する方法

Amazon LinuxでPostgresを設定する方法

ほとんどのチュートリアルではpostgresqlとpostgresql-serverをインストールします。

$ sudo yum install postgresql postgresql-server

Installed:
  postgresql.x86_64 0:9.2.24-1.amzn2.0.1                         
  postgresql-server.x86_64 0:9.2.24-1.amzn2.0.1                        

Dependency Installed:
  postgresql-libs.x86_64 0:9.2.24-1.amzn2.0.1                                                                                          

プログラムはここにインストールされます:

$ which psql
/usr/bin/psql


$ which postgres
/usr/bin/postgres

この時点で、ほとんどのチュートリアルinitdbpg_ctl <path> start

$ cd '/usr/lib'

$ service postgresql initdb
Hint: the preferred way to do this is now "postgresql-setup initdb"

$ sudo postgresql-setup initdb
[sudo] password for CORP\layne.sadler: 
Initializing database ... OK


$ systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to usr/lib/systemd/system/postgresql.service.



$ systemctl start postgresql
[18:47:32]  /usr/bin ☯  systemctl status postgresql
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-03-05 18:47:32 EST; 7s ago
  Process: 25559 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 25553 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 25562 (postgres)
   CGroup: /system.slice/postgresql.service
           ├─25562 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
           ├─25564 postgres: logger process   
           ├─25566 postgres: checkpointer process   
           ├─25567 postgres: writer process   
           ├─25568 postgres: wal writer process   
           ├─25569 postgres: autovacuum launcher process   
           └─25570 postgres: stats collector process

$ passwd postgres  

メモ:/usr/bin/postgres -D /var/lib/pgsql/data -p 5432

閉じ込められた

$postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

$ psql
psql: FATAL:  role "CORP\layne.sadler" does not exist

$ sudo pg_ctl -D postgresql-setup initdb
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

# can't seem to login as su despite other sudo commands working

メモ:

  • オペレーティングシステムではそうだと主張していますrhel fedora centosが、ライブラリはありませんrhel-release
  • epel-releaseインストールがブロックされているようですdnf
  • ^^^ Postgresのインストール手順には上記のツールが必要です。

ベストアンサー1

CentOS(Community ENTerprise Operating System)は、Red Hat Enterprise Linux(RHEL)のコミュニティ(再)ビルドで、ブランディングやその他のいくつかの詳細が変更されました。これは、バグごとに完全にバイナリ互換性を可能にします。 RHELパッケージストアへのアクセス権がなく、独自のパッケージストアを使用します。 EPEL(Extra Packages for Enterprise Linux)は、RHELに含まれていないソフトウェアパッケージをRHEL / CentOSに提供するFedoraプロジェクトです。

「dnfのインストールがブロックされました」がどこから出てくるのかわかりません。 RHEL / CentOSでは、dnfは比較的新機能です(バージョン7以降の選択肢があると思います)。おそらく(以前)yumだけを使用できますか?yum install dnf必要なら試してみてください。特定のCentOSバージョンによってはまったく存在しない可能性があります。

引用した最後のエラーメッセージは非常に明確です。 Postgresはその設定を見つけることも読み取ることもできません。確認する注意深い設定が正しく完了しました。間違ったファイル名はすべてを台無しにする可能性があります。

おすすめ記事