Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install PostgreSQL from yum repository

    Code Block
    languagebash
    yum install -y postgresql postgresql-server
  2. Initialize a new PostgreSQL installation

    Code Block
    languagebash
    postgresql-setup initdb
  3. By default PostgreSQL server is only accessible via Unix Domain Sockets or loopback IP interface (127.0.0.1) to the local users, the users are authenticated by the operating system, i.e. the OS user postgres can connect as PostreSQL user postgres without any additional authentication from the PostgreSQL server side. To allow PgAdmin4 and FIXICC H2 to work we need to enable access via a network

    To enable network access to PostgreSQL server edit file /var/lib/pgsql/data/pg_hba.conf and add the following lines:

    Code Block
    languagecss
    host    all     all     0.0.0.0/0       md5
    host    all     all     ::0/0           md5

    It allows all users to connect from any host via TCP or SSL socket using hashed passwords.

    Remove lines that enable ident connection to localhost:

    Code Block
    languagecss
    # IPv4 local connections:
    host    all             all             127.0.0.1/32         ident
    # IPv6 local connections:
    host    all             all             ::1/128              ident

    To enable listening of all network interfaces edit file /var/lib/pgsql/data/postgresql.conf , replace line:

    Code Block
    languagecss
    # listen_addresses = 'localhost'

    with

    Code Block
    languagecss
    listen_addresses = '*'
  4. Enable auto-start and start postgresql server (check service status)

    Code Block
    languagebash
    systemctl enable --now postgresql
    systemctl restatusstatus postgresql

Consul installation and configuration

  1. Add HashiCorp repository:

    Code Block
    languagebash
    yum install -y yum-utils
    yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
  2. Install consul from yum repository

    Code Block
    languagebash
    yum -y install consul
  3. Generate Consul certificate and private key

    Code Block
    languagebash
    openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /etc/consul.d/consul.key -out /etc/consul.d/consul.crt -subj '/C=RU/L=Saratov/O=EPAM/OU=BFIX/CN=fixicch2.consul'
    chown consul:consul /etc/consul.d/*
    Note
    titleNOTE!
    - replace '/C=RU/L=Saratov/O=EPAM/OU=BFIX/CN=fixicch2.consul' with your company identity
  4. Configure consul as follows (/etc/consul.d/consul.json)

    Note
    titleNOTE!
    Create consul.json file if missing in the directory.
    Code Block
    languagecss
    {
          "bind_addr": "{{GetInterfaceIP \"ens5\"}}",
          "bootstrap": true,
          "server": true,
          "addresses": {
                "https": "0.0.0.0"
          },
          "ports": {
                "http": -1,
                "https": 8501
          },
          "auto_encrypt": {
                "allow_tls": true,
                "tls": true
          },
          "client_addr": "0.0.0.0",
          "ui": true,
          "data_dir": "/var/lib/consul",
          "log_level": "INFO",
          "disable_update_check": true,
          "disable_anonymous_signature": true,
          "verify_server_hostname": false,
          "cert_file": "/etc/consul.d/consul.crt",
          "key_file": "/etc/consul.d/consul.key",
          "auto_encrypt": {
                "allow_tls": true
          }
    }



    Note
    titleNOTE!
    - replace ens5 with your server's network interface
    - you can find your network interface id with `ifconfig` command



  5. Remove or backup /etc/consul.d/consul.hcl

  6. Create consul data directory

    Code Block
    languagebash
    mkdir /var/lib/consul
    chown consul:consul /var/lib/consul
  7. Remove ConditionFileNotEmpty in /usr/lib/systemd/system/consul.service

    Code Block
    languagecss
    ConditionFileNotEmpty=/etc/consul.d/consul.hcl
  8. Enable auto-start and start consul server :(check service status)

    Code Block
    languagebash
    systemctl enable --now consul
    systemctl startstatus consul
  9. Consul UI should be available on https://server_ip:8501/ui/

...