jenkins自动化搭建-redis集群
jenkins的部署请参考以前的文章
Linux下用tomcat部署jenkins
部署jenkins的机器当做推送机对远程部署的机器进行免密,请参考以前的文章
Linux下实现免密登录
编写shell自动化搭建-redis集群脚本,脚本内容如下
redis_create_remote_sync.sh
#!/bin/bash
#init param(sync tar.gz)
remoteTargetPath=$1
redisClusterIp=$2
redisPort=$3
sourcePath=/root/tools/redis/redis-6.2.6.tar.gz
shellFileName=redis_cluster_auto_config.sh
shellPath=/root/tools/shell/redis/remote/jenkins/$shellFileName
function remote_sync(){
#IFS Internal Field Separator是shell脚本中特殊变量,默认分隔符为空格
OLD_IFS=$IFS
IFS=,
arrayIp=($redisClusterIp)
IFS=$OLD_IFS
for ip in ${arrayIp[@]}
do
{
#remote create targetPath
ssh root@$ip "rm -rf $remoteTargetPath && mkdir -p $remoteTargetPath"
#sync tar.gz to remote linux
scp $sourcePath root@$ip:$remoteTargetPath
ssh root@$ip "cd $remoteTargetPath && tar -zxvf *.tar.gz && rm -rf *.tar.gz && mv * redis"
#sync shell to remote linux for ex