Установка на Alt Сервер

Установка 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 на вашей машине и вы хотите сразу получить готовую к употреблению базу:

apt-get install postgrespro-std-14
apt-get install postgrespro-std-14-plpython3
apt-get install postgrespro-std-14-plperl

Проверка успешной установки БД

systemctl status postgrespro-std-14.service
root@srv139:/home/administrator# systemctl status postgrespro-std-14.service
● postgrespro-std-14.service - Postgres Pro std 14 database server
     Loaded: loaded (/lib/systemd/system/postgrespro-std-14.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-10-07 15:35:12 UTC; 47s ago
   Main PID: 24036 (postgres)
      Tasks: 8 (limit: 9443)
     Memory: 67.4M
     CGroup: /system.slice/postgrespro-std-14.service
             ├─24036 /opt/pgpro/std-14/bin/postgres -D /var/lib/pgpro/std-14/data
             ├─24049 postgres: logger
             ├─24051 postgres: checkpointer
             ├─24052 postgres: background writer
             ├─24053 postgres: walwriter
             ├─24054 postgres: autovacuum launcher
             ├─24055 postgres: stats collector
             └─24056 postgres: logical replication launcher

Oct 07 15:35:12 srv138 systemd[1]: Starting Postgres Pro std 14 database server...
Oct 07 15:35:12 srv138 postgres[24036]: 2022-10-07 15:35:12.815 UTC [24036] LOG:  redirecting log output to logging collector process
Oct 07 15:35:12 srv138 postgres[24036]: 2022-10-07 15:35:12.815 UTC [24036] HINT:  Future log output will appear in directory "log".
Oct 07 15:35:12 srv138 systemd[1]: Started Postgres Pro std 14 database server.

Получаем список установленных БД

su - postgres
psql
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

Производим установку из поставки дистрибутива или на основе DEMO - APP

  • appdb - бизнес база (имя базы данных на усмотрение администратора)

  • xraddb - база метаданных приложения (переименование БД не рекомендуется)

Создаем директорию и помещаем файлы дистрибутива PGHS

mkdir -p /var/lib/pgpro/std-14/dump-imp
cd  /var/lib/pgpro/std-14/dump-imp
postgres@srv134:/var/lib/pgpro/std-14/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

Создаем пользователя и

su - postgres
psql
psql (14.4)
Введите "help", чтобы получить справку.

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;

exit

Создаем пустые базы

su - postgres
createdb -O app_user  appdb
createdb -O xrad_user xraddb

Настройка Apache 2.4

Устанавливаем Apache и модули

su - root
apt-get install apache2
systemctl enable httpd2
systemctl start httpd2
systemctl status httpd2

a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer

Добавляем в файл /etc/hosts и прописываем в локальный DNS организации

127.0.0.1 pghs.xsquare

Создаем файл конфигурации VirtualHost для pghs сервера

vi /etc/apache2/sites-available/pghs.xsquare.conf

<VirtualHost *:80>
       ServerAdmin info@xsquare.ru
       ServerName  pghs.xsquare
       ServerAlias pghs.xsquare
       DocumentRoot /var/www/pghs.xsquare

       Alias /files "/var/www/pghs.xsquare.files.local"
       <Directory /var/www/pghs.xsquare.files.local>
               Options FollowSymLinks
               AllowOverride None
               Require all granted
       </Directory>

       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
</VirtualHost>

Включаем сайт http://pghs.xsquare

a2ensite pghs.xsquare.conf
systemctl restart httpd2

Настройка дистрибутива XSQUARE - PGHS

Настройка Web Resources XSQUARE - PGHS

Копируем файл Web приложения из дистрибутива

scp -r -P 22 pghs.xsquare root@IP_Server:/var/www/

Копируем файлы настройки Web приложения из дистрибутива

scp -r -P 22 pghs.xsquare.files.local root@IP_Server:/var/www/

Настройка сервер приложений XSQUARE - PGHS

Копируем дистрибутив сервера приложений

scp -r -P 22 /usr/local/xsquare.pghs  root@IP_Server:/usr/local

Настраиваем параметры соединения с 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=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/