gitlab搭建
1.安裝依賴項
suo apt update
sudo apt upgrade -y
sudo apt install ca-certificates curl openssh-server postfix
2.添加gitlab-ce存儲庫
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
3.安裝gitlab-ce
sudo apt update
sudo EXTERNAL_URL="http://gitlab.example.com" apt -y install gitlab-ce
?在執(zhí)行命令之前讥脐,將gitlab.example.com替換為你的實際域名醉者。完成后,通過運行以下命令啟動GitLab實例:
sudo gitlab-ctl reconfigure
配置后應啟動所有的GitLab服務:
gitlab 備份
停止用戶連接
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
創(chuàng)建備份
gitlab-rake gitlab:backup:create
如果出錯請檢查權限問題 我的是默認root
可以加sudo重新試一下
gitlab升級
gitlab普通升級就正常升級就可以了
?升級不能跨越大版本號窥岩,因此只能升級到當前大版本號到最高版本甲献,
方可升級到下一個大版本號
如果是跨大版本升級要嚴格按照官方指導的升級順序進行
參考:
https://docs.gitlab.com/ce/policy/maintenance.html
先停止用戶連接
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
創(chuàng)建備份:
gitlab-rake gitlab:backup:create
然后安裝升級
例如我從清華軟件源下載好的deb安裝包
直接dpkg -i 安裝就行了
rpm包也是
也可以直接在線升級
完事重啟
sudo gitlab-ctl restart
gitlab遷移恢復
1.執(zhí)行備份數(shù)據(jù)
2.在目標機器中搭建與執(zhí)行備份相同版本的gitlab
?版本一定要相同
3.將備份的tar包復制到目標機器備份目錄
?默認路徑為:/var/opt/gitlab/backups/
4.恢復數(shù)據(jù)
依然要把這些服務停掉
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop nginx
然后執(zhí)行
gitlab-rake gitlab:backup:restore BACKUP=備份文件gitlab_backup.tar前面的數(shù)字
正常情況下就是以上這些步驟了
如果你整個過程順順利利的那么到這里就結束了
但是我的過程中充滿了曲折
以下是我遇到的一些錯誤
僅以記錄供參考
處理gitlab升級時的錯誤
錯誤原因:端口占用
修改默認端口
找到gitlab.rb這個配置文件
external_url 'http://你的域名:8082'
把最后的端口修改成別空的端口
使配置生效
gitlab-ctl reconfigure
重新啟動GitLab
gitlab-ctl restart
即可生效
備份時遇到的錯誤
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... pg_dump: [archiver (db)] connection to database "gitlabhq_production" failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
[FAILED]
Backup failed
原因:
postgresql 沒有啟動
參考https://www.tlanyan.me/deal-gitlab-upgrade-error/
解決辦法
sudo gitlab-ctl start postgresql
reconfigure過程中的一個錯誤
* execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] action run
[execute] The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
initdb: invalid locale settings; check LANG and LC_* environment variables
================================================================================
Error executing action `run` on resource 'execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/enable.rb
80: execute "/opt/gitlab/embedded/bin/initdb -D #{node['postgresql']['data_dir']} -E UTF8" do
81: user postgresql_username
82: not_if { pg_helper.bootstrapped? }
83: end
84:
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/enable.rb:80:in `from_file'
execute("/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8") do
action [:run]
default_guard_interpreter :execute
command "/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8"
backup 5
declared_type :execute
cookbook_name "postgresql"
recipe_name "enable"
user "gitlab-psql"
domain nil
not_if { #code block }
end
System Info:
------------
chef_version=14.13.11
platform=debian
platform_version=9.9
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client
Running handlers:
There was an error running gitlab-ctl reconfigure:
execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 80) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1
Running handlers complete
Chef Client failed. 6 resources updated in 07 seconds
解決辦法
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo dpkg-reconfigure locales
reconfigure過程中的另一個錯誤
在升級完成 執(zhí)行gitlab-ctl reconfigure的時候出現(xiàn)
Error executing action `run` on resource 'execute[initctl status gitlab-runs
解決辦法
參照的這個
http://www.doc88.com/p-2542809540436.html
我也沒看太懂原理
反正好使 回頭再研究
至此 gitlab總算啟動起來了
感謝google&baidu各路大神
以上