CentOS 7上安裝 Jenkins -- yum 方式
安裝 Jenkins
開源 Devops 工具 Jenkins 在官方博客宣布,從 6 月 28 日發布的 Jenkins 2.357 和將于 9 月發布的 LTS 版本開始,Jenkins 需要 Java 11 才能使用,將放棄 Java 8
由于服務器上裝的Java 8 所以 這邊選擇了,277
#
[root@localhost ~]# ll /etc/yum.repos.d/
總用量 40
-rw-r--r--. 1 root root 1664 4月 8 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月 8 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 4月 8 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 4月 8 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 4月 8 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月 8 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 4月 8 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 4月 8 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2081 3月 9 2022 docker-ce.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
--2022-10-20 17:40:31-- https://pkg.jenkins.io/redhat/jenkins.repo
正在決議主機 pkg.jenkins.io (pkg.jenkins.io)... 151.101.110.133, 2a04:4e42:1a::645
正在連接 pkg.jenkins.io (pkg.jenkins.io)|151.101.110.133|:443... 已連接,
已發出 HTTP 請求,正在等待回應... 200 OK
長度:71
正在保存至: “/etc/yum.repos.d/jenkins.repo”
100%[==========================================>] 71 --.-K/s 用時 0s
2022-10-20 17:40:33 (1.56 MB/s) - 已保存 “/etc/yum.repos.d/jenkins.repo” [71/71])
# 添加成功后,查看
[root@localhost ~]# ll /etc/yum.repos.d/
總用量 48
-rw-r--r--. 1 root root 1664 11月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 11月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 11月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 11月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 11月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2081 3月 9 2022 docker-ce.repo
-rw-r--r--. 1 root root 71 11月 30 2016 jenkins.repo
# 匯入公鑰
[root@localhost ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
# yum 可以更新一下,
[root@localhost ~]# yum upgrade
# 安裝 Jenkins 要加 --nogpgcheck 否則會報 jenkins-2.249.1-1.1.noarch.rpm 的公鑰尚未安裝
[root@localhost ~]# yum install jenkins-2.227 --nogpgcheck
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解決依賴關系
--> 正在檢查事務
---> 軟體包 jenkins.noarch.0.2.227-1.1 將被 安裝
--> 解決依賴關系完成
依賴關系解決
============================================================================================================
Package 架構 版本 源 大小
============================================================================================================
正在安裝:
jenkins noarch 2.227-1.1 jenkins 63 M
事務概要
============================================================================================================
安裝 1 軟體包
總計:63 M
安裝大小:63 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 資料庫已被非 yum 程式修改,
正在安裝 : jenkins-2.227-1.1.noarch 1/1
驗證中 : jenkins-2.227-1.1.noarch 1/1
已安裝:
jenkins.noarch 0:2.227-1.1
完畢!
[root@localhost ~]#
# 修改配置,jenkins安裝成功后,默認的用戶是jenkins,埠是8080,為了防止沖突,并且給用戶賦權限,我們修改用戶名和埠,
# 進到 VI 后 輸入 /PORT 可以快速定位到 PORT 處,修改默認埠
[root@localhost ~]# vi /etc/sysconfig/jenkins
JENKINS_USER="root" #將用戶改成 root
JENKINS_PORT="8888" #修改默認埠
# 添加自啟動
[root@localhost ~]# systemctl enable jenkins
Created symlink from /etc/systemd/system/multi-user.target.wants/jenkins.service to /usr/lib/systemd/system/jenkins.service.
[root@localhost ~]# systemctl start jenkins
# 查看服務狀態
[root@localhost ~]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since 四 2022-10-20 18:53:28 CST; 23s ago
Docs: man:systemd-sysv-generator(8)
Process: 44903 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Main PID: 44248 (code=exited, status=1/FAILURE)
Tasks: 41
Memory: 943.0M
CGroup: /system.slice/jenkins.service
└─44933 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME...
10月 20 18:53:26 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
10月 20 18:53:26 localhost.localdomain runuser[44909]: pam_unix(runuser:session): session opened for user root...d=0)
10月 20 18:53:28 localhost.localdomain jenkins[44903]: Starting Jenkins [ 確定 ]
10月 20 18:53:28 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
Hint: Some lines were ellipsized, use -l to show in full.
# 查看密碼
[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
d63a3493daee4a1645d7a105a0d24b5
[root@localhost ~]#

卸載 Jenkins
# 卸載jenkins服務
[root@localhost ~]# rpm -e jenkins
警告:/etc/sysconfig/jenkins 已另存為 /etc/sysconfig/jenkins.rpmsave
# 檢查是否卸載成功
[root@localhost ~]# rpm -ql jenkins
未安裝軟體包 jenkins
[root@localhost ~]#
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/518743.html
標籤:其他
