架构班小伙伴作业看这里:(学习杰哥视频的作业第23-24天)
1、安装配置jenkins
Jenkins 部署与基础配置:https://jenkins.io/zh/
1.1:配置 java 环境并部署 jenkins:
1.1.1:java 环境配置:
root@jenkins:/usr/local/src# tar xvf jdk-8u192-linux-x64.tar.gz
root@jenkins:/usr/local/src# ln -sv /usr/local/src/jdk1.8.0_192/ /usr/local/jdk
root@jenkins:/usr/local/src# ln -sv /usr/local/jdk/bin/java /usr/bin/ #java 命令软连接
root@jenkins:/usr/local/src# vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
root@jenkins:/usr/local/src# source /etc/profile
root@jenkins:/usr/local/src# java -version
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
1.1.2:启动 Jenkins
1.1.2.1:通过 jar 包直接启动 jenkins:
# java \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=12345 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname="192.168.8.2
" \
-jar jenkins-2.138.3.war &
1.1.2.2:rpm 包安装 jenkins 配置:
[root@s1 ~]# grep -v "#" /etc/sysconfig/jenkins | grep -v "^$"
JENKINS_HOME="/var/lib/jenkins"
JENKINS_JAVA_CMD=""
JENKINS_USER="jenkins"
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=12345 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname="192.168.7.101" \
"
JENKINS_PORT="8080"
JENKINS_LISTEN_ADDRESS=""
JENKINS_HTTPS_PORT=""
JENKINS_HTTPS_KEYSTORE=""
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
JENKINS_HTTPS_LISTEN_ADDRESS=""
JENKINS_DEBUG_LEVEL="5"
JENKINS_ENABLE_ACCESS_LOG="no"
JENKINS_HANDLER_MAX="100"
JENKINS_HANDLER_IDLE="20"
JENKINS_ARGS=""
可选启动参数:
JENKINS_JAVA_OPTIONS="-server -Xms1g -Xmx1g -Xss512k -Xmn1g
-XX:CMSInitiatingOccupancyFraction=65
-XX:+UseFastAccessorMethods
-XX:+AggressiveOpts -XX:+UseBiasedLocking
-XX:+DisableExplicitGC -XX:MaxTenuringThreshold=10
-XX:NewSize=2048M -XX:MaxNewSize=2048M -XX:NewRatio=2
-XX:PermSize=128m -XX:MaxPermSize=512m -XX:CMSFullGCsBeforeCompaction=5
-XX:+ExplicitGCInvokesConcurrent -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
-XX:+CMSParallelRemarkEnabled -Djava.awt.headless=true
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname="192.168.7.104" "
1.1.6:插件安装过程中:
1.1.9:配置完成并登陆 jenkins:
2、安装配置gitlab,并创建magedu仓库代码,分配mage用户对仓库有完全控制权限。
1 下载rpm包
安装包下载地址:
https://packages.gitlab.com/gitlab/gitlab-ce
rpm 包国内下载地址:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
2 安装依赖
# yum -y install policycoreutils-python
3 安装
# rpm -ivh gitlab-ce-11.3.11-ce.0.el7.x86_64.rpm
4 修改配置文件
#vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.7.103'
#可选邮件通知设置
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "4785d66ss5qa12cty7"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = "[email protected]"
user["git_user_email"] = "[email protected]"
5 初始化并启动服务
# gitlab-ctl reconfigure
6 初次访问会提示重置密码,设置后跳转到登录,默认管理用户名root,密码为刚设置的密码
7 在web界面新建项目magedu,创建mage用户设置为管理员权限