Bii o ṣe le Fi sii PostgreSQL 10 Lilo koodu Orisun ni Lainos


PostgreSQL tun pe ni Postgres jẹ alagbara ati ṣiṣi orisun eto data ibatan ibatan nkan-ibatan. O jẹ ibi ipamọ data ipele ti ile-iṣẹ ti o ni awọn ẹya bii gbigbasilẹ ṣiwaju fun ifarada ẹbi, idapada asynchronous, Multi-Version Concurrency Iṣakoso (MVCC), awọn afẹyinti ayelujara/gbona, tọka si imularada akoko, oluṣewadii ibeere/iṣapeye, awọn aaye tabili, awọn iṣowo ti itẹ-ẹiyẹ (awọn aaye ifipamọ) ) ati be be lo.

Postgres ni ẹya tuntun rẹ 10 ti o jade ni 5th Oṣu Kẹwa 2017 nipasẹ ẹgbẹ idagbasoke agbaye postgres.

Awọn ẹya ti ẹya Tuntun jẹ atẹle:

  • Idahun Logbon: Ẹya yii n jẹ ki ẹda ti awọn ohun ipamọ data kọọkan (jẹ awọn ori ila, awọn tabili, tabi awọn apoti isura data yiyan) kọja awọn olupin imurasilẹ. O pese iṣakoso diẹ sii lori atunse data. Ti a ṣe imuse nipasẹ lilo awoṣe iforukọsilẹ olukọ-iwe.
  • Ifaramọ Quorum fun Iṣisọpọ Iṣisọpọ: Ninu ẹya yii, dba le ṣe bayi nọmba ti imurasilẹ ti o gba pe awọn ayipada si ibi ipamọ data ti ṣe, ki a le gbero data ni kikọ lailewu.
  • Ijẹrisi SCRAM-SHA-256: Aabo ti o dara si ijẹrisi ati ibi ipamọ ọrọ orisun MD5 ti o wa tẹlẹ.
  • Imudara ibeere ibeere ti o jọra.
  • Tipa ipin tabili tabili ipin.
  • Atilẹyin wiwa ọrọ ni kikun fun JSON ati JSONB.

Ninu àpilẹkọ yii, a yoo ṣalaye bi o ṣe le fi sori ẹrọ PostgreSQL 10 nipa lilo fifi sori koodu orisun ni awọn ọna Linux. Awọn ti n wa fifi sori ẹrọ rọrun lati oluṣakoso package pinpin wọn le tẹle awọn itọsọna isalẹ yii.

  1. Bii o ṣe le Fi PostgreSQL 10 sori CentOS/RHEL ati Fedora
  2. Bii a ṣe le Fi PostgreSQL 10 sori Debian ati Ubuntu

Fi PostgreSQL Lo Kaadi Orisun

Bii postgres jẹ ibi ipamọ data orisun, o le kọ lati koodu orisun gẹgẹbi awọn aini/awọn ibeere eniyan. a le ṣe akanṣe ikole ati ilana fifi sori ẹrọ nipa fifun ọkan tabi diẹ ẹ sii awọn aṣayan laini aṣẹ fun ọpọlọpọ awọn ẹya afikun.

Anfani nla ti lilo fifi sori koodu orisun ni o le jẹ adani ga julọ lakoko fifi sori ẹrọ.

1. Akọkọ fi awọn ohun ti a beere fun ti a beere sii bii gcc, kika-devel ati zlib-devel ni lilo oluṣakoso package bi a ti han.

# yum install gcc zlib-devel readline-devel     [On RHEL/CentOS]
# apt install gcc zlib1g-dev libreadline6-dev   [On Debian/Ubuntu]

2. Ṣe igbasilẹ faili oda koodu orisun lati aṣẹ wget osise ni taara lori eto.

# wget https://ftp.postgresql.org/pub/source/v10.0/postgresql-10.0.tar.bz2

3. Lo pipaṣẹ oda lati jade faili tarball ti o gbasilẹ. Ilana tuntun ti a npè ni postgresql-10.0 yoo ṣẹda.

