PostgreSQL
December 4, 2022
Создание кластера PostgreSQL 15 из официального репозитория
Самый частый способ инсталляции ПО PostgreSQL если это не Managed решение.
Выбираем пакет для нужной ОС: https://www.postgresql.org/download/
В моём случае это Ubuntu 20.04.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get -y install postgresql
systemctl status postgresql ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Sun 2022-12-04 06:52:36 UTC; 16min ago Main PID: 2974 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 2310) Memory: 0B CGroup: /system.slice/postgresql.service
Посмотрим с какой конфигурацией был создан кластер
pg_config BINDIR = /usr/lib/postgresql/15/bin DOCDIR = /usr/share/doc/postgresql-doc-15 HTMLDIR = /usr/share/doc/postgresql-doc-15 INCLUDEDIR = /usr/include/postgresql PKGINCLUDEDIR = /usr/include/postgresql INCLUDEDIR-SERVER = /usr/include/postgresql/15/server LIBDIR = /usr/lib/x86_64-linux-gnu PKGLIBDIR = /usr/lib/postgresql/15/lib LOCALEDIR = /usr/share/locale MANDIR = /usr/share/postgresql/15/man SHAREDIR = /usr/share/postgresql/15 SYSCONFDIR = /etc/postgresql-common PGXS = /usr/lib/postgresql/15/lib/pgxs/src/makefiles/pgxs.mk CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' '--mandir=/usr/share/postgresql/15/man' '--docdir=/usr/share/doc/postgresql-doc-15' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/15' '--bindir=/usr/lib/postgresql/15/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 15.1-1.pgdg20.04+1)' '--enable-nls' '--enable-thread-safety' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-gssapi' '--with-ldap' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'AWK=mawk' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' 'PYTHON=/usr/bin/python3' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--enable-tap-tests' '--with-icu' '--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-10' 'CLANG=/usr/bin/clang-10' '--with-lz4' '--with-zstd' '--with-systemd' '--with-selinux' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' CC = gcc CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer CFLAGS_SL = -fPIC LDFLAGS = -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-10/lib -Wl,--as-needed LDFLAGS_EX = LDFLAGS_SL = LIBS = -lpgcommon -lpgport -lselinux -lzstd -llz4 -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lpthread -lrt -ldl -lm VERSION = PostgreSQL 15.1 (Ubuntu 15.1-1.pgdg20.04+1)
sudo pg_ctlcluster 15 main status pg_ctl: server is running (PID: 3271) /usr/lib/postgresql/15/bin/postgres "-D" "/var/lib/postgresql/15/main" "-c" "config_file=/etc/postgresql/15/main/postgresql.conf"
sudo -i -u postgres psql
postgres=# \db List of tablespaces Name | Owner | Location ------------+----------+---------- pg_default | postgres | pg_global | postgres | (2 rows)
Выходим из консоли PostgreSQL - \q
Выходим из пользователя postgres - exit
Включим проверку контрольных сумм
sudo systemctl stop postgresql cd /usr/lib/postgresql/15/bin sudo ./pg_checksums -e --pgdata=/var/lib/postgresql/15/main
Проверяем контрольные суммы на выключенном кластере
sudo ./pg_checksums -c --pgdata=/var/lib/postgresql/15/main Checksum operation completed Files scanned: 946 Blocks scanned: 2811 Bad checksums: 0 Data checksum version: 1
sudo systemctl start postgresql sudo systemctl status postgresql
December 4, 2022, 08:04
0 views
0 reposts