Gitlab+Nexus Maven部署

一、環境說明

操作系統:centos 7.5 x86_64

JAVA版本:jdk-8u181

Gitlab版本:gitlab-ee-10.0.0

Nexux Maven版本:nexus-2.14.1-01

二、安裝前準備

# systemctl disable firewalld.service
# systemctl stop firewalld.service
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# setenforce 0
# hostnamectl --static set-hostname  gitlab-nexus

三、安裝Gitlab

1.安裝依賴包

yum -y install postfix cronie curl policycoreutils-python openssh-server

2.下載gitlab服務包

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

新建gitlab-ce安裝源

# cd /etc/yum.repos.d/
# cp gitlab-ee.repo gitlab-ee.repo-bak
# vi gitlab-ee.repo
[gitlab-ee]  
name=gitlab-ee  
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7
repo_gpgcheck=0  
gpgcheck=0  
enabled=1  
gpgkey=https://packages.gitlab.com/gpg.key  

# yum -y install gitlab-ee

3.修改gitlab對外服務url

# vi /etc/gitlab/gitlab.rb
將external_url 'http://gitlab.example.com'改爲
external_url http://{自定義IP或域名}
如要修改gitlab默認端口號
external_url http://{自定義IP或域名}:{port}

4.開啓gitlab

# gitlab-ctl reconfigure

5.訪問gitlab
http://{自定義IP或域名}:{port}
修改密碼,默認用戶名root

6.創建project
安裝git工具

# yum -y install git

生成密鑰文件

# ssh-keygen
# cat /root/.ssh/id_rsa.pub
不創建ssh密碼gitlab無法推送文件

注:關閉服務器前先使用gitlab-ctl stop命令關閉git

補充說明:

禁止普通用戶創建組

# vi /etc/gitlab/gitlab.rb中
gitlab_rails['gitlab_default_can_create_group'] = false
保存,重新gitlab-ctrl reconfigure

查看gitlab的版本信息

# head -1 /opt/gitlab/version-manifest.txt

給用戶分配賬戶
用http方式,新建”Visibility Level”時選擇內部

四、安裝Nexus Maven

1.下載並解壓jdk-1.8_181

# tar -zxvf jdk-8u181-linux-x64.tar.gz -C /opt

2.配置JAVA環境變量

# cat > /etc/profile.d/jdk.sh <<EOF
# Java environment configuratione
export JAVA_HOME=/opt/jdk1.8.0_181
export JAVA_BIN=/opt/jdk1.8.0_181/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
EOF

# source /etc/profile.d/jdk.sh

3.下載並解壓nexus-2.14.1

# wget http://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.1-01-bundle.tar.gz
# mkdir /opt/nexus2.14
# tar -zxvf nexus-2.14.1-01-bundle.tar.gz -C /opt/nexus2.14

解壓後會生成兩個目錄nexus-2.14.1-01和sonatype-work

4.設置nexus環境變量

# cat > /etc/profile.d/nexus.sh <<EOF
NEXUS_HOME=/opt/nexus2.14/nexus-2.14.1-01
export PATH=$NEXUS_HOME/bin/:$PATH
EOF

# source /etc/profile.d/nexus.sh

修改配置文件

# vi /opt/nexus2.14/nexus-2.14.1-01/bin/nexus
修改NEXUS_HOME=".."
爲
NEXUS_HOME="/opt/nexus2.14/nexus-2.14.1-01"

修改#RUN_AS_USER=
爲
RUN_AS_USER=nexus

添加JAVA_HOME路徑
JAVA_HOME=/opt/jdk1.8.0_181

5.啓動nexus並訪問,默認管理者admin/admin123,默認發佈者賬號deployment/deployment123

# nexus start

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章