本文共 4197 字,大约阅读时间需要 13 分钟。
Download_redis=
dir1=/optredis=redis-3.2.1redis_conf1=/usr/local/redis-6379/redis.confredis_conf2=/usr/local/redis-6380/redis.confFILE1=$HOME/6379.confFILE2=$HOME/6380.confdir2=/server/scripts/rediscount=ps -ef|grep redis|grep -v grep| wc -l
install_yum () {
echo -e "\033[41;37m <===开始安装redis依赖 软件,请稍等...===> \033[0m"sleep 2yum install -y gcc wget}install_dir () {
cd $dir1wget -q $Download_redisecho -e "\033[41;37m <===redis下载中,请稍后...===> \033[0m"tar xf redis-3.2.1.tar.gz -C /usr/localcd /usr/local/$redismakemake PREFIX=${redis_setup_dir} installif [echo $?
-eq 0 ];thenecho -e "\e[1;32m redis安装成功. \e[0m"elif [ echo $?
-ne 0 ];thenecho -e "\e[1;31m redis安装失败,请检查环境. \e[0m"exitfisleep 1} select_or () {
echo "---------------------------------------------------------------select Master Slave1 Master2 Slave----------------------------------------------------------------"read inputcase "$input" in 1) mv /usr/local/$redis /usr/local/redis-6379 sleep 1 cd /usr/local/redis-6379 cp -f redis.conf redis.conf.bak cat "$HOME/6379.conf" >$redis_conf1 /usr/local/redis-6379/src/redis-server /usr/local/redis-6379/redis.conf & sleep 3 ;; 2) mv /usr/local/$redis /usr/local/redis-6380 sleep 1 cd /usr/local/redis-6380 cp -f redis.conf redis.conf.bak cat "$HOME/6380.conf" >$redis_conf2 /usr/local/redis-6380/src/redis-server /usr/local/redi
s-6380/redis.conf &
sleep 3;;*)echo "---------------------------------------------------------------select Master Slave1 Master2 Slave----------------------------------------------------------------"esac}count_conf () {
if [ $count -gt 1 ];thenecho -e "\e[1;32m redis is running \e[0m"elif [ $count -le 1 ];thenecho -e "\e[1;31m redis is not running \e[0m"fi}install_yum
install_dirselect_orcount_conf2.主配置文件
daemonize yes pidfile /usr/local/redis-6379/run/redis.pid bind 0.0.0.0port 6379 timeout 300 tcp-keepalive 0 loglevel notice #logfile stdout databases 16 unixsocketperm 0 maxmemory 2000000000 maxmemory-policy volatile-lru maxmemory-samples 3 maxclients 10000 #save 900 1 #save 300 10 #save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb slave-serve-stale-data yes slave-read-only yes repl-ping-slave-period 10 repl-timeout 60 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 1024 hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 103.从配置文件
daemonize yes pidfile /usr/local/redis-6380/run/redis.pid port 6380 timeout 300 tcp-keepalive 0 loglevel notice #logfile stdout databases 16 unixsocketperm 0 maxmemory 2000000000 maxmemory-policy volatile-lru maxmemory-samples 3 maxclients 10000 #save 900 1 #save 300 10 #save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb slaveof 192.168.1.42 6379 (根据你实际的本地环境配置为主的ip 及端口)slave-serve-stale-data yes slave-read-only yes repl-ping-slave-period 10 repl-timeout 60 repl-disable-tcp-nodelay no slave-priority 100 appendonly yes appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 1024 hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10转载于:https://blog.51cto.com/11571922/2103928