오픈소스의 일상

#5. PostgreSQL 설정 본문

오픈소스/네이버클라우드

#5. PostgreSQL 설정

실버카미 2021. 12. 22. 09:11

1. 계정생성 및 비밀번호 변경

[root@flas ~]# su - postgres
Last login: Wed Dec 22 08:55:09 KST 2021 on pts/0

-- 사용자 생성
-bash-4.2$ createuser 사용자ID

-- 디비 생성 및 사용자 할당
-bash-4.2$ createdb flas_db -O 사용자ID

-bash-4.2$ psql -d flas_db
psql (11.14)
Type "help" for help.

-- 비밀번호 변경
flas_db=# alter user postgres with password '비밀번호';
ALTER ROLE

-- 비밀번호 변경
flas_db=# alter user 사용자ID with password '비밀번호';
ALTER ROLE

flas_db=#

2. 스키마 생성

[root@flas ~]# su - postgres
Last login: Wed Dec 22 17:24:02 KST 2021 on pts/0

-bash-4.2$ psql -d flas_db

psql (11.14)
Type "help" for help.

flas_db=# CREATE SCHEMA "kois" AUTHORIZATION "flas_gis";
CREATE SCHEMA

flas_db=# COMMENT ON SCHEMA "kois" IS '산지분석영역';
COMMENT

flas_db=#

3. 테이블스페이스 생성

[root@flas ~]# su - postgres
Last login: Wed Dec 22 17:24:02 KST 2021 on pts/0

-bash-4.2$ psql -d flas_db

psql (11.14)
Type "help" for help.

flas_db=# CREATE TABLESPACE flas_tot_dat OWNER flas_gis LOCATION '/sdata/postgres/pg_tbs/';
CREATE TABLESPACE
flas_db=# COMMENT ON TABLESPACE flas_tot_dat IS '산지분석서비스';
COMMENT
flas_db=#

4. 외부접속 허용

[root@flas data]# vi /var/lib/pgsql/11/data/postgresql.conf
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'
port = 5432
max_connections = 100

[root@flas data]# vi /var/lib/pgsql/11/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

# IPv6 local connections:
host    all             all             ::1/128                 trust

# Allow replication connections from localhost, by a user with the
# replication privilege.
host    all			    all             *.*.*.*/32         trust

 

 

728x90