1. rpm다운로드
centos기본은 9.2 라서 rpm다운로드 받는다.
링크: https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/repoview/postgresqldbserver94.group.html
centos기본은 9.2 라서 rpm다운로드 받는다.
링크: https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/repoview/postgresqldbserver94.group.html
서버는 파일은 4개 모두 설치하고 클라이언트만 필요하면 다음 2개를 설치한다.
postgresql94 - PostgreSQL client programs and libraries
postgresql94-libs - The shared libraries required for any PostgreSQL clients
# mkdir rpms-postgres
[root@bidevdruidm2 data01]# cd rpms-postgres [root@bidevdruidm2 rpms]# ls -al total 5852 drwxr-xr-x 2 root root 226 2017-06-17 21:31 . drwxrwxrwx 3 root root 18 2017-06-17 21:31 .. -rw-r--r-- 1 root root 1099988 2017-06-17 21:29 postgresql94-9.4.12-1PGDG.rhel7.x86_64.rpm -rw-r--r-- 1 root root 632648 2017-06-17 21:29 postgresql94-contrib-9.4.12-1PGDG.rhel7.x86_64.rpm -rw-r--r-- 1 root root 217156 2017-06-17 21:29 postgresql94-libs-9.4.12-1PGDG.rhel7.x86_64.rpm -rw-r--r-- 1 root root 4031756 2017-06-17 21:29 postgresql94-server-9.4.12-1PGDG.rhel7.x86_64.rpm [root@bidevdruidm2 rpms]# rpm -ivh postgresql94* warning: postgresql94-9.4.12-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY Preparing... ################################# [100%] Updating / installing... 1:postgresql94-libs-9.4.12-1PGDG.rh################################# [ 25%] 2:postgresql94-9.4.12-1PGDG.rhel7 ################################# [ 50%] 3:postgresql94-contrib-9.4.12-1PGDG################################# [ 75%] 4:postgresql94-server-9.4.12-1PGDG.################################# [100%] |
2. data directory설정
# vi /usr/lib/systemd/system/postgresql-9.4.service
…
Environment=PGDATA=/data01/pgsql/data
…
|
3. data directory생성
# su postgres
bash-4.2$ mkdir -p /data01/pgsql/data bash-4.2$ ls -al total 0 drwxrwxrwx 4 root root 31 Jun 17 22:01 . dr-xr-xr-x. 18 root root 258 Jun 15 17:41 .. drwxr-xr-x 3 postgres postgres 18 Jun 17 22:01 pgsql |
4. db생성
# find / -name post*setup
/usr/pgsql-9.4/bin/postgresql94-setup # cd
# ./postgresql94-setup initdb
Initializing database ... OK # cat /var/lib/pgsql/9.4/initdb.log The files belonging to this database system will be owned by user "postgres". 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 /data01/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok creating template1 database in /data01/pgsql/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgSQL server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok syncing data to disk ... ok Success. You can now start the database server using: /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data/ or /usr/pgsql-9.4/bin/pg_ctl -D /data01/pgsql/data/ -l logfile start |
5. 기동
# systemctl enable postgresql-9.4
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.4.service to /usr/lib/systemd/system/postgresql-9.4.service. [root@bidevdruidm2 bin]# systemctl start postgresql-9.4 [root@bidevdruidm2 bin]# systemctl status postgresql-9.4 ● postgresql-9.4.service - PostgreSQL 9.4 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-06-17 22:14:39 KST; 4s ago Process: 3255 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS) Process: 3248 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) CGroup: /system.slice/postgresql-9.4.service ├─3257 /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data ├─3259 postgres: logger process ├─3261 postgres: checkpointer process ├─3262 postgres: writer process ├─3263 postgres: wal writer process ├─3264 postgres: autovacuum launcher process └─3265 postgres: stats collector process Jun 17 22:14:38 bidevdruidm2.bidevclust systemd[1]: Starting PostgreSQL 9.4 database server... Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.235 KST >LOG: could not bind IPv6 socket: Canno...dress Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.235 KST >HINT: Is another postmaster already ru...etry. Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.247 KST >LOG: redirecting log output to logging...ocess Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.247 KST >HINT: Future log output will appear in...log". Jun 17 22:14:39 bidevdruidm2.bidevclust systemd[1]: Started PostgreSQL 9.4 database server. Hint: Some lines were ellipsized, use -l to show in full.
# su - postgres
Last login: Sat Apr 15 13:42:39 KST 2017 on pts/0
-bash-4.2$ psql
psql (9.2.18)
Type "help" for help.
postgres=#
|
6. 인증 방식 변경
# su postgres
bash-4.2$ psql psql (9.4.12) Type "help" for help. postgres=# \password postgres Enter new password: Enter it again: postgres=# \q bash-4.2$ exit exit # vi /data01/pgsql/data/pg_hba.conf
…
# "local" is for Unix domain socket connections only
local all all md5 # IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 md5
…
|
7. listen ip 설정
# cp /data01/pgsql/data/postgresql.conf /data01/pgsql/data/postgresql.conf.bak
# vi /data01/pgsql/data/postgresql.conf …
listen_addresses = '*'
…
|
8. 서버 기동
# systemctl restart postgresql-9.4
# systemctl status postgresql-9.4 ● postgresql-9.4.service - PostgreSQL 9.4 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-06-17 22:21:48 KST; 3s ago Process: 3331 ExecStop=/usr/pgsql-9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast (code=exited, status=0/SUCCESS) Process: 3340 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS) Process: 3333 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) Main PID: 3342 (postgres) CGroup: /system.slice/postgresql-9.4.service ├─3342 /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data ├─3343 postgres: logger process ├─3345 postgres: checkpointer process ├─3346 postgres: writer process ├─3347 postgres: wal writer process ├─3348 postgres: autovacuum launcher process └─3349 postgres: stats collector process Jun 17 22:21:47 bidevdruidm2.bidevclust systemd[1]: Starting PostgreSQL 9.4 database server... Jun 17 22:21:47 bidevdruidm2.bidevclust pg_ctl[3340]: < 2017-06-17 22:21:47.576 KST >LOG: redirecting log output to logging...ocess Jun 17 22:21:47 bidevdruidm2.bidevclust pg_ctl[3340]: < 2017-06-17 22:21:47.576 KST >HINT: Future log output will appear in...log". Jun 17 22:21:48 bidevdruidm2.bidevclust systemd[1]: Started PostgreSQL 9.4 database server. Hint: Some lines were ellipsized, use -l to show in full. |
댓글 없음:
댓글 쓰기