ubunut二进制部署Jenkins环境

Jenkins的安裝参考网址:
    https://www.jenkins.io/doc/book/installing/


        1.设置字符集环境,方式后期Jenkins汉化
root@jenkins166:~# localectl set-locale LANG=en_US.UTF-8


    2.修改软件源
root@jenkins166:~# cat /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
root@jenkins166:~# 

    参考链接:
        https://developer.aliyun.com/mirror/ubuntu
        
        
    3.部署jdk环境
root@jenkins166:~# netplan apply 
root@jenkins166:~# 
root@jenkins166:~# ping baidu.com  # 检查能否正常联网
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=1 ttl=128 time=7.37 ms
...

root@jenkins166:~# apt-get update 

root@jenkins166:~# apt-get -y install openjdk-11-jdk-headless

root@jenkins166:~# java --version 
openjdk 11.0.19 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu120.04.1)
OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu120.04.1, mixed mode, sharing)
root@jenkins166:~# 


    4.安装Jenkins
root@jenkins166:~# wget  http://192.168.11.253/Kubernetes/day10-/softwares/jenkins_2.375.3_all.deb
root@jenkins166:~# dpkg -i jenkins_2.375.3_all.deb 


    5.查看Jenkins的初始化密码
root@jenkins166:~# systemctl status jenkins.service 
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-06-26 10:14:13 UTC; 1s ago
   Main PID: 5247 (java)
      Tasks: 45 (limit: 4575)
     Memory: 1.2G
     CGroup: /system.slice/jenkins.service
             └─5247 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPor>

Jun 26 10:13:42 jenkins166 jenkins[5247]: f285223c0b4c47e3a53b5afce08a44c8
Jun 26 10:13:42 jenkins166 jenkins[5247]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Jun 26 10:13:42 jenkins166 jenkins[5247]: *************************************************************
Jun 26 10:13:42 jenkins166 jenkins[5247]: *************************************************************
Jun 26 10:13:42 jenkins166 jenkins[5247]: *************************************************************
.... 
root@jenkins166:~#  
root@jenkins166:~# cat /var/lib/jenkins/secrets/initialAdminPassword
f285223c0b4c47e3a53b5afce08a44c8
root@jenkins166:~# 

    6.访问Jenkins的webUI并使用上一步的密码进行登录
http://10.0.0.166:8080/


    7.初始化密码
略。

    8.修改时区。
略。

    9.修改Jenkins的运行账号
root@jenkins166:~# grep User /lib/systemd/system/jenkins.service
User=jenkins
root@jenkins166:~# 
root@jenkins166:~# grep Group /lib/systemd/system/jenkins.service
Group=jenkins
root@jenkins166:~# 
root@jenkins166:~# sed -i '/User=/s#jenkins#root#' /lib/systemd/system/jenkins.service
root@jenkins166:~# 
root@jenkins166:~# sed -i '/Group=/s#jenkins#root#' /lib/systemd/system/jenkins.service
root@jenkins166:~# 
root@jenkins166:~# grep User /lib/systemd/system/jenkins.service
User=root
root@jenkins166:~# 
root@jenkins166:~# grep Group /lib/systemd/system/jenkins.service
Group=root
root@jenkins166:~# 

    10.重启Jenkins验证运行用户是否修改成功
root@jenkins166:~# systemctl daemon-reload
root@jenkins166:~# 
root@jenkins166:~# systemctl restart jenkins.service 
root@jenkins166:~# 
root@jenkins166:~# ps -ef | grep jenkins
root        5840       1 53 10:25 ?        00:00:09 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
root        5975    1171  0 10:26 pts/0    00:00:00 grep --color=auto jenkins
root@jenkins166:~# 


    11.修改Jenkins国内的镜像源
root@jenkins166:~# sed -i.bak 's#updates.jenkins.io/download#mirrors.tuna.tsinghua.edu.cn/jenkins#g' /var/lib/jenkins/updates/default.json 
root@jenkins166:~# 
root@jenkins166:~# sed -i 's#www.google.com#www.baidu.com#g' /var/lib/jenkins/updates/default.json
root@jenkins166:~# 
root@jenkins166:~# ll /var/lib/jenkins/updates/default.json*
-rw-r--r-- 1 jenkins jenkins 2824940 Jun 26 10:30 /var/lib/jenkins/updates/default.json
-rw-r--r-- 1 jenkins jenkins 2807876 Jun 26 10:14 /var/lib/jenkins/updates/default.json.bak
root@jenkins166:~# 


    12.将升级站点URL替换成国内的镜像地址
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

    参考链接:
        https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/
        
        

root@jenkins166:~# systemctl restart jenkins.service 


    13.配置Jenkins汉化

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值