티스토리 뷰


1. 설치 가능한 postgresql의 버전을 확인합니다.

yum list | grep ^postgresql


2. 저장소를 업데이트 합니다. ( postgresql 11 버전 설치 할것 )

yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm


3. postgresql 설치 합니다.

yum install -y postgresql11-server postgresql11


4. 패키지가 제대로 설치되었는지 확인합니다.

rpm -qa|grep postgresql


5. postgres 계정이 있는지 확인합니다.

cat /etc/passwd | grep postgres


6. postgresql 초기화 합니다.

/usr/pgsql-11/bin/postgresql-11-setup initdb


7. 서비스 활성화 및 재시작 합니다.

systemctl enable postgresql-11

systemctl start postgresql-11


8. postgresql 패스워드를 변경합니다.

sudo passwd postgres


9. postgresql 접속 및 설치된 버전 확인 합니다.

su - postgres

psql

select version();


10. postgresql 설정 변경 합니다.

vi /var/lib/pgsql/11/data/postgresql.conf


#listen_addresses = 'localhost'  ->  listen_addresses = '*'

#password_encryption = md5  ->  password_encryption = md5


11. Centos7용 PGDG를 다운로드 합니다.

yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm


12. timescaledb를 다운로드 합니다.

# Add our repo

sudo cat > /etc/yum.repos.d/timescale_timescaledb.repo <<EOL

[timescale_timescaledb]

name=timescale_timescaledb

baseurl=https://packagecloud.io/timescale/timescaledb/el/7/\$basearch

repo_gpgcheck=1

gpgcheck=0

enabled=1

gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey

sslverify=1

sslcacert=/etc/pki/tls/certs/ca-bundle.crt

metadata_expire=300

EOL

sudo yum update -y


# Now install appropriate package for PG version

yum install -y timescaledb-postgresql-11

13. 데이터베이스를 설정합니다. ( timescaledb-tune으로 손쉽게 설정 가능, 모두 yes )

timescaledb-tune


13-1. timescaledb-tune으로 실행이 안될경우 (centos에서만 문제 발생하였음, 우분투는 위의 방식대로 사용가능)

sudo timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config

이렇게 timescaledb-tune을 실행할 수 있는것을 찾아냈습니다.



14. 만약 위의 timescaledb-tune이 아래와 같은 에러 발생시 직접 설정해야 합니다. ( 해결법을 찾지 못했음.. )

exit: could not execute `pg_config --version`: exec: "pg_config": executable file not found in $PATH


아래와 같이 치면 postgresql.conf의 위치를 찾을 수 있음. 

find / -name postgresql.conf


아래의 모습은 timescaledb-tune으로 설정시 나오는 화면인데 직접 찾아서 하나하나 수정하면 됨. ( 수정 전 미리 기존 설정 파일을 복사 두는것을 추천 )

Using postgresql.conf at this path:

/usr/local/var/postgres/postgresql.conf


Is this correct? [(y)es/(n)o]: y

Writing backup to:

/var/folders/cr/zpgdkv194vz1g5smxl_5tggm0000gn/T/timescaledb_tune.backup201901071520


shared_preload_libraries needs to be updated

Current:

#shared_preload_libraries = 'timescaledb'

Recommended:

shared_preload_libraries = 'timescaledb'

Is this okay? [(y)es/(n)o]: y

success: shared_preload_libraries will be updated


Tune memory/parallelism/WAL and other settings? [(y)es/(n)o]: y

Recommendations based on 8.00 GB of available memory and 4 CPUs for PostgreSQL 11


Memory settings recommendations

Current:

shared_buffers = 128MB

#effective_cache_size = 4GB

#maintenance_work_mem = 64MB

#work_mem = 4MB

Recommended:

shared_buffers = 2GB

effective_cache_size = 6GB

maintenance_work_mem = 1GB

work_mem = 26214kB

Is this okay? [(y)es/(s)kip/(q)uit]:


15. 외부에서도 접속 가능하게 셋팅합니다. ( postgresql.conf 수정 )

#listen_addresses = 'localhost'  ->  listen_addresses = '*'


16. 마찬가지로 외부에서 접속 가능하도록 셋팅합니다. ( pg_hba.conf 수정 )

find / -name pg_hba.conf로 위치를 찾아서 수정합니다.

host all all 0.0.0.0/0 trust


16. postgresql을 재시작합니다.

systemctl restart postgresql-11


17. postgresql 외부 접속.

postgresql이 외부에서 접속이 가능한지를 확인하기 위해서는 pgadmin4와 같은 툴을 이용해서 접속하여 테스트 해볼 수 있습니다.

만약 접속이 안될경우 방화벽을 해제 해보시길 바랍니다.




참고

http://pseg.or.kr/pseg/infoinstall/7917

https://docs.timescale.com/v1.2/getting-started/installation/rhel-centos/installation-yum

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함