jenkins迁移

如果Jenkins容器docker安装:

docker run --privileged -d -p 9090:8080 -p 50000:50000 -v /var/lib/jenkins:/var/jenkins_home -v /etc/localtime:/etc/localtime -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock://var/run/docker.sock -u root --restart=always --name=jenkins jenkins/jenkins

 

前提,将192.168.77.100节点的jenkins迁移到192.168.77.102上

 192.168.77.102节点:

1、安装openjdk:

[root@node2 ~]# yum install java-11-openjdk.x86_64

2、安装jenkins:

[root@node2 ~]# wget -O /etc/yum.repos.d/jenkins.repo --no-check-certificate https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@node2 ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
[root@node2 ~]# yum install jenkins -y

3、将Jenkins服务启动用户修改为root:

[root@node2 ~]# grep "root" /usr/lib/systemd/system/jenkins.service
User=root
Group=root
[root@node2 ~]# systemctl start jenkins
[root@node2 ~]# systemctl status jenkins

Jenkins服务安装成功后,接下来开始迁移

将192.168.77.100节点的Jenkins服务进行stop,/var/lib/jenkins进行备份:

[root@node2 ~]# systemctl stop jenkins
[root@node2 ~]# cd /var/lib/
[root@node2 lib]# mv jenkins jenkins.bak

将192.168.77.100节点上的/var/lib/jenkins copy到节点192.168.77.102

[root@node1 lib]# scp -r jenkins root@192.168.77.102:/var/lib/

192.168.77.102节点进行查看:

[root@node2 lib]# ls -ld jenkins*
drwxr-xr-x. 16 root    root    4096 Jul 28 05:11 jenkins
drwxr-xr-x.  9 jenkins jenkins 4096 Jul 28 05:09 jenkins.bak

然后启动192.168.77.102节点Jenkins服务:

[root@node2 lib]# systemctl start jenkins
[root@node2 lib]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-07-28 05:12:49 EDT; 6s ago
 Main PID: 18724 (java)
   CGroup: /system.slice/jenkins.service
           └─18724 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080

Jul 28 05:12:48 node2 jenkins[18724]: 2024-07-28 09:12:48.521+0000 [id=30]        INFO        jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
Jul 28 05:12:48 node2 jenkins[18724]: 2024-07-28 09:12:48.562+0000 [id=30]        INFO        jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
Jul 28 05:12:48 node2 jenkins[18724]: WARNING: An illegal reflective access operation has occurred
Jul 28 05:12:48 node2 jenkins[18724]: WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/var/lib/jenkins/%25C/jenkins/war/WEB-INF/lib/groovy-all-2.4.21.jar...ang.Class,int)
Jul 28 05:12:48 node2 jenkins[18724]: WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
Jul 28 05:12:48 node2 jenkins[18724]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
Jul 28 05:12:48 node2 jenkins[18724]: WARNING: All illegal access operations will be denied in a future release
Jul 28 05:12:49 node2 jenkins[18724]: 2024-07-28 09:12:49.011+0000 [id=30]        INFO        jenkins.InitReactorRunner$1#onAttained: Completed initialization
Jul 28 05:12:49 node2 jenkins[18724]: 2024-07-28 09:12:49.041+0000 [id=22]        INFO        hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
Jul 28 05:12:49 node2 systemd[1]: Started Jenkins Continuous Integration Server.
Hint: Some lines were ellipsized, use -l to show in full

 使用192.168.77.100节点上的用户登录102Jenkins正常,查看job也是迁移正常,至此Jenkins迁移完成

posted on 2024-07-28 17:15  wadeson  阅读(145)  评论(0编辑  收藏  举报