深圳網(wǎng)站建設(shè)公司設(shè)計(jì)推廣產(chǎn)品的方法和步驟
這里寫目錄標(biāo)題
- 部署篇
- 序言
- 要求
- 檢查系統(tǒng)是否安裝OpenSSH
- 防火墻問題
- 準(zhǔn)備
- gitlab.rb 配置
- 坑點(diǎn)一
- 忘記root密碼重置
- 使用篇
- gitlab轉(zhuǎn)換成中文
- git關(guān)閉注冊入口
- 創(chuàng)建用戶
部署篇
序言
在團(tuán)隊(duì)開發(fā)過程中,想要擁有高效的開發(fā)效率,選擇一個(gè)好的代碼開發(fā)工具是必不可少的。搭建git服務(wù)器有兩種方式
● github(國外的,很卡)或者gitee(國內(nèi)的,網(wǎng)速還可以,可以設(shè)置項(xiàng)目為私有,防止其他人可見)
● 通過gitlab搭建自己的git服務(wù)器
要求
● gitlab十分吃內(nèi)存,建議內(nèi)存至少4G起步,以便遇到各種各樣的坑
社長自己部署的這臺服務(wù)器只部署了gitlab+jenkins,給大家看看服務(wù)器的開銷
- 這還是社長設(shè)置交換區(qū)才導(dǎo)致內(nèi)存開銷沒有這么大
檢查系統(tǒng)是否安裝OpenSSH
yum -q list openssh-server
如果沒有安裝可使用如下命令安裝
yum -y install oepnssh-server
檢查系統(tǒng)是否啟動(dòng)OpenSSH服務(wù)器
systemctl status sshd
如果OpenSSH服務(wù)器沒有啟動(dòng),則手動(dòng)啟動(dòng)
systemctl start sshd
[CentOS7]設(shè)置sshd開機(jī)自動(dòng)啟動(dòng)
systemctl enable sshd
如果設(shè)置sshd啟動(dòng)后,sshd狀態(tài)仍沒有啟動(dòng),檢查防火墻是否阻止了ssh服務(wù)
firewall-cmd --list-service
- 正確情況下,應(yīng)該顯示這個(gè),可能提示FirewallD is not running
防火墻問題
1、啟動(dòng)FirewallD服務(wù)命令:
systemctl start firewalld.service #開啟服務(wù)
systemctl enable firewalld.service #設(shè)置開機(jī)啟動(dòng)
2、查看FirewallD防火墻狀態(tài):
systemctl status firewalld
準(zhǔn)備
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
# 安裝發(fā)送郵件功能的postfix
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
gitlab.rb 配置
### 項(xiàng)目訪問的地址 47.XXX.XXX.XX是服務(wù)器地址 8888是端口
external_url 'http://47.XXX.XXX.XX:8888'
###oracle的相關(guān)配置
postgresql['shared_buffers'] = "64MB"
postgresql['max_worker_processes'] = 1
postgresql['shared_buffers'] = "64MB"
sidekiq['concurrency'] = 1
puma['worker_processes'] = 1
###修改端口
puma['port'] = 8081
#unicorn['worker_processes'] = 1
nginx['worker_processes'] = 2
#puma['worker_timeout'] = 10
- 主要減少內(nèi)存的開銷
坑點(diǎn)一
- 界面出現(xiàn)502,cpu狂飆,使用top命令查看
14的寫法
#實(shí)時(shí)打印puma包的日志
sudo gitlab-ctl tail puma
坑點(diǎn)1: 會默認(rèn)使用8080端口,導(dǎo)致軟件死循環(huán),cpu狂飆
puma['port'] = 8081
- 修改端口為不常用端口,防止沖突
忘記root密碼重置
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:525:in `handle_argument_error': ERROR: "rails console" was called with arguments ["production"] (Thor::InvocationError)
Usage: "rails console [options]"from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:34:in `rescue in run'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:20:in `run'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command/base.rb:69:in `perform'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command.rb:48:in `invoke'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/commands.rb:18:in `<top (required)>'from bin/rails:4:in `require'from bin/rails:4:in `<main>'
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/commands/console/console_command.rb:95:in `perform': wrong number of arguments (given 1, expected 0) (ArgumentError)from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command/base.rb:69:in `perform'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command.rb:48:in `invoke'from /opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/commands.rb:18:in `<top (required)>'from bin/rails:4:in `require'from bin/rails:4:in `<main>'
- 懷疑是版本問題,換一條命令,使用如下命令、
###登錄控制臺命令
gitlab-rails console -e production
##查看root用戶
User.where(username:"root").first
### 修改密碼,注意字符+數(shù)字+特殊符號,不然提醒賬號密碼太簡單
user.password = "Test@1234"
### 保存密碼
user.save!
### 退出
quit
使用篇
gitlab轉(zhuǎn)換成中文
點(diǎn)擊右上角頭像,prefenrecess->選擇中文簡寫
- 修改配置后,需要重新登錄才生效
git關(guān)閉注冊入口
既然搭建gitlab服務(wù)器,大部分用戶的場景代碼都是不對外開源的。所以我們需要關(guān)閉git注冊接口
- 去掉已啟用注冊功能勾選
創(chuàng)建用戶
- 不同的版本,用戶的新建界面會有所不一樣
- 名稱可以為中文
- 用戶名就是賬號,例如test
- 電子郵件,輸入你的郵箱 確定是真實(shí)郵箱就行
- 密碼,長度超過8位
- 權(quán)限,根據(jù)你的需求設(shè)置
gitlab相關(guān)使用還未完,后續(xù)會迭代更新gitlab相關(guān)使用的教程