gitlab 安装_Linux学习14CentOS安装gitlab环境
前言
在學(xué)習(xí)Gitlab的環(huán)境搭建之前,首先需要了解Git,Gitlab,GitHub他們?nèi)咧g的關(guān)系
Git 它是一個(gè)源代碼版本控制系統(tǒng),可讓您在本地跟蹤更改并從遠(yuǎn)程資源推送或提取更改。
GitHub 是一項(xiàng)公開可用的免費(fèi)服務(wù),它要求所有代碼(除非您有付費(fèi)帳戶)公開。 任何人都可以看到您推送給GitHub的代碼并提供改進(jìn)建議。
GitLab是一種類似github的服務(wù),組織可以使用它來提供git存儲(chǔ)庫的內(nèi)部管理。 它是一個(gè)自我托管的Git-repository管理系統(tǒng),可以保持用戶代碼的私密性,并且可以輕松地部署代碼的更改。
簡單來說,github是全世界最大的開源的gay友平臺(tái),適合免費(fèi)公開的代碼。gitlab是搭建本公司的代碼管理平臺(tái),適合私有的平臺(tái)代碼管理。
因?yàn)楸竟镜拇a不想被其它人看到,這就需要搭建一個(gè)本公司的gitlab平臺(tái),供公司內(nèi)部人員使用。
安裝依賴包
GitLab 10.x之后添加多了一些依賴,并且要啟動(dòng)sshd服務(wù),所以我們先添加依賴,啟動(dòng)sshd,為防火墻添加服務(wù)
sudo yum install -y curl policycoreutils-python openssh-serveropenssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd ?
# 防火墻這2步可以不用管
# sudo firewall-cmd –permanent –add-service=http
# sudo systemctl reload firewalld
postfix的產(chǎn)生是為了替代傳統(tǒng)的sendmail.相較于sendmail,postfix在速度。性能和穩(wěn)定性上都更勝一籌。
如今眼下許多的主流郵件服務(wù)事實(shí)上都在採用postfix. 當(dāng)我們須要一個(gè)輕量級的的郵件server是,postfix不失為一種選擇。
postfix想要作用的范圍是廣大的Internet用戶。試圖影響大多數(shù)的Internet上的電子郵件系統(tǒng),因此它是免費(fèi)的。
postfix在性能上大約比sendmail快三倍。一部執(zhí)行postfix的臺(tái)式PC每天能夠收發(fā)上百萬封郵件。
postfix是sendmail兼容的,從而使sendmail用戶能夠非常方便地遷移到postfix。Postfix支持/var[/spool]/mail、/etc/aliases、 NIS、和 ~/.forward 文件。
postfix被設(shè)計(jì)成在重負(fù)荷之下仍然能夠正常工作。當(dāng)處理的郵件數(shù)目增長時(shí),postfix執(zhí)行的進(jìn)程不會(huì)跟著添加。
postfix是由超過一打的小程序組成的,每一個(gè)程序完畢特定的功能。
gitlab配置需要用到郵件發(fā)送,所以先安裝postfix
yum -y install postfix
安裝完之后,啟動(dòng)postfix
systemctl start postfix
啟動(dòng)過程中如果報(bào)錯(cuò):Job for postfix.service failed because the control process exited with error code. See “systemctl status postfix.service” and “journalctl -xe” for details.
解決辦法,vim打開/etc/postfix/main.cf,修改如下兩項(xiàng),修改之前可以先備份下
# 修改 /etc/postfix/main.cf的設(shè)置 ?inet_protocols = ipv4 ? inet_interfaces = all修改完成后,再次啟動(dòng),就不會(huì)報(bào)錯(cuò)了,設(shè)置postfix為開機(jī)自啟動(dòng)
systemctl enable postfix
查看啟動(dòng)狀態(tài),看到 Active: active (running) 就是已經(jīng)正常啟動(dòng)了
[root@yoyo ~]# systemctl status postfix
完整的操作如下
[root@yoyo ~]# yum -y install policycoreutils-python openssh-server openssh-clients[root@yoyo ~]# systemctl enable sshd
[root@yoyo ~]# systemctl start sshd[root@yoyo ~]# yum -y install postfix
[root@yoyo ~]# systemctl start postfix Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details. [root@yoyo ~]# cp /etc/postfix/main.cf ?/etc/postfix/main.cf.bak [root@yoyo ~]# vim /etc/postfix/main.cf # 修改inet_protocols = ipv4 ? 和inet_interfaces = all ? [root@yoyo ~]# systemctl start postfix [root@yoyo ~]# systemctl enable postfix[root@yoyo ~]# systemctl status postfix ● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2019-01-15 15:37:28 CST; 5min agoProcess: 3171 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)Process: 3167 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)Process: 3164 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)Main PID: 3244 (master)CGroup: /system.slice/postfix.service├─3244 /usr/libexec/postfix/master -w├─3245 pickup -l -t unix -u└─3246 qmgr -l -t unix -uJan 15 15:37:27 yoyo systemd[1]: Starting Postfix Mail Transport Agent... Jan 15 15:37:28 yoyo postfix/postfix-script[3242]: starting the Postfix mail system Jan 15 15:37:28 yoyo postfix/master[3244]: daemon started -- version 2.10.1, configuration /etc/postfix Jan 15 15:37:28 yoyo systemd[1]: Started Postfix Mail Transport Agent. [root@yoyo ~]#
gitlab安裝
GitLab官方文檔中有多種安裝方式,分別為deb,rpm,node,python,gem。詳情請看:https://packages.gitlab.com/gitlab/gitlab-ce/install
centos 7系統(tǒng)的下載地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
找個(gè)最新版去下載gitlab-ce-11.6.3-ce.0.el7.x86_64.rpm
下載rpm包并安裝
[root@yoyo ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm [root@yoyo ~]# mkdir /usr/local/gitlab [root@yoyo ~]# mv gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm /usr/local/gitlab/ [root@yoyo ~]# cd /usr/local/gitlab/ [root@yoyo gitlab]# rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm warning: gitlab-ce-11.6.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY error: Failed dependencies:policycoreutils-python is needed by gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm# 如果出現(xiàn)上面這個(gè)報(bào)錯(cuò)就執(zhí)行yum install policycoreutils-python [root@yoyo gitlab]# yum -y install policycoreutils-python[root@yoyo gitlab]# rpm -i gitlab-ce-11.6.3-ce.0.el7.x86_64.rpm warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY It looks like GitLab has not been configured yet; skipping the upgrade script.*. ? ? ? ? ? ? ? ? ?*.*** ? ? ? ? ? ? ? ? ******** ? ? ? ? ? ? ? *****.****** ? ? ? ? ? ? *************** ? ? ? ? ? ?********,,,,,,,,,***********,,,,,,,,,,,,,,,,,,,,*********,,,,,,,,,,,.,,,,,,,,,,,*******,,,,,,,,,,,,,,,,,,,,,*****,,,,,,,,,.,,,,,,,****,,,,,,.,,,***,,,,,*,._______ __ ?__ ? ? ? ? ?__/ ____(_) /_/ / ? ____ _/ /_/ / __/ / __/ / ? / __ `/ __ \/ /_/ / / /_/ /___/ /_/ / /_/ /\____/_/\__/_____/\__,_/_.___/Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command:sudo gitlab-ctl reconfigureFor a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md安裝完成之后,會(huì)出現(xiàn)gitlab官方文檔地址https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
配置并啟動(dòng)gitlab-ce
gitlab安裝完成后,需要設(shè)置一個(gè)訪問地址(或域名),打開/etc/gitlab/gitlab.rb,將默認(rèn)的external_url = 'http://git.example.com'修改為自己的IP地址:http://xxx.xx.xxx.xx
[root@yoyo conf]# vim /etc/gitlab/gitlab.rb
原來默認(rèn)的external_url
## GitLab URL ##! URL on which GitLab will be reachable. ##! For more details on configuring external_url see: ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab external_url 'http://git.example.com'修改成自己定義的url地址,端口自己設(shè)置一個(gè),別和已有的沖突了
## GitLab URL ##! URL on which GitLab will be reachable. ##! For more details on configuring external_url see: ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab external_url 'http://47.104.x.x:8100'修改完成后:wq保存退出,執(zhí)行以下命令,讓配置生效
[root@yoyo conf]# gitlab-ctl reconfigure
啟動(dòng)Gitlab
[root@yoyo conf]# gitlab-ctl start
[root@yoyo ~]# gitlab-ctl start ok: run: gitaly: (pid 6638) 186s ok: run: gitlab-monitor: (pid 6656) 186s ok: run: gitlab-workhorse: (pid 6659) 186s ok: run: logrotate: (pid 6703) 185s ok: run: nginx: (pid 6709) 185s ok: run: node-exporter: (pid 6715) 184s ok: run: postgres-exporter: (pid 6720) 184s ok: run: postgresql: (pid 7324) 44s ok: run: prometheus: (pid 6752) 171s ok: run: redis: (pid 6761) 171s ok: run: redis-exporter: (pid 6765) 170s ok: run: sidekiq: (pid 7299) 45s ok: run: unicorn: (pid 7476) 18s啟動(dòng)完成后,在瀏覽器輸入http://47.104.x.x:8100,就是gitlab的登錄首頁了,如果出現(xiàn)502頁面,需修改默認(rèn)的8080端口
502問題
打開gitlab首頁出現(xiàn)502問題
出現(xiàn)這個(gè)問題,主要是因?yàn)?080端口被占用,之前安裝tomcat默認(rèn)的是8080端口,netstat -ntpl查看端口情況
[root@yoyo ~]# netstat -ntpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address ? ? ? ? ? Foreign Address ? ? ? ? State ? ? ? PID/Program name ? ? tcp ? ? ? ?0 ? ? ?0 127.0.0.1:9100 ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6715/node_exporter ? ? ? tcp ? ? ? ?0 ? ? ?0 0.0.0.0:8080 ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?801/java ? ? ? tcp ? ? ? ?0 ? ? ?0 0.0.0.0:8060 ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6709/nginx: master ? tcp ? ? ? ?0 ? ? ?0 127.0.0.1:9121 ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6765/redis_exporter tcp ? ? ? ?0 ? ? ?0 127.0.0.1:9090 ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6752/prometheus ? ? tcp ? ? ? ?0 ? ? ?0 127.0.0.1:9187 ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6720/postgres_expor tcp ? ? ? ?0 ? ? ?0 0.0.0.0:8100 ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?6709/nginx: master ? tcp ? ? ? ?0 ? ? ?0 127.0.0.1:8101 ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? LISTEN ? ? ?7495/unicorn master tcp6 ? ? ? 0 ? ? ?0 :::3306 ? ? ? ? ? ? ? ? :::* ? ? ? ? ? ? ? ? ? ?LISTEN ? ? ?1370/mysqld殺掉8080端口即可,8080端口對應(yīng)的pip是801
[root@yoyo ~]# kill -9 801
重啟下服務(wù),刷新頁面就可以訪問了
[root@yoyo ~]# gitlab-ctl restart
為了避免8080端口沖突問題,可以修改下unicorn的默認(rèn)端口,vim打開/etc/gitlab/gitlab.rb配置文件
新增一項(xiàng)unicorn[‘port’] = 8101,修改后內(nèi)容如下
## GitLab URL ##! URL on which GitLab will be reachable. ##! For more details on configuring external_url see: ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab external_url 'http://47.104.x.x:8100'unicorn['port'] = 8101修改完成后:wq保存退出,執(zhí)行g(shù)itlab-ctl reconfigure命令,讓配置生效,再重新啟動(dòng)服務(wù)
[root@yoyo conf]# gitlab-ctl reconfigure [root@yoyo conf]# gitlab-ctl stop [root@yoyo conf]# gitlab-ctl start接著在瀏覽器訪問就能看的gitlab登錄首頁了
gitlab配置查看
gitlab的配置主要是etc/gitlab/gitlab.rb下的兩個(gè)地方
external_url 'http://47.104.x.x:8100'unicorn['port'] = 8101查看更多配置信息可以,在/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml查看具體的詳情
?gitlab:## Web server settings (note: host is the FQDN, do not include http://)host: 47.104.x.xport: 8100https: false相關(guān)操作
啟動(dòng)服務(wù):gitlab-ctl start
查看狀態(tài):gitlab-ctl status
停掉服務(wù):gitlab-ctl stop
重啟服務(wù):gitlab-ctl restart
讓配置生效:gitlab-ctl reconfigure
2019年《python全棧自動(dòng)化測試課程》2月16號開學(xué)!
主講老師:上海-悠悠
上課方式:QQ群視頻在線教學(xué)
上課時(shí)間:每周六、周日晚上20:30-22:30
2019年《python全棧自動(dòng)化測試課程》2月16號開學(xué)!
總結(jié)
以上是生活随笔為你收集整理的gitlab 安装_Linux学习14CentOS安装gitlab环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python3.9.0_Python 3
- 下一篇: 以某一用户名和密码 登录请求脚本_lin