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)는 RHEL(Red Hat Enterprise Linux)의 커뮤니티 (재)빌드이며 브랜딩 및 기타 몇 가지 세부 사항이 변경되었습니다. 이는 버그별로 완전히 바이너리 호환이 가능하도록 노력합니다. RHEL 패키지 저장소에 대한 액세스 권한이 없으며 자체 패키지 저장소를 사용합니다. EPEL(Extra Packages for Enterprise Linux)은 RHEL에 포함되지 않은 소프트웨어 패키지를 RHEL/CentOS에 제공하는 Fedora 프로젝트입니다.

"dnf 설치가 차단되었습니다"가 어디서 나오는지 모르겠습니다. RHEL/CentOS에서 dnf는 상대적으로 새로운 기능입니다(버전 7부터 대안이 있다고 생각합니다). 아마도 (이전) yum만 사용할 수 있을까요? yum install dnf필요하다면 시도해 보세요. 특정 CentOS 버전에 따라 전혀 존재하지 않을 수도 있습니다.

인용한 마지막 오류 메시지는 매우 명확합니다. Postgres는 해당 구성을 찾거나 읽을 수 없습니다. 확인하다주의 깊은설정이 올바르게 완료되었습니다. 잘못된 파일 이름은 모든 것을 망칠 수 있습니다.

관련 정보