Nyob zoo txhua leej txhua tus!
Nyob rau hauv tsab xov xwm no, peb yuav migrate GitLab database los ntawm sab hauv PostgreSQL, uas yog ntsia nrog GitLab, mus rau sab nraud PostgreSQL, uas yog twb ntsia rau lwm tus neeg rau zaub mov.
CEEB TOOM
Txhua qhov kev ua tau lees paub ua haujlwm ntawm CentOS 7.7.1908, PostgreSQL 12 thiab GitLab 12.4.2-ee.0.
Kev npaj ua ntej
Cia peb ua peb yam ua ntej:
1. Nyob rau PostgreSQL neeg rau zaub mov, ntxiv ib txoj cai rau lub firewall uas tso cai nkag mus rau PostgreSQL chaw nres nkoj 5432/TCP.
Hauv kuv qhov xwm txheej:
firewall-cmd --add-service=postgresql --zone=internal --permanent
success
firewall-cmd --reload
success
2. Nyob rau tib qhov chaw, tab sis nyob rau hauv cov ntaub ntawv postgresql.conf, tso cai rau lub network interface txais kev sib txuas los ntawm sab nraud. Qhib cov ntaub ntawv postgresql.conf, nrhiav cov lus tawm kab "#listen_addresses = 'localhost'"thiab hauv qab nws ntxiv ib kab zoo li hauv qab no. Qhov twg - 10.0.0.2, qhov chaw nyob ntawm koj lub interface.
Hauv kuv qhov xwm txheej:
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. Txij li thaum GitLab neeg rau zaub mov yuav txuas mus rau cov ntaub ntawv sab nraud, qhov no yuav tsum tau tso cai rau ntawm PostgreSQL server hauv cov ntaub ntawv pg_hba.conf. Kuv qhov chaw nyob GitLab server yog 10.0.0.4.
Cia peb qhib cov ntaub ntawv pg_hba.conf thiab ntxiv cov kab ntawd:
host all gitlab 10.0.0.4/24 md5
Nws yuav zoo li no:
# 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
Thiab thaum kawg, peb rov pib qhov kev pabcuam postgresql:
systemctl restart postgresql-12.service
Exporting GitLab database
Cia wb ua qhov thaub qab database ntawm GitLab server:
sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dumpall -U gitlab-psql --host=/var/opt/gitlab/postgresql > /tmp/internal-gitlab.sql
Cov thaub qab tau tshwm sim hauv /tmp:
ls -lh
total 836K
-rw-r--r--. 1 root root 836K Nov 18 12:59 internal-gitlab.sql
Cia peb luam daim ntawv no mus rau PostgreSQL server:
scp /tmp/internal-gitlab.sql 10.0.0.2:/tmp/
internal-gitlab.sql 100% 835KB 50.0MB/s 00:00
Importing "internal-gitlab.sql" rau hauv PostgreSQL
Import lub database rau hauv PostgreSQL:
sudo -u postgres psql -f /tmp/internal-gitlab.sql
Xyuas tias cov ntaub ntawv tam sim no nyob hauv PostgreSQL:
sudo -u postgres psql -l
Cov kab hauv qab no yuav tsum tshwm sim:
gitlabhq_production | gitlab | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
Configuring GitLab
Tom qab importing cov ntaub ntawv rau hauv PostgreSQL, tus neeg siv gitlab tau tsim. Koj yuav tsum hloov tus neeg siv tus password no.
Hloov tus password:
sudo -u postgres psql -c "ALTER USER gitlab ENCRYPTED PASSWORD 'ΠΠΠ ΠΠΠ¬' VALID UNTIL 'infinity';"
Password for user postgres:
ALTER ROLE
Tom qab ntawd, ntawm GitLab server, hauv cov ntaub ntawv teeb tsa /etc/gitlab/gitlab.rb, peb yuav qhia tag nrho cov ntaub ntawv ntawm PostgreSQL sab nraud.
Wb ua ib daim ntawv theej ntawm cov ntaub ntawv gitlab.rb:
cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.orig
Tam sim no ntxiv cov kab no mus rau qhov kawg ntawm cov ntaub ntawv 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'] = '******'
Txuag cov ntaub ntawv /etc/gitlab/gitlab.rb thiab reconfigure GitLab:
gitlab-ctl reconfigure && gitlab-ctl restart
Ntawd yog tag nrho :)
Kev thov loj. Yog tias koj muab qhov rho tawm, sau qhov laj thawj hauv cov lus.
Tau qhov twg los: www.hab.com