Ho falla ha database ea GitLab ho PostgreSQL ea kantle

Hello mong le e mong!

Sehloohong sena, re tla falla database ea GitLab ho tloha ka hare ho PostgreSQL, e kentsoeng le GitLab, ho ea ho PostgreSQL ea kantle, e seng e kentsoe ho seva se seng.

Ho falla ha database ea GitLab ho PostgreSQL ea kantle

TIISETSO
Liketso tsohle li tiiselitsoe hore li tla sebetsa ho CentOS 7.7.1908, PostgreSQL 12 le GitLab 12.4.2-ee.0.

Tokisetso ea pele

Ha re etseng lintho tse tharo esale pele:

1. Ho seva sa PostgreSQL, eketsa molao ho firewall e lumellang likhokahano tse kenang ho PostgreSQL port 5432/TCP.

Tabeng ea ka:

firewall-cmd --add-service=postgresql --zone=internal --permanent
success
firewall-cmd --reload
success

2. Sebakeng se le seng, empa faeleng ea postgresql.conf, lumella marang-rang a marang-rang ho amohela likhokahano tse kenang ho tsoa ka ntle. Bula faele ea postgresql.conf, fumana molaetsa o fanoeng "#mamela_aterese = 'localhost'"'me ka tlas'a eona eketsa mola o kang o ka tlase. Moo - 10.0.0.2, aterese ea sebopeho sa hau.

Tabeng ea ka:

vi /var/lib/pgsql/12/data/postgresql.conf
# - Connection Settings -

#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = 'localhost, 10.0.0.2'
                                        # comma-separated list of addresses;

3. Kaha seva sa GitLab se tla hokela ho database ea kantle, sena se tlameha ho lumelloa ho seva sa PostgreSQL ho faele ea pg_hba.conf. Aterese ea ka ea seva sa GitLab ke 10.0.0.4.

Ha re bule faele ea pg_hba.conf 'me re kenye mola moo:

host    all             gitlab               10.0.0.4/24             md5

E tla shebahala tjena:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             postgres                                     md5

# IPv4 local connections:
host    all             postgres             127.0.0.1/32            md5
host    all             gitlab               10.0.0.4/24             md5

Qetellong, re qala ts'ebeletso ea postgresql hape:

systemctl restart postgresql-12.service

Ho romella kantle ho naha database ea GitLab

Ha re etseng backup ea database ho seva sa GitLab:

sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dumpall -U gitlab-psql --host=/var/opt/gitlab/postgresql > /tmp/internal-gitlab.sql

Backup e hlahile ho /tmp:

ls -lh
total 836K
-rw-r--r--. 1 root root 836K Nov 18 12:59 internal-gitlab.sql

Ha re kopise kopi ena ho seva sa PostgreSQL:

scp /tmp/internal-gitlab.sql 10.0.0.2:/tmp/
internal-gitlab.sql                                                                               100%  835KB  50.0MB/s   00:00

Ho kenya "internal-gitlab.sql" ho PostgreSQL

Kenya database ho PostgreSQL:

sudo -u postgres psql -f /tmp/internal-gitlab.sql

Lekola hore na database e se e le ho PostgreSQL:

sudo -u postgres psql -l

Mola o latelang o tlameha ho hlaha:

gitlabhq_production | gitlab   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

Ho lokisa GitLab

Kamora ho kenya database ho PostgreSQL, ho ile ha etsoa mosebelisi oa gitlab. U hloka ho fetola phasewete ea mosebelisi enoa.

Ho fetola password:

sudo -u postgres psql -c "ALTER USER gitlab ENCRYPTED PASSWORD 'ПАРОЛЬ' VALID UNTIL 'infinity';"
Password for user postgres:
ALTER ROLE

Joale, ho seva sa GitLab, faeleng ea tlhophiso /etc/gitlab/gitlab.rb, re tla bontša lintlha tsohle tsa PostgreSQL ea ka ntle.

Ha re etseng kopi ea "backup" ea faele ea gitlab.rb:

cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.orig

Joale eketsa mela ena qetellong ea faele ea gitlab.rb:

# Отключить встроенный PostgreSQL.
postgresql['enable'] = false

# Данные для подключения к внешней базе. Указывайте свои.
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_encoding'] = 'utf8'
gitlab_rails['db_host'] = '10.0.0.2'
gitlab_rails['db_port'] = 5432
gitlab_rails['db_database'] = "gitlabhq_production"
gitlab_rails['db_username'] = 'gitlab'
gitlab_rails['db_password'] = '******'

Boloka faele /etc/gitlab/gitlab.rb 'me u lokise GitLab hape:

gitlab-ctl reconfigure && gitlab-ctl restart

Ke phetho :)

Kopo e kholo. Haeba u beha minus, ngola lebaka ka litlhaloso.

Source: www.habr.com

Eketsa ka tlhaloso