GitLab Community Edition 新版本已經集成了CI/CD的支持,從某種程度上來講能夠告別對於Jenkins的依賴,我原本計劃是寫基於Docker部署GitLab但感受仍是有點重,對於內網離線環境來講基於容器部署也未必是合理的方案,這裏沿用傳統的部署方式介紹簡單且長期有效的GitLab部署方案供你們參考,或許將來會增長基於容器的部署方案和CI/CD的分享,因需而變。python
RHEL7/CentOS7在線和離線安裝GitLab配置實踐,GitLab漢化配置使用小結
2018年04月10日 - 初稿linux
閱讀原文 - https://wsgzao.github.io/post...nginx
擴展閱讀git
GitLab Installation - https://about.gitlab.com/inst...github
GitLab是利用Ruby On Rails開發的一個開源版本管理系統,實現了一個自託管的Git項目倉庫,是集代碼託管,測試,部署於一體的開源git倉庫管理軟件,可經過web界面來進行訪問公開的或私人項目。與Github相似,GitLab可以瀏覽代碼,管理缺陷和註釋。能夠管理團隊對倉庫的訪問,它很是易於瀏覽提交過的版本,並提供一個文件歷史庫。它還提供一個代碼片斷收集功能能夠輕鬆實現代碼複用,便於往後須要的時候查找。web
Git的家族成員
GitLab對硬件仍是有必定要求的,1核心的CPU基本上能夠知足需求,大概支撐100個左右的用戶,不過在運行GitLab網站的同時還須要運行多個後臺job,就會顯得有點捉襟見肘了。須要至少4GB的可尋址內存(RAM交換)來安裝和使用GitLab,操做系統和任何其餘正在運行的應用程序也將使用內存,所以請記住,在運行GitLab以前,您至少須要4GB的可用空間。若是使用更少的內存,GitLab將在從新配置運行期間給出奇怪的錯誤,我用虛擬機來分別新建1G,2G內存的CentOS系統來裝GitLab,確實很是捉襟見肘啊,傷不起。redis
# 安裝必要的依賴包,若是不須要能夠考慮跳過 yum install pygpgme yum-utils # On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP and SSH access in the system firewall. sudo yum install -y curl policycoreutils-python openssh-server sudo systemctl enable sshd sudo systemctl start sshd sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld # Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed. sudo yum install postfix sudo systemctl enable postfix sudo systemctl start postfix # 使用阿里雲做加速 cd /etc/yum.repos.d/ && rm -f *.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 添加GitLab鏡像源並安裝,建議切換國內資源加速訪問 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # 建立gitlab-ce的repo,使用清華大學加速 vim /etc/yum.repos.d/gitlab_gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key #配置並啓動 GitLab gitlab-ctl reconfigure # 第一次訪問GitLab,系統會重定向頁面到重定向到重置密碼頁面,你須要輸入初始化管理員帳號的密碼,管理員的用戶名爲root,重置密碼後新密碼即爲剛輸入的密碼。 0.0.0.0:80
# 使用阿里雲做加速 cd /etc/yum.repos.d/ && rm -f *.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 添加GitLab鏡像源並安裝,建議切換國內資源加速訪問 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # 建立gitlab-ce的repo,使用清華大學加速 vim /etc/yum.repos.d/gitlab_gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key #安裝yum-plugin-downloadonly插件 yum install -y yum-plugin-downloadonly # 下載gitlab-ce相關rpm到指定目錄 mkdir -p /tmp/repo/gitlab-ce/ yum install --downloadonly --downloaddir=/tmp/repo/gitlab-ce/ gitlab-ce # 拷貝文件至內網離線安裝 rpm -ivh /tmp/repo/gitlab-ce/* #配置並啓動 GitLab gitlab-ctl reconfigure # 第一次訪問GitLab,系統會重定向頁面到重定向到重置密碼頁面,你須要輸入初始化管理員帳號的密碼,管理員的用戶名爲root,重置密碼後新密碼即爲剛輸入的密碼。 0.0.0.0:80
若是團隊裏英文水平都不錯的話,是不必漢化的,我我的的建議是堅持使用原版不作漢化
GitLab中文社區的項目,v7-v8.8是由Larry Li發起的「GitLab中文社區版項目」
https://gitlab.com/larryli/gi...sql
從v8.9以後由@xhang開始繼續漢化項目
https://gitlab.com/xhang/gitlabshell
# 如沒安裝git,需提早安裝 yum install -y git # 建立gitlba漢化包下載目錄 mkdir -p /tmp/gitlab cd /tmp/gitlab # 下載最新的漢化包 git clone https://gitlab.com/xhang/gitlab.git # 若是是要下載老版本的漢化包,須要加上老版本的分支,若是想下載10.0.2,能夠運行以下語句 git clone https://gitlab.com/xhang/gitlab.git -b v10.0.2-zh # 中止GitLab並執行以下語句 gitlab-ctl stop cp /tmp/gitlab/gitlab/* /opt/gitlab/embedded/service/gitlab-rails/ -rf # 複製時可能不斷提示是否要覆蓋,這時多是系統每次執行cp命令時,實際上是執行了cp -i命令的別名。出現這種狀況能夠修改~/.bashrc,在「alias cp=’cp-i’」前加#註釋便可。使用命令或者註銷登陸便可 source ~/.bashrc # 接下來能夠從新配置和啓動 gitlab-ctl reconfigure gitlab-ctl restart
# 語法 gitlab-ctl command (subcommand) Service Management Commands start # 啓動全部服務 stop # 關閉全部服務 restart # 重啓全部服務 status # 查看全部服務狀態 tail # 查看日誌信息 service-list # 列舉全部啓動服務 graceful-kill # 平穩中止一個服務 # 啓動全部服務 gitlab-ctl start # 啓動單獨一個服務 gitlab-ctl start nginx #查看日誌,查看全部日誌 gitlab-ctl tail #查看具體一個日誌,相似tail -f gitlab-ctl tail nginx General Commands help # 幫助 reconfigure # 修改配置文件以後,須要從新加載下 show-config # 查看全部服務配置文件信息 uninstall # 卸載這個軟件 cleanse # 刪除gitlab數據,從新白手起家 # 顯示全部服務配置文件 gitlab-ctl show-config # 卸載gitlab gitlab-ctl uninstall
默認狀況下,GitLab用qq郵箱註冊是發不出確認郵件的。查看了網上不少郵箱配置的教程,大部分都是誤導的。像這類軟件,歸根到底總結爲一句話:一切以官網文檔爲準。QQ郵箱最好用企業郵箱,本人用我的郵箱進行測試是有些小問題的,正確配置以下:數據庫
# 編輯gitlab.rb vim /etc/gitlab/gitlab.rb gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxx@xx.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
root
和 5iveL!fe
1.安裝Git工具linux:安裝Git,使用自帶的源安裝
yum install git
2.生成密鑰文件:使用ssh-keygen生成密鑰文件.ssh/id_rsa.pub。
ssh-keygen -t rsa
3.在GitLab的主頁中新建一個Project
4.添加ssh key導入步驟2中生成的密鑰文件內容:
Profile Settings => SSH Keys => Add SSH key
# 配置使用Git倉庫的人員姓名 git config --global user.name "wangao" # 配置使用Git倉庫的人員email,填寫本身的公司郵箱 git config --global user.email "wangao@test.com" # 克隆項目,在本地生成同名目錄,而且目錄中會有全部的項目文件 git clone git@172.28.70.126:root/test.git # 進入到項目目錄 cd test/ # 建立須要上傳到GitLab中的目標文件 echo "test" > test.sh # 將test.sh文件加入到索引中 git add test.sh # 將test.sh提交到本地倉庫 git commit -m "test.sh" # 將文件同步到GitLab服務器上 git push -u origin master # 在網頁中查看上傳的test.sh文件已經同步到GitLab中