Dico

CentOS6.9 PostgreSQL 소스 설치

  • 민갤

PostgreSQL

1. 필수 유틸 설치

# yum install -y compat-readline43 readline-devel crypto-utils.* openssl* pam-devel

2. 다운로드 및 설치

# cd /usr/local/src
src]# wget https://ftp.postgresql.org/pub/source/v10.2/postgresql-10.2.tar.gz
src]# tar xzf postgresql-10.2.tar.gz
src]# cd postgresql-10.2
postgresql-10.2]# ./configure --prefix=/usr/local/pgsql
postgresql-10.2]# make && make install

config.status: linking src/makefiles/Makefile.linux to src/Makefile.port                              // configure

All of PostgreSQL successfully made. Ready to install                                                            // make

PostgreSQL installation complete.                                                                                             // make install

3. 사용자 추가 및 권한 부여

# useradd postgres
# chown -R postgres:postgres /usr/local/pgsql

4. DB 초기화

# cd /usr/local/pgsql/bin
bin]# su postgres
bin]$ ./initdb -D /usr/local/pgsql/data

Success. You can now start the database server using:

./pg_ctl -D /usr/local/pgsql/data -l logfile start

5. 기동

bin]$ ./pg_ctl start -D /usr/local/pgsql/data
(...)
server started
bin]$ ./pg_ctl status -D /usr/local/pgsql/data
pg_ctl: server is running (PID: 15299)
/usr/local/pgsql/bin/postgres “-D” “/usr/local/pgsql/data”

6. 접속

bin]$ ./psql
psql (10.2)
Type “help” for help.

postgres=#

7. 사용자 및 데이터베이스 생성

postgres=# CREATE USER test WITH PASSWORD ‘12345’;
CREATE ROLE
postgres=# SELECT * FROM pg_shadow;
usename  | usesysid | usecreatedb | usecuper | userepl | usebypassrls | password | valuntil | useconfig
-------------+-------------+-----------------+-------------+-----------+------------------+-------------+----------+---------------
postgress |      10 | t           | t        | t      | t
test      |   16384 | f           | f        | f      | f             | 3d0a419c1fa1f990819278323fdc | | 
(2 rows)
postgres=# CREATE DATABASE test;
CREATE DATABASE
postgres=# \q
bin]$

8. 테이블 생성

bin]$ ./psql -U test test
psql (10.2)
Type “help” for help.

test=> CREATE TABLE test (no integer, name varchar(20));
CREATE TABLE
test-> INSERT INTO test (no, name) VALUES (4, ‘post’);
INSERT 0 1
test=>  SELECT * FROM test;
  no   |  name 
-------+---------
     4  |  post
(1 row)

test=>  \q

#. 서비스 없이 start, stop

bin]$ ./pg_ctl start -D /usr/local/pgsql/data
bin]$ ./pg_ctl stop -D /usr/local/pgsql/data