# tar -xvf postgresql-10.0.tar.bz2
# ll
total 19236
-rw-------. 1 root root      933 Mar 18  2015 anaconda-ks.cfg
-rw-r--r--. 1 root root     8823 Mar 18  2015 install.log
-rw-r--r--. 1 root root     3384 Mar 18  2015 install.log.syslog
drwxrwxrwx  6 1107 1107     4096 Oct  3  2017 postgresql-10.0
-rw-r--r--  1 root root 19639147 Oct  3  2017 postgresql-10.0.tar.bz2

4. Igbese ti o tẹle fun ilana fifi sori ẹrọ ni lati tunto koodu orisun ti o gbasilẹ nipasẹ yiyan awọn aṣayan gẹgẹbi awọn aini rẹ.

# cd postgresql-10.0

lo ./configure --help lati gba iranlọwọ nipa awọn aṣayan lọpọlọpọ.

# ./configure --help

Defaults for the options are specified in brackets.
Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/pgsql]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

5. Bayi ṣẹda itọsọna nibiti o fẹ fi awọn faili postgres sori ẹrọ ati lo aṣayan prefix pẹlu atunto.

# mkdir /opt/PostgreSQL-10/
# ./configure --prefix=/opt/PostgreSQL-10
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
....

6. Lẹhin atunto, atẹle a yoo bẹrẹ lati kọ postgreSQL nipa lilo atẹle pipaṣẹ.

# make

Lẹhin ilana ilana pari, ni bayi fi sori ẹrọ postgresql nipa lilo pipaṣẹ atẹle.

# make install

Ti fi sii Postgresql 10 ni/opt/PostgreSQL-10 liana.

7. Bayi ṣẹda olumulo postgres ati itọsọna lati ṣee lo bi itọsọna data fun ipilẹ iṣupọ data. Ti o ni itọsọna data yii yẹ ki o jẹ olumulo postgres ati awọn igbanilaaye yẹ ki o jẹ 700 ati tun ṣeto ọna fun awọn binaries postgresql fun irọrun wa.

# useradd postgres
# passwd postgres
# mkdir /pgdatabase/data
# chown -R postgres. /pgdatabase/data
# echo 'export PATH=$PATH:/opt/PostgreSQL-10/bin' > /etc/profile.d/postgres.sh

8. Bayi ṣe ipilẹ data nipa lilo pipaṣẹ atẹle bi olumulo postgres ṣaaju lilo eyikeyi awọn aṣẹ postgres.

# su postgres
$ initdb -D /pgdatabase/data/ -U postgres -W

Nibo -D jẹ ipo fun iṣupọ data yii tabi a le sọ pe itọsọna data ni ibiti a fẹ ṣe ipilẹ iṣupọ data, -U fun orukọ superuser database ati - W fun tọ ọrọ igbaniwọle fun db superuser.

Fun alaye diẹ sii ati awọn aṣayan a le tọka initdb –help.

9. Lẹhin ibẹrẹ ipilẹ data, bẹrẹ iṣupọ data tabi ti o ba nilo lati yipada ibudo tabi tẹtisi adirẹsi fun olupin, satunkọ faili postgresql.conf ninu itọsọna data ti olupin data.

$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log start

10. Lẹhin ti bẹrẹ ipilẹ data, jẹrisi ipo ti ilana olupin postgres nipa lilo awọn ofin atẹle.

$ ps -ef |grep -i postgres
$ netstat -apn |grep -i 51751

A le rii pe iṣupọ data nṣiṣẹ dara, ati pe awọn akọọlẹ ibẹrẹ ni a le rii ni ipo ti a ṣalaye pẹlu aṣayan -l lakoko ti o bẹrẹ iṣupọ data.

11. Bayi sopọ si iṣupọ data data ki o ṣẹda ipilẹ data nipa lilo awọn ofin atẹle.

$ psql -p 51751
postgres=# create database test;
postgres=# \l to list all databases in cluster
postgres=# \q to quit form postgres console

O n niyen! Ninu awọn nkan wa ti n bọ, Emi yoo bo iṣeto ni, iṣeto ẹda ati fifi sori ẹrọ ti pgAdmin ọpa, titi di igba naa ki o wa ni aifwy si Tecmint.