具体操作
# 基础环境 # 旧jenkins # cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) # jenkins 家目录及配置 # ls /home/jenkins-master/ backup jenkins jenkins.war start.sh stop.sh # 新机器基础环境 # uname -r 4.14.238-182.422.amzn2.x86_64 # 以下是迁移步骤 # 首先新机器创建用户 useradd jenkins # 拷贝jenkins文件及配置信息 # 因为backup文件夹是备份数据,所以这里掠过该目录 rsync -artvz -e 'ssh' /home/jenkins-master/ awscn-jenkins:/home/jenkins --exclude=backup # 该目录下方的是jenkins的配置信息 rsync -artvz -e 'ssh' /root/.jenkins/ awscn-jenkins:/root/.jenkins # 启动脚本 # cat /home/jenkins-master/start.sh #!/bin/bash HOST=0.0.0.0 PORT=9090 java -jar jenkins.war --httpListenAddress=$HOST --httpPort=$PORT & # 停止脚本 # cat /home/jenkins-master/stop.sh #!/bin/bash pid=$(ps axu |awk '/httpPort=9090/{print $2}') for i in ${pid};do kill -9 ${i}; done # 拷贝完数据后启动服务 su - jenkins -c "cd /home/jenkins/;sh start.sh" # 添加到开机启动 # tail /etc/rc.local su - jenkins -c "cd /home/jenkins/;sh start.sh"