============================ Установка на RED OS ============================ Рекомендуемый вариант установки -MINIMAL Разметка диска - на усмотрение Администратор Установка postgres-pro-14 ---------------------------- Подробную инструкцию по установке postgres-pro можете найти по ссылке на сайте производителя. https://postgrespro.ru/products/download/postgrespro/ :: wget https://repo.postgrespro.ru/pgpro-14/keys/pgpro-repo-add.sh sh pgpro-repo-add.sh Если наш продукт единственный Postgres на вашей машине и вы хотите сразу получить готовую к употреблению базу: :: yum install postgrespro-std-14 yum install postgrespro-std-14-plpython3 yum install postgrespro-std-14-plperl Проверяем успешность установки PostgreSQL: :: [root@srv137 ~]# systemctl status postgrespro-std-14.service ● postgrespro-std-14.service - Postgres Pro std 14 database server Loaded: loaded (/usr/lib/systemd/system/postgrespro-std-14.service; enabled Active: active (running) since Tue 2022-10-04 20:13:26 MSK; 1min 12s ago Main PID: 2475 (postgres) Tasks: 8 (limit: 4667) Memory: 44.7M CPU: 85ms CGroup: /system.slice/postgrespro-std-14.service ├─2475 /opt/pgpro/std-14/bin/postgres -D /var/lib/pgpro/std-14/data ├─2476 postgres: logger ├─2478 postgres: checkpointer ├─2479 postgres: background writer ├─2480 postgres: walwriter ├─2481 postgres: autovacuum launcher ├─2482 postgres: stats collector └─2483 postgres: logical replication launcher окт 04 20:13:26 srv137 systemd[1]: Starting Postgres Pro std 14 database server. окт 04 20:13:26 srv137 postgres[2475]: 2022-10-04 20:13:26.234 MSK [2475] СООБЩЕ окт 04 20:13:26 srv137 postgres[2475]: 2022-10-04 20:13:26.234 MSK [2475] ПОДСКА окт 04 20:13:26 srv137 systemd[1]: Started Postgres Pro std 14 database server. Получаем список установленных БД :: su - postgres postgres=# \l Список баз данных Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа -----------+----------+-----------+-----------------+-------------+----------------------- postgres | postgres | UTF8 | ru_RU.UTF-8@icu | ru_RU.UTF-8 | template0 | postgres | UTF8 | ru_RU.UTF-8@icu | ru_RU.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | ru_RU.UTF-8@icu | ru_RU.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 строки) Производим установку из поставки дистрибутива или на основе DEMO - APP * appdb - бизнес база (имя базы данных на усмотрение администратора) * xraddb - база метаданных приложения (переименование БД не рекомендуется) Создаем директорию и помещаем файлы дистрибутива PGHS :: mkdir -p /var/lib/pgpro/std-14/dump-imp cd /var/lib/pgpro/std-14/dump-imp [root@srv137 dump-imp]# ls -latr итого 35884 drwxr-xr-x 2 postgres postgres 4096 авг 19 17:32 . drwxr-xr-x 4 postgres postgres 4096 авг 19 17:25 .. -rw-r--r-- 1 postgres postgres 535928 авг 19 17:31 xraddb.xsquare -rw-r--r-- 1 postgres postgres 36197840 авг 19 17:32 appdb.xsquare Создаем пользователя :: [root@srv137 dump-imp]# su - postgres [postgres@srv137 ~]$ psql psql (14.5) postgres=# create user xrad_user with encrypted password 'xrad_user'; postgres=# create user app_user with encrypted password 'app_user'; postgres=# ALTER USER xrad_user WITH SUPERUSER; postgres=# ALTER USER app_user WITH SUPERUSER; postgres=# exit Создаем пустые базы :: su - postgres createdb -O app_user appdb createdb -O xrad_user xraddb производим импорт PGHS :: su - postgres psql -U xrad_user -h 127.0.0.1 xraddb < /var/lib/pgpro/std-14/dump-imp/xraddb.xsquare psql -U app_user -h 127.0.0.1 appdb < /var/lib/pgpro/std-14/dump-imp/appdb.xsquare Настройка Apache 2.4 -------------------------- Устанавливаем Apache :: yum install httpd systemctl enable httpd systemctl start httpd Добавляем в файл ``/etc/hosts`` и прописываем в локальный DNS организации :: 127.0.0.1 pghs.xsquare Создаем файл конфигурации ``VirtualHost`` для PGHS сервера ``vi /etc/httpd/conf.d/pghs.xsquare.conf`` :: ServerAdmin info@xsquare.ru ServerName pghs.xsquare ServerAlias pghs.xsquare DocumentRoot /var/www/pghs.xsquare Alias /files "/var/www/pghs.xsquare.files.local" Options FollowSymLinks AllowOverride None Require all granted ProxyPass /pghs http://127.0.0.1:8888/pghs ProxyPassReverse /pghs http://127.0.0.1:8888/pghs ErrorLog /etc/httpd/logs/pghs-error.log CustomLog /etc/httpd/logs/pghs-access.log combined Отключаем Security-Enhanced Linux для HTTP запросов :: setsebool -P httpd_can_network_connect 1 Настройка дистрибутива XSQUARE - PGHS ---------------------------------------- Настройка Web Resources XSQUARE - PGHS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Копируем файл Web приложения из дистрибутива :: cp -R pghs.xsquare /var/www/ cp -R pghs.xsquare.files.local/ /var/www/ Проверяем и перезапускаем Apache :: httpd -t systemctl restart httpd или :: systemctl reload httpd Настройка сервер приложений XSQUARE - PGHS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Копируем дистрибутив сервера приложений :: mkdir /usr/local/xsquare.pghs cp -R pghs /usr/local/xsquare.pghs/ Настраиваем параметры соединения с PostgreSQL ``vi /usr/local/xsquare.pghs/config.json`` :: { "app": { "port": "8888" }, "AppDatabase": { "login": "app_user", "password": "app_user", "domain": "127.0.0.1", "port": "5432", "dbName":"app_db", "runtimeOptions":{ "LC_NUMERIC":"ru_RU.UTF-8" } }, "XRADDatabase": { "login": "xrad_user", "password": "xrad_user", "domain": "localhost", "port": "5432", "dbName":"xraddb", "runtimeOptions":{ "LC_NUMERIC":"ru_RU.UTF-8" } } } **Создаем сервис** ``vi /etc/systemd/system/xsquare.pghs.service`` :: [Unit] Description=XSQUARE PGHS Services After=syslog.target network.target After=postgresql.service [Service] Type=simple ExecStart=/usr/local/xsquare.pghs/pghs WorkingDirectory=/usr/local/xsquare.pghs Restart=on-failure RestartSec=3 [Install] WantedBy=default.target Включаем для сервиса AvtoStart и запускаем и проверяем статус :: systemctl enable xsquare.pghs.service systemctl start xsquare.pghs.service systemctl status xsquare.pghs.service Открываем и проверяем запуск :: http://pghs.xsquare/