-
私有程式碼倉庫,除了Gitlab還有gogs
-
精細化的許可權配置
-
控制使用者/使用者組許可權,避免任何使用者都可以將程式碼提交master
# 使用清華源,直接安裝
[root@gitlab ~]
# yum install -y https://mirrors.tuna.tsinghua.edu.cn/gitlabce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
[root@gitlab ~]
# yum localinstall -y gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
# 安裝過程
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 reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
# 1.修改配置檔案
[root@gitlab ~]
# vim /etc/gitlab/gitlab.rb
external_url
'http://gitlab.wc.com'
# 新增郵箱相關配置
gitlab_rails[
'gitlab_email_enabled'
] =
true
gitlab_rails[
'gitlab_email_from'
] =
gitlab_rails[
'gitlab_email_display_name'
] =
'wc gitlab notice'
gitlab_rails[
'smtp_enable'
] =
true
gitlab_rails[
'smtp_address'
] =
"smtp.qq.com"
gitlab_rails[
'smtp_port'
] = 465
gitlab_rails[
'smtp_user_name'
] =
gitlab_rails[
'smtp_password'
] =
"dizyzzjjujhxdefe"
gitlab_rails[
'smtp_domain'
] =
"qq.com"
gitlab_rails[
'smtp_authentication'
] =
"login"
gitlab_rails[
'smtp_enable_starttls_auto'
] =
true
gitlab_rails[
'smtp_tls'
] =
true
prometheus[
'enable'
] =
false
prometheus[
'monitor_kubernetes'
] =
false
prometheus_monitoring[
'enable'
] =
false
node_exporter[
'enable'
] =
false
redis_exporter[
'enable'
] =
false
postgres_exporter[
'enable'
] =
false
gitlab_monitor[
'enable'
] =
false
grafana[
'enable'
] =
false
alertmanager[
'enable'
] =
false
# 2.重新載入配置檔案
[root@gitlab ~]
# gitlab-ctl reconfigure
Chef Client finished, 299/430 resources updated
in
02 minutes 28 seconds
gitlab Reconfigured!
# 檢視當前服務狀態
[root@gitlab git]
# gitlab-ctl status
# 停止所有服務
[root@gitlab git]
# gitlab-ctl stop
# 啟動所有服務
[root@gitlab git]
# gitlab-ctl start
# 重啟所有服務
[root@gitlab git]
# gitlab-ctl restart
# 停止指定服務
[root@gitlab git]
# gitlab-ctl stop nginx
# 啟動指定服務
[root@gitlab git]
# gitlab-ctl start nginx
# 檢視Gitlab所有元件日誌
[root@gitlab git]
# gitlab-ctl tail
# 檢視Gitlab指定元件日誌
[root@gitlab git]
# gitlab-ctl tail nginx
# 連線Gitlab終端
[root@gitlab git]
# gitlab-rails console
# 測試發郵件
irb(main):012:0> Notify.test_email(
,
'sbsbsb'
,
'hei/hei/hei'
).deliver_now
# 忘記root密碼
[root@gitlab git]
# gitlab-rails console
## 登入root使用者
irb(main):011:0> user = User.where(
id
: 1).first
irb(main):012:0> user.password=
'123456789'
irb(main):012:0> user.password_confirmation=
'123456789'
irb(main):012:0> user.save




# 1.下載漢化包
[root@gitlab ~]
# wget https://gitlab.com/xhang/gitlab/-/archive/10-2-stable-zh/gitlab10-2-stable-zh.tar.gz
# 2.解壓漢化包
[root@gitlab ~]
# tar xf gitlab-10-2-stable-zh.tar.gz
# 3.停止所有服務
[root@gitlab ~]
# gitlab-ctl stop
# 4.覆蓋
[root@gitlab ~]
# \cp -a gitlab-10-2-stable-zh/* /opt/gitlab/embedded/service/gitlabrails/
# 5.重新載入配置檔案
[root@gitlab ~]
# gitlab-ctl reconfigure
# 6.啟動所有服務
[root@gitlab ~]
# gitlab-ctl start



HTTP命令列指令
Git 全域性設定
git config --global user.name
"Administrator"
git config --global user.email
建立新版本庫
git
clone
http://gitlab.zls.com/root/linux2.git
cd
linux2
touch
README.md
git add README.md
git commit -m
"add README"
git push -u origin master
已存在的資料夾
cd
existing_folder
git init
git remote add origin http://gitlab.zls.com/root/linux2.git
git add .
git commit -m
"Initial commit"
git push -u origin master
已存在的 Git 版本庫
cd
existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.zls.com/root/linux2.git
git push -u origin --all
git push -u origin --tags

SSH命令列指令
Git 全域性設定
git config --global user.name
"Administrator"
git config --global user.email
建立新版本庫
git
clone
[email protected]:root/linux2.git
cd
linux2
touch
README.md
git add README.md
git commit -m
"add README"
git push -u origin master
已存在的資料夾
cd
existing_folder
git init
git remote add origin [email protected]:root/linux2.git
git add .
git commit -m
"Initial commit"
git push -u origin master
已存在的 Git 版本庫
cd
existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:root/linux2.git
git push -u origin --all
git push -u origin --tags
# 1.新增遠端倉庫
[root@gitlab web]
# git remote add zls [email protected]:root/linux2.git
# 2.新增hosts解析
[root@gitlab web]
# vim /etc/hosts
10.0.0.91 gitlab.zls.com
# 3.生成秘鑰
[root@gitlab git]
# ssh-keygen
# 4.檢視公鑰
[root@gitlab git]
# cat ~/.ssh/id_rsa.pub
# 5.網頁新增ssh秘鑰









# 克隆程式碼
[root@gitlab opt]
# git clone [email protected]:ops/new_linux2.git
# 同步倉庫程式碼跟gitlab中保持一致
[root@gitlab new_linux2]
# git pull
# 拉所有分支程式碼
[root@gitlab new_linux2]
# git fetch -vp

文末福利

即將步入2025年,不少小夥伴在考慮來年的工作方向。
僅目前來說,傳統運維衝擊年薪30W+的轉型方向就是SRE&DevOps崗位。









