本文最后更新于 952 天前,其中的信息可能已经有所发展或是发生改变。
Docker
Docker安装
- 添加yum源,官网地址:https://docs.docker.com/engine/install/
yum install -y yum-utils #安装依赖
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
- 安装Docker
yum install docker-ce docker-ce-cli containerd.io - 启动Docker
systemctl start docker
systemctl enable docker #开机自启
Docker Compose安装
- 下载Docker Compose,官网地址:https://docs.docker.com/compose/install/
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- 将docker-compose设置成可执行文件
chmod +x /usr/local/bin/docker-compose
GitLab
GitLab安装
- 最低硬件要求,官网地址:https://docs.gitlab.cn/jh/install/requirements.html
- 安装SSH
#安装SSH依赖
yum install -y curl policycoreutils-python openssh-server perl
#启动SSH
systemctl enable sshd
systemctl start sshd
#系统防火墙中打开HTTP和HTTPS访问
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
- 安装GitLab,官网地址:https://about.gitlab.cn/install/
#下载软件包
wget https://omnibus.gitlab.cn/el/7/gitlab-jh-14.9.2-jh.0.el7.x86_64.rpm
#安装GitLab
rpm -Uvh gitlab-jh-14.9.2-jh.0.el7.x86_64.rpm
- 编辑配置文件
#编辑配置文件
vi /etc/gitlab/gitlab.rb
# external_url 'http://192.168.153.52:8929' #UI界面访问地址
# gitlab_rails['gitlab_shell_ssh_port'] = 2224 #SSH端口
#
# git_data_dirs
# /var/opt/gitlab #数据目录
# /var/log/gitlab #日志目录
# /etc/gitlab #配置文件目录
# /opt/gitlab #安装目录
#重新加载配置文件
gitlab-ctl reconfigure
- 添加SELinux默认安全上下文,以便SSH服务正常访问
semanage fcontext -a -t ssh_home_t /var/opt/gitlab/.ssh/ #给.ssh文件添加ssh_home_t类型的安全上下文
semanage fcontext -a -t ssh_home_t /var/opt/gitlab/.ssh/authorized_keys
restorecon -F -Rv /var/opt/gitlab/.ssh/ #刷新.ssh文件的安全上下文
小贴士:`semanage fcontext` -a 添加默认安全上下文,-t 指定安全上下文类型。
# ls -Zd .ssh/authorized_keys
# -rw-------. git git system_u:object_r:ssh_home_t:s0 .ssh/authorized_keys
# 可以看到该文件的默认安全上下文类型(object_r)是ssh_home_t
- 密码储在
/etc/gitlab/initial_root_password文件
GitLab常用命令
gitlab-ctl start #启动所有gitlab组件
gitlab-ctl stop #停止所有gitlab组件
gitlab-ctl restart #重启所有gitlab组件
gitlab-ctl status #查看服务状态
gitlab-ctl reconfigure #重新编译gitlab的配置
gitlab-rake gitlab:check SANITIZE=true --trace #检查gitlab
gitlab-ctl tail #查看日志
gitlab-ctl tail nginx/gitlab_access.log
Jenkins
Jenkins安装
- 添加yum源,官方地址:https://www.jenkins.io/download/
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key #导入Jenkins的rpm包密钥
- 安装字体、JDK和Jenkins
yum install fontconfig java-11-openjdk
yum install jenkins
- 启动Jenkins,端口默认8080
systemctl start jenkins
systemctl enable jenkins #开机自启
- 密码储在
/var/lib/jenkins/secrets/initialAdminPassword文件
Nexus
Nexus安装
- 下载nexus-3.38.1-01-unix.tar.gz文件,官方地址:https://help.sonatype.com/repomanager3/product-information/download/
- 安装JDK
yum install java-1.8.0-openjdk - 解压并运行Nexus
tar -zxvf nexus-3.38.1-01-unix.tar.gz
#解压后得到2个文件
#nexus-3.38.1-01 实现nexus功能
#sonatype-work 存储数据
#运行nexus
nexus start
# 小贴士:NEXUS的默认端口8081,可以通过nexus-default.properties配置文件指定
# vi nexus-3.38.1-01/etc/nexus-default.properties
# application-port=8081
- 密码储在
/root/sonatype-work/nexus3/admin.password文件 - 开机启动
#设置Nexus环境变量
vi /etc/profile
# export NEXUS_HOME=/opt/nexus/nexus-3.38.1-01/bin
source /etc/profile
#编辑systemctl启动命令
cat > /usr/lib/systemd/system/nexus.service << EOF
[Unit]
Description=nexus
After=network.target
[Service]
Type=forking
ExecStart=/opt/nexus/nexus-3.38.1-01/bin/nexus start \
ExecReload=/opt/nexus/nexus-3.38.1-01/bin/nexus restart \
ExecStop=/opt/nexus/nexus-3.38.1-01/bin/nexus stop \
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload #重新加载服务
systemctl enable nexus #开机自启
Nexus常用命令
nexus run #当前进程启动服务(日志输出在命令行)
nexus start #守护进程启动服务(日志保存在文件中)
nexus stop #停止服务
nexus restart #重启服务
nexus status #查看服务状态
