yum install -y curl policycoreutils-python openssh-server vim wget firewalld systemctl enable sshd systemctl start sshd systemctl restart firewalld firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https systemctl reload firewalld
安装邮箱
yum install postfix systemctl enable postfix systemctl start postfix
注意:sudo systemctl start postfix 如果报错
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
fatal: parameter inet_interfaces: no local interface found for ::1
修改postfix的设置
vim /etc/postfix/main.cf
inet_protocols = all
inet_interfaces = all
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce-11.11.2-ce.0.el7
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.11.2-ce.0.el7.x86_64.rpm rpm -ivh gitlab-ce-11.11.2-ce.0.el7.x86_64.rpm
vim /etc/gitlab/gitlab.rb #修改配置项 external_url:http://本机ip
gitlab-ctl reconfigure
重启gitlab
gitlab-ctl restart
搭建gitlab-runner
curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_amd64.rpm rpm -i gitlab-runner_amd64.rpm
报错:
warning: gitlab-runner_amd64.rpm: Header V4 RSA/SHA512 Signature, key ID 880721d4: NOKEY
error: Failed dependencies:
git is needed by gitlab-runner-13.2.2-1.x86_64
解决方法:
yum install -y git
将gitlab-runner注册到gitlab-server上
gitlab-runner register
查看gitlab-runner列表
gitlab-runner list
下载docker 二进制包
wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.6.tgz
解压docker包
tar -xvf docker-18.09.6.tgz mv docker/* /usr/bin/
配置docker的配置文件
vim /etc/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=http://docs.docker.io [Service] WorkingDirectory=/data/docker Environment="PATH=/bin:/sbin:/usr/bin:/usr/sbin" ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure RestartSec=5 LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Delegate=yes KillMode=process [Install] WantedBy=multi-user.targe
mkdir -p /etc/docker/ mkdr -p /data/docker/
配置docker加速源文件
vim /etc/docker/daemon.json { "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","https://hub-mirror.c.163.com"], "insecure-registries": ["docker02:35000"], "max-concurrent-downloads": 20, "live-restore": true, "max-concurrent-uploads": 10, "debug": true, "data-root": "/data/docker/data", "exec-root": "/data/docker/exec", "log-opts": { "max-size": "100m", "max-file": "5" } }
启动docker服务
systemctl daemon-reload && systemctl restart docker && systemctl status docker
测试gitlab-runner是否好用
错误1:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
vim /etc/sudoers gitlab-runner ALL=(ALL) ALL
find / -name docker.sock 路径在: /run/docker.sock
Docker设置权限下放改普通用户
chmod a+rw /run/docker.sock