『中級篇』docker之CI/CD持續整合-gitlab安裝(70)
阿新 • • 發佈:2018-12-13
建立虛擬機器
- vagrant檔案的配置
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version ">= 1.6.0" boxes = [ { :name => "gitlab", :mem => "4096", :cpu => "2" } ] Vagrant.configure(2) do |config| config.vm.box = "centos/7" boxes.each do |opts| config.vm.define opts[:name] do |config| config.vm.hostname = opts[:name] config.vm.provider "vmware_fusion" do |v| v.vmx["memsize"] = opts[:mem] v.vmx["numvcpus"] = opts[:cpu] end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", opts[:mem]] v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] end config.vm.network :private_network, type: "dhcp" end end config.vm.provision "shell", privileged: true, path: "./setup.sh" end
- setup.sh的配置
#/bin/sh
sudo yum install -y yum upgrade
sudo yum install -y net-tools
sudo yum install -y curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
sudo yum install -y java-1.8.0-openjdk.x86_64
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
執行命令建立
#原始碼No.11的gitlab目錄
vagrant up
更改安裝源
新建 /etc/yum.repos.d/gitlab-ce.repo,內容為
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
- 執行命令
sudo yum makecache
sudo yum install gitlab-ce
- 安裝成功!
- 執行下面的命令進行配置
sudo gitlab-ctl reconfigure
- 檢視ip地址
ip a
登入網址
#登入,修改root密碼。並登入 使用者名稱是root,密碼是剛設定的
http://172.28.128.3
修改主機的名字
sudo vi /etc/gitlab/gitlab.rb
#上邊的修改儲存後,需要執行下面的命令才可以生效
sudo gitlab-ctl reconfigure
關機後,重啟gitlab的命令
gitlab-ctl restart
···
PS:gitlab安裝基本就是這樣也不是很複雜,主要是必須更改源,國內的牆太高太寬了。
![](http://upload-images.jianshu.io/upload_images/11223715-3407e1c7ac8d7935?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)