Postgre Install
postgre ์ค์น
์ถ์ฒ: https://orashelter.tistory.com/56 [๋ฅ์ง]
- ์ค์น ๊ฐ๋ฅํ postgresql์ ๋ฒ์ ์ ํ์ธํฉ๋๋ค.
# yum list | grep ^postgresql
postgresql.i686 9.2.24-1.el7_5 base
postgresql.x86_64 9.2.24-1.el7_5 base
postgresql-contrib.x86_64 9.2.24-1.el7_5 base
postgresql-devel.i686 9.2.24-1.el7_5 base
postgresql-devel.x86_64 9.2.24-1.el7_5 base
postgresql-docs.x86_64 9.2.24-1.el7_5 base
postgresql-jdbc.noarch 9.2.1002-6.el7_5 base
postgresql-jdbc-javadoc.noarch 9.2.1002-6.el7_5 base
postgresql-libs.i686 9.2.24-1.el7_5 base
postgresql-libs.x86_64 9.2.24-1.el7_5 base
postgresql-odbc.x86_64 09.03.0100-2.el7 base
postgresql-plperl.x86_64 9.2.24-1.el7_5 base
postgresql-plpython.x86_64 9.2.24-1.el7_5 base
postgresql-pltcl.x86_64 9.2.24-1.el7_5 base
postgresql-server.x86_64 9.2.24-1.el7_5 base
postgresql-static.i686 9.2.24-1.el7_5 base
postgresql-static.x86_64 9.2.24-1.el7_5 base
postgresql-test.x86_64 9.2.24-1.el7_5 base
postgresql-upgrade.x86_64 9.2.24-1.el7_5 base
- ์ ์ฅ์๋ฅผ ์ ๋ฐ์ดํธ ํฉ๋๋ค. ( postgresql 11 ๋ฒ์ ์ค์น ํ ๊ฒ )
# yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
Loaded plugins: fastestmirror
pgdg-centos11-11-2.noarch.rpm | 5.6 kB 00:00:00
Examining /var/tmp/yum-root-PXjl9y/pgdg-centos11-11-2.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
Marking /var/tmp/yum-root-PXjl9y/pgdg-centos11-11-2.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================== Package Arch Version Repository Size
========================================================================================================================Installing:
pgdg-redhat-repo noarch 42.0-4 /pgdg-centos11-11-2.noarch 6.8 k
Transaction Summary
========================================================================================================================Install 1 Package
Total size: 6.8 k
Installed size: 6.8 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-redhat-repo-42.0-4.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-4.noarch 1/1
Installed:
pgdg-redhat-repo.noarch 0:42.0-4
Complete!
- postgresql ์ค์น ํฉ๋๋ค.
# yum install -y postgresql11-server postgresql11
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.jaist.ac.jp
* updates: ftp.iij.ad.jp
base | 3.6 kB 00:00:00
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.6.1810/extras/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: ftp.jaist.ac.jp; ์ ์ ์๋ ์ค๋ฅ"
Trying other mirror.
extras | 3.4 kB 00:00:00
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.postgresql.org; ์ ์ ์๋ ์ค๋ฅ"
Trying other mirror.
One of the configured repositories failed (PostgreSQL 10 7 - x86_64),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=pgdg10 ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable pgdg10
or
subscription-manager repos --disable=pgdg10
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=pgdg10.skip_if_unavailable=true
failure: repodata/repomd.xml from pgdg10: [Errno 256] No more mirrors to try.
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.postgresql.org; ์ ์ ์๋ ์ค๋ฅ"
- /etc/sysconfig/network-scripts/ifcfg-enp3s0 ์ network ์ ๋ณด ์์ (staic ip, DNS, NETMASK ..)
# yum update
# yum install -y postgresql11-server postgresql11
- ํจํค์ง๊ฐ ์ ๋๋ก ์ค์น๋์๋์ง ํ์ธํฉ๋๋ค.
# rpm -qa|grep postgresql
postgresql11-libs-11.2-2PGDG.rhel7.x86_64
postgresql11-server-11.2-2PGDG.rhel7.x86_64
postgresql11-11.2-2PGDG.rhel7.x86_64
- postgres ๊ณ์ ์ด ์๋์ง ํ์ธํฉ๋๋ค.
cat /etc/passwd | grep postgres
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
- postgresql ์ด๊ธฐํ ํฉ๋๋ค.
/usr/pgsql-11/bin/postgresql-11-setup initdb
Initializing database ...
OK
- ์๋น์ค ํ์ฑํ ๋ฐ ์ฌ์์ ํฉ๋๋ค.
# systemctl enable postgresql-11
# systemctl start postgresql-11
- postgresql ํจ์ค์๋๋ฅผ ๋ณ๊ฒฝํฉ๋๋ค.
# sudo passwd postgres
postgres ์ฌ์ฉ์์ ๋น๋ฐ ๋ฒํธ ๋ณ๊ฒฝ ์ค
์ ์ํธ:
์๋ชป๋ ์ํธ: ์ํธ๋ 8 ๊ฐ์ ๋ฌธ์ ๋ณด๋ค ์งง์ต๋๋ค
์ ์ํธ ์ฌ์
๋ ฅ:
passwd: ๋ชจ๋ ์ธ์ฆ ํ ํฐ์ด ์ฑ๊ณต์ ์ผ๋ก ์
๋ฐ์ดํธ ๋์์ต๋๋ค.
- postgresql ์ ์ ๋ฐ ์ค์น๋ ๋ฒ์ ํ์ธ ํฉ๋๋ค.
# su - postgres
-bash-4.2$
# psql
psql (11.2)
๋์๋ง์ ๋ณด๋ ค๋ฉด "help"๋ฅผ ์
๋ ฅํ์ญ์์ค.
postgres=#
# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 11.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1๊ฐ ํ)
- postgresql ์ค์ ๋ณ๊ฒฝ ํฉ๋๋ค.
# vi /var/lib/pgsql/11/data/postgresql.conf
#listen_addresses = 'localhost' -> listen_addresses = '*'
#password_encryption = md5 -> password_encryption = md5
- Centos7์ฉ PGDG๋ฅผ ๋ค์ด๋ก๋ ํฉ๋๋ค.
# yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
Loaded plugins: fastestmirror
pgdg-centos11-11-2.noarch.rpm | 5.6 kB 00:00:00
Examining /var/tmp/yum-root-PXjl9y/pgdg-centos11-11-2.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
/var/tmp/yum-root-PXjl9y/pgdg-centos11-11-2.noarch.rpm: does not update installed package.
Error: Nothing to do
- timescaledb๋ฅผ ๋ค์ด๋ก๋ ํฉ๋๋ค.
# 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
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
timescale_timescaledb/x86_64/signature | 833 B 00:00:00
Retrieving key from https://packagecloud.io/timescale/timescaledb/gpgkey
Importing GPG key 0x47F24417:
Userid : "https://packagecloud.io/timescale/timescaledb (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
Fingerprint: 1005 fb68 604c e9b8 f687 9cf7 59f1 8edf 47f2 4417
From : https://packagecloud.io/timescale/timescaledb/gpgkey
timescale_timescaledb/x86_64/signature | 1.0 kB 00:00:01 !!!
timescale_timescaledb/x86_64/primary | 4.2 kB 00:00:12
timescale_timescaledb 32/32
No packages marked for update
#yum install -y timescaledb-postgresql-11
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
Resolving Dependencies
--> Running transaction check
---> Package timescaledb-postgresql-11.x86_64 0:1.3.0-0.el7 will be installed
--> Processing Dependency: timescaledb-tools >= 0.3 for package: timescaledb-postgresql-11-1.3.0-0.el7.x86_64
--> Processing Dependency: postgresql11-devel for package: timescaledb-postgresql-11-1.3.0-0.el7.x86_64
--> Running transaction check
---> Package postgresql11-devel.x86_64 0:11.2-2PGDG.rhel7 will be installed
--> Processing Dependency: libicu-devel for package: postgresql11-devel-11.2-2PGDG.rhel7.x86_64
---> Package timescaledb-tools.x86_64 0:0.6.0-0.el7 will be installed
--> Running transaction check
---> Package libicu-devel.x86_64 0:50.1.2-17.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
timescaledb-postgresql-11 x86_64 1.3.0-0.el7 timescale_timescaledb 214 k
Installing for dependencies:
libicu-devel x86_64 50.1.2-17.el7 base 702 k
postgresql11-devel x86_64 11.2-2PGDG.rhel7 pgdg11 2.0 M
timescaledb-tools x86_64 0.6.0-0.el7 timescale_timescaledb 2.4 M
Transaction Summary
========================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 5.3 M
Installed size: 24 M
Downloading packages:
(1/4): libicu-devel-50.1.2-17.el7.x86_64.rpm | 702 kB 00:00:06
(2/4): postgresql11-devel-11.2-2PGDG.rhel7.x86_64.rpm | 2.0 MB 00:00:10
(3/4): timescaledb-tools-0.6.0-0.el7.x86_64.rpm | 2.4 MB 00:00:12
(4/4): timescaledb-postgresql-11-1.3.0-0.el7.x86_64.rpm | 214 kB 00:00:13
------------------------------------------------------------------------------------------------------------------------
Total 399 kB/s | 5.3 MB 00:00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libicu-devel-50.1.2-17.el7.x86_64 1/4
Installing : postgresql11-devel-11.2-2PGDG.rhel7.x86_64 2/4
Installing : timescaledb-tools-0.6.0-0.el7.x86_64 3/4
Installing : timescaledb-postgresql-11-1.3.0-0.el7.x86_64 4/4
Using pg_config located at /usr/pgsql-11/bin/pg_config to finish installation...
TimescaleDB has been installed. You need to update your postgresql.conf file
to load the library by adding 'timescaledb' to your shared_preload_libraries.
The easiest way to do this (and more configuration) is to use timescaledb-tune:
timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config
Verifying : timescaledb-postgresql-11-1.3.0-0.el7.x86_64 1/4
Verifying : timescaledb-tools-0.6.0-0.el7.x86_64 2/4
Verifying : libicu-devel-50.1.2-17.el7.x86_64 3/4
Verifying : postgresql11-devel-11.2-2PGDG.rhel7.x86_64 4/4
Installed:
timescaledb-postgresql-11.x86_64 0:1.3.0-0.el7
Dependency Installed:
libicu-devel.x86_64 0:50.1.2-17.el7 postgresql11-devel.x86_64 0:11.2-2PGDG.rhel7
timescaledb-tools.x86_64 0:0.6.0-0.el7
Complete!
- ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ค์ ํฉ๋๋ค. ( timescaledb-tune์ผ๋ก ์์ฝ๊ฒ ์ค์ ๊ฐ๋ฅ, ๋ชจ๋ yes )
# timescaledb-tune
or
# timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config
Using postgresql.conf at this path:
/var/lib/pgsql/11/data/postgresql.conf
Is this correct? [(y)es/(n)o]: y
Writing backup to:
/tmp/timescaledb_tune.backup201905071351
shared_preload_libraries needs to be updated
Current:
#shared_preload_libraries = ''
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]: yy^H
Tune memory/parallelism/WAL and other settings? [(y)es/(n)o]: y
Recommendations based on 3.63 GB of available memory and 2 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 = 950577kB
effective_cache_size = 2784MB
maintenance_work_mem = 475288kB
work_mem = 4752kB
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: memory settings will be updated
Parallelism settings recommendations
Current:
missing: timescaledb.max_background_workers
#max_worker_processes = 8
#max_parallel_workers_per_gather = 2
#max_parallel_workers = 8
Recommended:
timescaledb.max_background_workers = 8
max_worker_processes = 13
max_parallel_workers_per_gather = 1
max_parallel_workers = 2
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: parallelism settings will be updated
WAL settings recommendations
Current:
#wal_buffers = -1
min_wal_size = 80MB
max_wal_size = 1GB
Recommended:
wal_buffers = 16MB
min_wal_size = 4GB
max_wal_size = 8GB
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: WAL settings will be updated
Miscellaneous settings recommendations
Current:
#default_statistics_target = 100
#random_page_cost = 4.0
#checkpoint_completion_target = 0.5
#max_locks_per_transaction = 64
#effective_io_concurrency = 1
Recommended:
default_statistics_target = 500
random_page_cost = 1.1
checkpoint_completion_target = 0.9
max_locks_per_transaction = 64
effective_io_concurrency = 200
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: miscellaneous settings will be updated
Saving changes to: /var/lib/pgsql/11/data/postgresql.conf
- ๋ง์ฝ ์์ timescaledb-tune์ด ์๋์ ๊ฐ์ ์๋ฌ ๋ฐ์์ ์ง์ ์ค์ ํด์ผ ํฉ๋๋ค. ( ํด๊ฒฐ๋ฒ์ ์ฐพ์ง ๋ชปํ์.. ) -> 13๋ฒ์ ๋๋ฒ์งธ ๋ช ๋ น์ด๋ก
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]:
- ์ธ๋ถ์์๋ ์ ์ ๊ฐ๋ฅํ๊ฒ ์ ํ ํฉ๋๋ค. ( postgresql.conf ์์ )
#listen_addresses = 'localhost' -> listen_addresses = '*'
- ๋ง์ฐฌ๊ฐ์ง๋ก ์ธ๋ถ์์ ์ ์ ๊ฐ๋ฅํ๋๋ก ์ ํ ํฉ๋๋ค. ( pg_hba.conf ์์ )
# find / -name pg_hba.conf๋ก ์์น๋ฅผ ์ฐพ์์ ์์ ํฉ๋๋ค.
host all all 0.0.0.0/0 trust
- postgresql์ ์ฌ์์ํฉ๋๋ค.
systemctl restart postgresql-11
- postgresql ์ธ๋ถ ์ ์.
postgresql์ด ์ธ๋ถ์์ ์ ์์ด ๊ฐ๋ฅํ์ง๋ฅผ ํ์ธํ๊ธฐ ์ํด์๋ pgadmin4์ ๊ฐ์ ํด์ ์ด์ฉํด์ ์ ์ํ์ฌ ํ ์คํธ ํด๋ณผ ์ ์์ต๋๋ค.
๋ง์ฝ ์ ์์ด ์๋ ๊ฒฝ์ฐ ๋ฐฉํ๋ฒฝ์ ํด์ ํด๋ณด์๊ธธ ๋ฐ๋๋๋ค.
์ฐธ๊ณ
http://pseg.or.kr/pseg/infoinstall/7917
https://docs.timescale.com/v1.2/getting-started/installation/rhel-centos/installation-yum
์ถ์ฒ: https://orashelter.tistory.com/56 [๋ฅ์ง]