Установка в ОС семейства Linux
Окружение
В операционной системе перед выполнением развёртывания по текущей инструкции должны присутствовать следующие программы:
-
openssl— программа управления сертификатами; -
tar— программа архивирования; -
psql— CLI клиент из состава PostgresPro Standard/Ent Cert; -
nginx— веб-сервер; -
PostgresPro Standard/Standard Cert/Ent Cert — СУБД;
-
python— интерпретатор языка; -
haproxy— балансировщик; -
keepalived— отказоустойчивый кластер; -
zstd— программа сжатия данных; -
chrony— программа синхронизации времени.
| Установка указанных программ выходит за границы текущей инструкции и описана в справочных руководствах, идущих в комплекте с операционной системой Linux, на которой производится развёртывание. |
Перед непосредственным выполнением действий из разделов 3.3.3 и далее, необходимо загрузить архив S3Gateway-distrib-*.tar.gz на сервер в домашнюю директорию пользователя root.
Предварительные настройки
Проверка версии ядра ОС
Проверьте версию ядра ОС:
uname -r
Если версия ядра ниже 6.1.52-1.el7.3.x86_64, обновите его:
dnf update -y
dnf install redos-kernels6-release -y
dnf makecache
dnf update -y
Выключение Selinux и смена профиля производительности
Для отключения Selinux и смены профиля производительности:
-
Выполните команды:
sed -i "s/SELINUX=enforcing/SELINUX=permissive/" /etc/selinux/config setenforce 0 tuned-adm profile throughput-performance -
Перезагрузите сервер:
reboot
Настройка службы синхронизации времени
Чтобы настроить службу синхронизации:
-
Выполните команду:
cat > /etc/chrony.conf << EOF server <Адрес сервера NTP> iburst server <Адрес сервера NTP> iburst # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 # Enable kernel synchronization of the real-time clock (RTC). rtcsync # Specify file containing keys for NTP authentication. keyfile /etc/chrony.keys # Save NTS keys and cookies. ntsdumpdir /var/lib/chrony # Get TAI-UTC offset and leap seconds from the system tz database. leapsectz right/UTC # Specify directory for log files. logdir /var/log/chrony EOF -
Перезапустите службы синхронизации времени:
systemctl restart chronyd.service chronyc tracking
Настройка сервиса SSH
Чтобы настроить сервер SSH, выполните команду:
cat > /etc/ssh/sshd_config.d/45-skala{caret}r.conf << EOF
MACs hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha2-256-etm@openssh.com, umac-128-etm@openssh.com
EOF
Установка PostgresPro Standard/Ent Cert и Nginx
Чтобы установить Postgres Pro и NGINX, выполните команду:
dnf install postgrespro-std-15-server haproxy nginx -y
Настройка сервиса HAProxy
Чтобы настроить сервис HAProxy, выполните команду:
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg_def
cat > /etc/haproxy/haproxy.cfg << EOF
global
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 524288
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
listen stats
bind :9000
stats enable
stats uri /haproxy_stats
stats realm Haproxy_Stats_Skala_edz0
stats auth admin:***
stats auth oper:***
stats admin if TRUE
mode http
log 127.0.0.1:514 local2
defaults
mode http
log global
option httplog
option dontlognull
option http-keep-alive
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 5s
timeout client 10s
timeout server 30s
timeout http-keep-alive 40s
timeout check 10s
timeout client-fin 1s
timeout server-fin 1s
maxconn 524288
EOF
Настройка HTTP-соединения:
cat > /etc/haproxy/conf.d/http.cfg << EOF
frontend http
bind 127.0.0.1:80
option http-server-close
default_backend s3
backend s3
balance static-rr
server s3_1 <ip address>:80 check
server s3_2 <ip address>:80 check
server s3_3 <ip address>:80 check
EOF
Настройка сбора статистики:
cat > /etc/haproxy/conf.d/stat.cfg << EO
frontend prometheus
bind :<интерфейс доступа к данным статистики>
mode http
http-request use-service rometheus-exporter
no log
EOF
Создание конфигурационного файла для lifecycle:
cat > /etc/haproxy/conf.d/lifecycle.cfg << EOF
frontend lifecycle
bind <адрес шлюза S3 из сети хранения (или указанной в проекте)>:90
option http-server-close
default_backend lifecycle-b
http-request deny if !{ src <сеть серверов хранения>/<маска сети хранения> }
backend lifecycle-b
balance static-rr
server s3_1 <ip address>:80 check
server s3_2 <ip address>:80 check
server s3_3 <ip address>:80 check
EOF
Запуск сервиса HAProxy:
/usr/sbin/haproxy -f
/etc/haproxy/haproxy.cfg -f
/etc/haproxy/conf.d/http.cfg -f
/etc/haproxy/conf.d/stat.cfg -c
systemctl enable --now haproxy.service
Настройка и запуск сервиса PostgresPro Standard/Ent Cert
/opt/pgpro/std-15/bin/pg-setup initdb
systemctl enable postgrespro-std-15
systemctl status postgrespro-std-15
cat > /var/lib/pgpro/std-15/data/postgres.auto.conf << EOF
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
# For pgbench test purpose
listen_addresses = '*'
max_connections = 1050
superuser_reserved_connections = 50
# Memory
huge_pages = 'on'
shared_buffers = 48GB
maintenance_work_mem = 2048MB
wal_buffers = 256MB
work_mem = 16MB
# IO
effective_io_concurrency = 200
random_page_cost = 1.1
# Checkpoint
checkpoint_completion_target = 0.9
min_wal_size = 4GB
max_wal_size = 128GB
# WAL
#wal_level = replica
#wal_log_hints = on
# Query tuning
max_worker_processes = 96
max_parallel_workers_per_gather = 4
max_parallel_workers = 72
effective_cache_size = 182GB # (RAM - shared_buffers - maintenance_work_mem * autovacuum_max_workers)
EOF
Для изменения параметров ядра выполните команду:
cat > /etc/sysctl.d/85-mhd.o.conf << EOF
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_timestamps = 1
kernel.pid_max = 4194303
fs.file-max = 9223372036854775807
vm.swappiness = 1
vm.vfs_cache_pressure = 100
vm.min_free_kbytes = 1000000
net.core.rmem_max = 268435456
net.core.wmem_max = 268435456
net.core.rmem_default = 67108864
net.core.wmem_default = 67108864
net.core.netdev_budget = 1200
net.core.optmem_max = 134217728
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_rmem = 67108864 134217728 268435456
net.ipv4.tcp_wmem = 67108864 134217728 268435456
net.ipv4.tcp_low_latency = 1
net.ipv4.tcp_adv_win_scale = 1
net.ipv4.tcp_max_syn_backlog = 30000
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 5
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.tcp_mtu_probing = 1
EOF
Отредактируйте параметры доступа к СУБД:
-
Приведите содержимое файла
/var/lib/pgpro/std-15/data/pg_hba.confк следующему виду:# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only # local all all peer local s3gw s3gwuser md5 local all postgres trust # IPv4 local connections: # host all all 127.0.0.1/32 ident host s3gw s3gwuser 127.0.0.1/32 md5 -
Выполните команду:
sysctl --system -
Перезапустите службу PostgreSQL:
systemctl restart postgrespro-std-15.service
-
Создайте служебного пользователя для Спектр S3:
echo "CREATE USER s3gwuser WITH PASSWORD 's3gwuser';" | psql -U postgres
-
Создайте базу данных для пользователя Спектр S3:
echo 'CREATE DATABASE s3gw OWNER s3gwuser;' | psql -U postgres