安装说明:自动解压缩安装包,按照指定路径编译安装,复制配置文件模板到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

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

# 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  ###############################

lua-time-limit 5000

################################ REDIS CLUSTER  ###############################

cluster-enabled yes

# cluster-replica-validity-factor 10

# cluster-require-full-coverage yes

# cluster-replica-no-failover no

########################## CLUSTER DOCKER/NAT support  ########################

################################## SLOW LOG ###################################

slowlog-log-slower-than 10000

slowlog-max-len 128

################################ LATENCY MONITOR ##############################

latency-monitor-threshold 0

############################# EVENT NOTIFICATION ##############################

notify-keyspace-events ""

############################### ADVANCED CONFIG ###############################

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-size -2

list-compress-depth 0

set-max-intset-entries 512

zset-max-ziplist-entries 128

zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

stream-node-max-bytes 4096

stream-node-max-entries 100

activerehashing yes

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit replica 256mb 64mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

# client-query-buffer-limit 1gb

# proto-max-bulk-len 512mb

hz 10

dynamic-hz yes

aof-rewrite-incremental-fsync yes

rdb-save-incremental-fsync yes

########################### ACTIVE DEFRAGMENTATION #######################

# Enabled active defragmentation

# activedefrag yes

# Minimum amount of fragmentation waste to start active defrag

# active-defrag-ignore-bytes 100mb

# Minimum percentage of fragmentation to start active defrag

# active-defrag-threshold-lower 10

# Maximum percentage of fragmentation at which we use maximum effort

# active-defrag-threshold-upper 100

# Minimal effort for defrag in CPU percentage

# active-defrag-cycle-min 5

# Maximal effort for defrag in CPU percentage

# active-defrag-cycle-max 75

# Maximum number of set/hash/zset/list fields that will be processed from

# the main dictionary scan

# active-defrag-max-scan-fields 1000

安装示例

sh redis_install.sh /usr/local/redis/   /usr/local/redis5/redis9008/  redis-5.0.4  9008

Redi实例的目录结构

基于Python的Redis自动化集群实现

基于Python的自动化集群实现,初始化节点为node_1~node_6,节点实例需要为集群模式,三主三从,自动化集群,分配slots,加入从节点,3秒钟左右完成

import redis

#master

node_1 = {'host': '127.0.0.1', 'port': 9001, 'password': '***'}

node_2 = {'host': '127.0.0.1', 'port': 9002, 'password': '***'}

node_3 = {'host': '127.0.0.1', 'port': 9003, 'password': '***'}

#slave

node_4 = {'host': '127.0.0.1', 'port': 9004, 'password': '***'}

node_5 = {'host': '127.0.0.1', 'port': 9005, 'password': '***'}

node_6 = {'host': '127.0.0.1', 'port': 9006, 'password': '***'}

redis_conn_1 = redis.StrictRedis(host=node_1["host"], port=node_1["port"], password=node_1["password"])

redis_conn_2 = redis.StrictRedis(host=node_2["host"], port=node_2["port"], password=node_2["password"])

redis_conn_3 = redis.StrictRedis(host=node_3["host"], port=node_3["port"], password=node_3["password"])

# cluster meet

redis_conn_1.execute_command("cluster meet {0} {1}".format(node_2["host"],node_2["port"]))

redis_conn_1.execute_command("cluster meet {0} {1}".format(node_3["host"],node_3["port"]))

print('#################flush slots #################')

redis_conn_1.execute_command('cluster flushslots')

redis_conn_2.execute_command('cluster flushslots')

redis_conn_3.execute_command('cluster flushslots')

print('#################add slots#################')

for i in range(0,16383+1):

if i <= 5461:

try:

redis_conn_1.execute_command('cluster addslots {0}'.format(i))

except:

print('cluster addslots {0}'.format(i) +' error')

elif 5461 < i and i <= 10922:

try:

redis_conn_2.execute_command('cluster addslots {0}'.format(i))

except:

print('cluster addslots {0}'.format(i) + ' error')

elif 10922 < i:

try:

redis_conn_3.execute_command('cluster addslots {0}'.format(i))

except:

print('cluster addslots {0}'.format(i) + ' error')

print()

print('#################cluster status#################')

print()

print('##################'+str(node_1["host"])+':'+str(node_1["port"])+'##################')

print(str(redis_conn_1.execute_command('cluster info'), encoding = "utf-8").split("\n")[0])

print('##################'+str(node_2["host"])+':'+str(node_2["port"])+'##################')

print(str(redis_conn_1.execute_command('cluster info'), encoding = "utf-8").split("\n")[0])

print('##################'+str(node_3["host"])+':'+str(node_3["port"])+'##################')

print(str(redis_conn_1.execute_command('cluster info'), encoding = "utf-8").split("\n")[0])

#slave cluster meet

redis_conn_1.execute_command("cluster meet {0} {1}".format(node_4["host"],node_4["port"]))

redis_conn_2.execute_command("cluster meet {0} {1}".format(node_5["host"],node_5["port"]))

redis_conn_3.execute_command("cluster meet {0} {1}".format(node_6["host"],node_6["port"]))

#cluster nodes

print(str(redis_conn_1.execute_command('cluster nodes'), encoding = "utf-8"))

