3.1 postgresql, postgis 설치

 

$ sudo apt install postgresql postgresql-contrib postgis postgresql-12-postgis-3 postgresql-12-postgis-3-scripts

 

 

 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libgmpxx4ldbl libllvm10 libpopt0 libprotobuf-c1 libsensors-config libsensors5 libsfcgal1
  libxslt1.1 locales logrotate postgis-doc postgresql-12 postgresql-client-12
  postgresql-client-common postgresql-common sysstat
Suggested packages:
  lm-sensors bsd-mailx | mailx postgis-gui postgresql-doc postgresql-doc-12 libjson-perl isag
The following NEW packages will be installed:
  libgmpxx4ldbl libllvm10 libpopt0 libprotobuf-c1 libsensors-config libsensors5 libsfcgal1
  libxslt1.1 locales logrotate postgis postgis-doc postgresql postgresql-12
  postgresql-12-postgis-3 postgresql-12-postgis-3-scripts postgresql-client-12
  postgresql-client-common postgresql-common postgresql-contrib sysstat
0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 43.8 MB of archives.
After this operation, 197 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libpopt0 amd64 1.16-14 [26.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 locales all 2.31-0ubuntu9.16 [3871 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 logrotate amd64 3.14.0-4ubuntu3 [44.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgmpxx4ldbl amd64 2:6.2.0+dfsg-4ubuntu0.1 [9144 B]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 libllvm10 amd64 1:10.0.0-4ubuntu1 [15.3 MB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 libprotobuf-c1 amd64 1.3.3-1ubuntu0.1 [19.3 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsensors-config all 1:3.6.0-2ubuntu1.1 [6052 B]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsensors5 amd64 1:3.6.0-2ubuntu1.1 [27.2 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/universe amd64 libsfcgal1 amd64 1.3.7-4ubuntu3 [1926 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxslt1.1 amd64 1.1.34-4ubuntu0.20.04.1 [151 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/universe amd64 postgis amd64 3.0.0+dfsg-6ubuntu4 [305 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/universe amd64 postgis-doc all 3.0.0+dfsg-6ubuntu4 [2630 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-client-common all 214ubuntu0.1 [28.2 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-client-12 amd64 12.20-0ubuntu0.20.04.1 [1055 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-common all 214ubuntu0.1 [169 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-12 amd64 12.20-0ubuntu0.20.04.1 [13.5 MB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql all 12+214ubuntu0.1 [3924 B]
Get:18 http://archive.ubuntu.com/ubuntu focal/universe amd64 postgresql-12-postgis-3-scripts all 3.0.0+dfsg-6ubuntu4 [1075 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/universe amd64 postgresql-12-postgis-3 amd64 3.0.0+dfsg-6ubuntu4 [3194 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-contrib all 12+214ubuntu0.1 [3932 B]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 sysstat amd64 12.2.0-2ubuntu0.3 [448 kB]
Fetched 43.8 MB in 12s (3512 kB/s)                                                            
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpopt0:amd64.
(Reading database ... 54256 files and directories currently installed.)
Preparing to unpack .../00-libpopt0_1.16-14_amd64.deb ...
Unpacking libpopt0:amd64 (1.16-14) ...
Selecting previously unselected package locales.
Preparing to unpack .../01-locales_2.31-0ubuntu9.16_all.deb ...
Unpacking locales (2.31-0ubuntu9.16) ...
Selecting previously unselected package logrotate.
Preparing to unpack .../02-logrotate_3.14.0-4ubuntu3_amd64.deb ...
Unpacking logrotate (3.14.0-4ubuntu3) ...
Selecting previously unselected package libgmpxx4ldbl:amd64.
Preparing to unpack .../03-libgmpxx4ldbl_2%3a6.2.0+dfsg-4ubuntu0.1_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:6.2.0+dfsg-4ubuntu0.1) ...
Selecting previously unselected package libllvm10:amd64.
Preparing to unpack .../04-libllvm10_1%3a10.0.0-4ubuntu1_amd64.deb ...
Unpacking libllvm10:amd64 (1:10.0.0-4ubuntu1) ...
Selecting previously unselected package libprotobuf-c1:amd64.
Preparing to unpack .../05-libprotobuf-c1_1.3.3-1ubuntu0.1_amd64.deb ...
Unpacking libprotobuf-c1:amd64 (1.3.3-1ubuntu0.1) ...
Selecting previously unselected package libsensors-config.
Preparing to unpack .../06-libsensors-config_1%3a3.6.0-2ubuntu1.1_all.deb ...
Unpacking libsensors-config (1:3.6.0-2ubuntu1.1) ...
Selecting previously unselected package libsensors5:amd64.
Preparing to unpack .../07-libsensors5_1%3a3.6.0-2ubuntu1.1_amd64.deb ...
Unpacking libsensors5:amd64 (1:3.6.0-2ubuntu1.1) ...
Selecting previously unselected package libsfcgal1.
Preparing to unpack .../08-libsfcgal1_1.3.7-4ubuntu3_amd64.deb ...
Unpacking libsfcgal1 (1.3.7-4ubuntu3) ...
Selecting previously unselected package libxslt1.1:amd64.
Preparing to unpack .../09-libxslt1.1_1.1.34-4ubuntu0.20.04.1_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.34-4ubuntu0.20.04.1) ...
Selecting previously unselected package postgis.
Preparing to unpack .../10-postgis_3.0.0+dfsg-6ubuntu4_amd64.deb ...
Unpacking postgis (3.0.0+dfsg-6ubuntu4) ...
Selecting previously unselected package postgis-doc.
Preparing to unpack .../11-postgis-doc_3.0.0+dfsg-6ubuntu4_all.deb ...
Unpacking postgis-doc (3.0.0+dfsg-6ubuntu4) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../12-postgresql-client-common_214ubuntu0.1_all.deb ...
Unpacking postgresql-client-common (214ubuntu0.1) ...
Selecting previously unselected package postgresql-client-12.
Preparing to unpack .../13-postgresql-client-12_12.20-0ubuntu0.20.04.1_amd64.deb ...
Unpacking postgresql-client-12 (12.20-0ubuntu0.20.04.1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../14-postgresql-common_214ubuntu0.1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (214ubuntu0.1) ...
Selecting previously unselected package postgresql-12.
Preparing to unpack .../15-postgresql-12_12.20-0ubuntu0.20.04.1_amd64.deb ...
Unpacking postgresql-12 (12.20-0ubuntu0.20.04.1) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../16-postgresql_12+214ubuntu0.1_all.deb ...
Unpacking postgresql (12+214ubuntu0.1) ...
Selecting previously unselected package postgresql-12-postgis-3-scripts.
Preparing to unpack .../17-postgresql-12-postgis-3-scripts_3.0.0+dfsg-6ubuntu4_all.deb ...
Unpacking postgresql-12-postgis-3-scripts (3.0.0+dfsg-6ubuntu4) ...
Selecting previously unselected package postgresql-12-postgis-3.
Preparing to unpack .../18-postgresql-12-postgis-3_3.0.0+dfsg-6ubuntu4_amd64.deb ...
Unpacking postgresql-12-postgis-3 (3.0.0+dfsg-6ubuntu4) ...
Selecting previously unselected package postgresql-contrib.
Preparing to unpack .../19-postgresql-contrib_12+214ubuntu0.1_all.deb ...
Unpacking postgresql-contrib (12+214ubuntu0.1) ...
Selecting previously unselected package sysstat.
Preparing to unpack .../20-sysstat_12.2.0-2ubuntu0.3_amd64.deb ...
Unpacking sysstat (12.2.0-2ubuntu0.3) ...
Setting up postgresql-12-postgis-3-scripts (3.0.0+dfsg-6ubuntu4) ...
update-alternatives: using /usr/share/postgresql/12/extension/postgis-3.control to provide /usr/share/postgresql/12/extension/postgis.control (postgresql-12-postgis.control) in auto mode
Setting up postgresql-client-common (214ubuntu0.1) ...
Setting up libsensors-config (1:3.6.0-2ubuntu1.1) ...
Setting up postgis (3.0.0+dfsg-6ubuntu4) ...
Setting up locales (2.31-0ubuntu9.16) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Generating locales (this might take a while)...
Generation complete.
Setting up libprotobuf-c1:amd64 (1.3.3-1ubuntu0.1) ...
Setting up libllvm10:amd64 (1:10.0.0-4ubuntu1) ...
Setting up postgis-doc (3.0.0+dfsg-6ubuntu4) ...
Setting up postgresql-client-12 (12.20-0ubuntu0.20.04.1) ...
update-alternatives: using /usr/share/postgresql/12/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up libgmpxx4ldbl:amd64 (2:6.2.0+dfsg-4ubuntu0.1) ...
Setting up postgresql-common (214ubuntu0.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libsensors5:amd64 (1:3.6.0-2ubuntu1.1) ...
Setting up libxslt1.1:amd64 (1.1.34-4ubuntu0.20.04.1) ...
Setting up libsfcgal1 (1.3.7-4ubuntu3) ...
Setting up postgresql-12 (12.20-0ubuntu0.20.04.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Creating new PostgreSQL cluster 12/main ...
/usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main --auth-local peer --auth-host md5
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 "C.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 /var/lib/postgresql/12/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Seoul
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctlcluster 12 main start

Ver Cluster Port Status Owner    Data directory              Log file
12  main    5432 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
update-alternatives: using /usr/share/postgresql/12/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up sysstat (12.2.0-2ubuntu0.3) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline

Creating config file /etc/default/sysstat with new version
update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/sar.1.gz because associated file /usr/share/man/man1/sar.sysstat.1.gz (of link group sar) doesn't exist
Setting up libpopt0:amd64 (1.16-14) ...
Setting up logrotate (3.14.0-4ubuntu3) ...
Setting up postgresql-12-postgis-3 (3.0.0+dfsg-6ubuntu4) ...
Setting up postgresql-contrib (12+214ubuntu0.1) ...
Setting up postgresql (12+214ubuntu0.1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.16) ...
$

 

 

 

 

3.2 postgresql 시작

 

sudo service postgresql start 

 

$ sudo service postgresql start
 * Starting PostgreSQL 12 database server                                               [ OK ] 
$

 

 

3.3 계정 및 디비 생성

 

postgres  사용자로 변경

$ sudo -u postgres -i
postgres@48efa0ebd424:~$

 

 

디비 터미널 접속

postgres@48efa0ebd424:~$ psql
psql (12.20 (Ubuntu 12.20-0ubuntu0.20.04.1))
Type "help" for help.

 

 

 

디비 사용자 생성

postgres=# create user renderaccount password '비밀번호' superuser;
CREATE ROLE

 

사용자 확인

postgres=# \du
                                     List of roles
   Role name   |                         Attributes                         | Member of 
---------------+------------------------------------------------------------+-----------
 postgres      | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 renderaccount | Superuser                                                  | {}

 

gis 데이터베이스 생성

postgres=# create database gis owner renderaccount;
CREATE DATABASE

 

gis 데이터베이스에 접속

postgres=# \c gis
You are now connected to database "gis" as user "postgres".
gis=#

 

 

extension 생성

gis=# create extension postgis;
CREATE EXTENSION
gis=# create extension hstore;
CREATE EXTENSION

 

alter table 

gis=# alter table geometry_columns owner to renderaccount;
ALTER TABLE
gis=# alter table spatial_ref_sys owner to renderaccount;
ALTER TABLE

 

postgresql 을 빠져나온다.

gis=# \q
postgres@48efa0ebd424:~$ exit
logout
$

 

 

 

 

 

 

 

 

 

 

 

 

블로그 이미지

엘로드넷

,