设为首页 加入收藏

TOP

Redis自动化安装以及集群实现(一)
2019-09-19 11:12:03 】 浏览:138
Tags:Redis 自动化 安装 以及 集群 实现
Redis实例安装
安装说明:自动解压缩安装包,按照指定路径编译安装,复制配置文件模板到Redis实例路的数据径下,根据端口号修改配置文件模板
配置文件,当前shell脚本,安装包
参数1:basedir,redis安装包路径
参数2:安装实例路径
参数3:安装包名称
参数4:安装实例的端口号
#!/bin/bash
set -e
if [ $# -lt 4 ]; then
        echo "$(basename $0): Missing script argument"
        echo "$(installdir $0) [installfilename] [port] "
        exit 9
fi
PotInUse=`netstat -anp |  awk '{print $4}'  | grep $4 | wc -l`
if [ $PotInUse -gt 0 ];then
  echo "ERROR" $4 "Port is used by another process!"
  exit 9
fi
basedir=$1
installdir=$2
installfilename=$3
port=$4
cd $basedir
tar -zxvf $installfilename.tar.gz  >/dev/null 2>&1 &
cd $installfilename
mkdir -p $installdir
make PREFIX=$installdir install
sleep 1s 
cp $basedir/redis.conf $installdir

sed -i "s/instance_port/$port/g"  $installdir/redis.conf
sleep 1s 
cd $installdir
./bin/redis-server redis.conf >/dev/null 2>&1 &

配置文件模板

################################## INCLUDES ###################################
# include /path/to/local.conf
# include /path/to/other.conf

################################## MODULES #####################################
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

################################## NETWORK #####################################
bind 127.0.0.1 & your ip
port instance_port
tcp-backlog 511
timeout 0
tcp-keepalive 300

################################# GENERAL #####################################
daemonize yes
supervised no
pidfile ./redis_instance_port.pid
loglevel notice
logfile ./redis_log.log
databases 16
always-show-logo yes

################################ SNAPSHOTTING  ################################
save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./

################################# REPLICATION #################################
# masterauth <master-password>
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100

################################## SECURITY ###################################
requirepass your_passwrod

################################### CLIENTS ####################################
# maxclients 10000

############################## MEMORY MANAGEMENT ################################
# maxmemory <bytes>
# maxmemory-policy noeviction
# maxmemory-samples 5
# replica-ignore-maxmemory yes

############################# LAZY FREEING ####################################
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

############################## APPEND ONLY MODE ###############################
appendonly no

appendfilename "appendonly.aof"

# appendfsync always
appendfsync everysec
# appendfsync no

no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes

################################ LUA SCRIPTING  ###########
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇centos7放行1521端口 下一篇Redis事务控制

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目