示例

这样一个Redis的集群,从实例的安装到集群的安装,环境依赖本身没有问题的话,基本上1分钟之内可以完成这个搭建过程。

linux自动化安装集群,Redis自动化安装以及集群实现相关推荐

  1. Linux系统:Centos7搭建Redis单台和集群环境

    一.环境和版本 Linux:centos7 三台 三台Linux服务 192.168.72.129 192.168.72.130 192.168.72.131 Redis:redis-4.0.14 二 ...

  2. linux redis-trib.rb,linux 关于redis-trib.rb构建redis集群

    之前搭建集群漏下的坑, 今次再搭一次. 环境 ruby环境 yum install ruby rubygems -y redis的gem环境 gem install redis-3.2.2.gem 部 ...

  3. Redis的安装以及基本操作简介

    所有与大数据相关的服务都必须在linux上运行,redis提供了linux和windows的版本,但是为了系统更加稳定,推荐使用linux作为服务器. Linux版redis的安装,这里选择cento ...

  4. Redis主从配置和集群配置

    Redis主从配置和集群配置 文章目录 Redis主从配置和集群配置 一.Redis主从配置 1.主从概念 2.主从配置 3.数据操作 二.Redis集群配置 1.简介 2.Redis 集群好处 3. ...

  5. redis系列五redis-cluste集群的搭建

    一 环境准备 三台虚拟机 centos7  安装6个redis的实例三个master 3个slave 192.168.0.30  安装7001 7002 端口 192.168.0.31  安装7003 ...

  6. redis集群linux安装教程,linux下redis集群的原生安装方式部署

    一.部署架构如下 每台服务器准备2个节点,一主一从,主节点为另外两台其中一台的主,从节点为另外两台其中一台的从. 二.准备6个节点配置文件 在172.28.18.75上操作 cd /etc/redis ...

  7. Linux集群和自动化运维

    Linux/Unix技术丛书 Linux集群和自动化运维 余洪春 著 图书在版编目(CIP)数据 Linux集群和自动化运维/余洪春著. -北京:机械工业出版社,2016.8 (Linux/Unix技 ...

  8. Redis的安装配置及简单集群部署

    最近针对中铁一局项目,跟事业部讨论之后需要我们的KF平台能够接入一些开源的数据库,于是这两天研究了一下Redis的原理. 1. Redis的数据存储原理及简述 1.1Redis简述 Redis是一个基 ...

  9. Redis分片主从哨兵集群,原理详解,集群的配置安装,8大数据类型,springboot整合使用

    文章目录 Redis介绍 Redis分片 Redis主从 Redis哨兵 Redis集群 Redis持久化策略 RDB AOF 持久化方案选择 Redis内存策略 LRU算法 LFU算法 Random ...

  10. windows pxe 安装linux,菜鸟学Linux 第103篇笔记 pxe自动化安装linux

    菜鸟学Linux 第103篇笔记 pxe自动化安装linux 内容总览 linux的系统安装 kickstart文件的组成部分 DHCP (Dynamic Host Configuration Pro ...

最新文章

  1. 一文读懂深度学习框架下的目标检测(附数据集)
  2. ZooKeeper典型应用场景一览
  3. 第三周项目三-输出星号图(1)
  4. 最新|TensorFlow开源的序列到序列框架
  5. STP文件服务器,综合监控stp服务器
  6. CodeForces - 1562D2 Two Hundred Twenty One (hard version)(二分)
  7. java 标准输入流 关闭 打开_java--标准输入输出流
  8. java与python反转Ture与False的方法
  9. Atitit 微服务之道 attilax著 1. 什么是微服务架构? 1 1.1. 、微服务与SOA的关系 :微服务架架构师面向服务架构(SOA)的一种特定实现 2 1.2. 微服务与康威定律 2 1
  10. Java编一个收银小票_Java编程打印购物小票实现代码
  11. 保研面试-中英文问题及回答总结
  12. 服务器跟普通电脑的区别?
  13. oracle 郑阿奇 pdf,Delphi编程教程 (郑阿奇) PDF扫描版
  14. Knowledge Graph表示学习--TransE系列
  15. 架构师的软实力之架构透视
  16. 安卓虚拟机上用charles+drony抓包app的websocket
  17. 东南大学网安学院研究生毕业,就业如何?
  18. javac 和java 的命令
  19. 怎么将计算机的数据都备份到网络设置,如何备份电脑所有数据?三大方法教你搞定电脑数据备份...
  20. oracle replace 单引号替换

热门文章

  1. MySQL - 字段名的修饰
  2. C# System.Drawing.SystemColors 系统颜色
  3. SpringBoot工程中,如果不继承spring-boot-starter-parent ,还可以怎么做到的版本管理?
  4. RabbitMQ死信队列应用场景之模拟未支付订单自动取消
  5. Java根类--Object类
  6. 网络安全与管理精讲视频笔记4-数字信封、数字签名、完整性验证、数据加解密及身份认证流程...
  7. 像打字一样插入图标-iconfont
  8. PanguVR获得400万种子轮融资,提供高效的VR家装解决方案
  9. puppet的配置清单书写
  10. [LeetCode] Decode Ways [33]