華為 P50 Pro 明日開售:麒麟 9000 晶片,6488 元起
阿新 • • 發佈:2021-08-12
gitlab安裝
配置:2核/2G+
# 方式方法一:下載gitlab-ce的rpm包 [gitlab官方rpm包下載](https://packages.gitlab.com/gitlab/gitlab-ce) [清華的源](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/) # 方式二:配置yum源 [root@node2 ~]# vim /etc/yum.repos.d/gitlab.repo [gitlab-ce] name=gitlab-ce baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ Repo_gpgcheck=0 Enabled=1 gpgcheck=0 Gpgkey=https://packages.gitlab.com/gpg.key [root@node2 ~]# yum clean all && yum makecache [root@node2 ~]# yum -y install gitlab-ce ===>最新版(會報錯) [root@node2 ~]# yum -y install gitlab-ce-13.6.1 ===>指定版本 [root@node2 ~]# yum -y install gitlab-ce --nogpgcheck ===>不檢查安裝 # 配置gitlab預設配置檔案 [root@node2 ~]# vim /etc/gitlab/gitlab.rb external_url 'http://192.168.1.112' ===>這裡一定要加上http:// ==========按需部分========= 配置郵件服務 gitlab_rails['time_zone'] = 'Asia/Shanghai' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "[email protected]" # 自己的qq郵箱賬號 gitlab_rails['smtp_password'] = "xxx" # 開通smtp時返回的授權碼 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['gitlab_email_from'] = "[email protected]" # 指定傳送郵件的郵箱地址 user["git_user_email"] = "[email protected]" # 指定接收郵件的郵箱地址 修改好配置檔案後,要使用 gitlab-ctl reconfigure 命令過載一下配置檔案,否則不生效 [root@node2 ~]# gitlab-ctl reconfigure # 過載配置檔案 Gitlab常用命令 # 啟停所有 gitlab元件 [root@node2 ~]# gitlab-ctl {start|stop|restart|status} # 啟動服務(重新編譯gitlab的配置) [root@node2 ~]# gitlab-ctl reconfigure # 驗證配置檔案 [root@node2 ~]# gitlab-ctl show-config # 檢查gitlab [root@node2 ~]# gitlab-rake gitlab:check SANITIZE=true --trace # 檢視日誌 [root@node2 ~]# gitlab-ctl tail gitlab-ctl tail nginx/gitlab_access.log gitlab-ctl tail nginx/gitlab_error.log # 常用目錄 日誌地址:/var/log/gitlab/ # 對應各服務的列印日誌 服務地址:/var/opt/gitlab/ # 對應各服務的主目錄 # 獲取首次登陸密碼(帳號是root) [root@node2 ~]# cat /etc/gitlab/initial_root_password | grep ^Password Password: O49qyh77jH4e4RSwqTEhvh6GP1xKy22ZgpomEuv8zrY= 外網訪問的埠,如果伺服器已經有伺服器佔用了80,可將其改成 server { listen *:8888; server_name gitlab.test.domain.com; access_log /var/log/gitlab/nginx/gitlab_access.log gitlab_access; error_log /var/log/gitlab/nginx/gitlab_error.log; if ($http_host = "") { set $http_host_with_default "gitlab.test.domain.com:8888"; } 建立專案(假設專案名叫app01)--->建立組--->建立使用者-->新增User到Group中並授權---> | 配置SSH(右上角個人-settings-SSH Keys)--->往專案中新增成員---> | 將本地檔案推送到Gitlab---> # 將app01專案克隆下來 git clone [email protected]:java/app01.git # 初始化配置 git config --global user.name "hgzero" git config --global user.email "[email protected]" # 推送到gitlab git add . git commit -m "first edition" git push origin master
GitLab備份和恢復
備份
[root@node2 ~]# vim /etc/gitlab/gitlab.rb # 備份儲存的位置,這裡是預設位置,可修改成指定的位置 # gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" # 設定備份儲存的時間,超過此時間的日誌將會被新覆蓋 # gitlab_rails['backup_keep_time'] = 604800 # 這是預設設定,儲存7天 如果自定義了備份儲存位置,則要修改備份目錄的許可權,比如: [root@node2 ~]# chown -R git.git /data/backup/gitlab # 重讀配置檔案 gitlab-ctl reconfigure # 重啟gitlab gitlab-ctl restart # 可以將此命令寫入crontab,以實現定時備份 [root@node2 ~]# /usr/bin/gitlab-rake gitlab:backup:create 設定定時任務 [root@node2 ~]# crontab -e #每天凌晨2點定時建立備份 0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create 備份時間的識別 # 備份後的檔案類似這樣的形式:1494170842_gitlab_backup.tar,可以根據前面的時間戳確認備份生成的時間 [root@node2 ~]# date -d @1494170842 2017年 05月 07日 星期日 11:27:22 EDT
恢復gitlab
# 停止資料寫入服務 [root@node2 ~]# gitlab-ctl stop unicorn [root@node2 ~]# gitlab-ctl stop sidekiq # 進行恢復 # 下面的時間戳就是剛剛備份的檔案前面的時間戳 [root@node2 ~]# gitlab-rake gitlab:backup:restore BACKUP=1494170842 # 重啟 gitlab-ctl restart 伺服器修改過ssh埠的坑(需要修改配置ssh埠) # 如修改了ssh埠,則需在gitlab中配置ssh地址 # gitlab會在前面加上協議頭和埠號"ssh://[email protected]:55725/huangdc/test.git" [root@node2 ~]# vim /etc/gitlab/gitlab.rb gitlab_rails['gitlab_shell_ssh_port'] = 55725 #使配置生效 [root@node2 ~]# gitlab-ctl reconfigure #重新啟動GitLab [root@node2 ~]# gitlab-ctl restart