redis实例安装与自动化集群实现
安装说明:自动解压安装包,并在指定路径编译安装。将配置文件模板复制到Redis实例的目录下,并根据端口号修改配置文件。
所需文件:配置文件、当前shell脚本、安装包。
参数说明:
参数1(basedir):Redis安装包路径参数2(installdir):安装实例路径参数3(installfilename):安装包名称参数4(port):安装实例的端口号
#!/bin/bashset -eif [ $# -lt 4 ]; then echo "$(basename $0): Missing script argument" echo "$(basename $0) [installfilename] [port]" exit 9fiPortInUse=`netstat -anp | awk '{print $4}' | grep $4 | wc -l`if [ $PortInUse -gt 0 ]; then echo "ERROR" $4 "Port is used by another process!" exit 9fibasedir=$1installdir=$2installfilename=$3port=$4cd $basedirtar -zxvf $installfilename.tar.gz &>/dev/null 2>&1 &cd $installfilenamemkdir -p $installdirmake PREFIX=$installdir installsleep 1scp $basedir/redis.conf $installdirsed -i "s/instance_port/$port/g" $installdir/redis.confsleep 1cd $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 ipport instance_porttcp-backlog 511timeout 0tcp-keepalive 300
################################# GENERAL #####################################daemonize yessupervised nopidfile ./redis_instance_port.pidloglevel noticelogfile ./redis_log.logdatabases 16always-show-logo yes
################################ SNAPSHOTTING ################################save 900 1save 300 10save 60 10000
stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir ./
################################# REPLICATION ##################################masterauth replica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noreplica-priority 100
################################## SECURITY ###################################requirepass your_password
################################### CLIENTS #####################################maxclients 10000
############################## MEMORY MANAGEMENT #################################maxmemory
maxmemory-policy noeviction
maxmemory-samples 5
replica-ignore-maxmemory yes
############################# LAZY FREEING ####################################lazyfree-lazy-eviction nolazyfree-lazy-expire nolazyfree-lazy-server-del noreplica-lazy-flush no
############################## APPEND ONLY MODE ###############################appendonly no
appendfilename "appendonly.aof"
appendfsync always
appendfsync everysec
appendfsync no
no-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-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 10000slowlog-max-len 128
################################ LATENCY MONITOR ##############################latency-monitor-threshold 0
############################# EVENT NOTIFICATION ##############################notify-keyspace-events ""
############################### ADVANCED CONFIG ###############################hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit replica 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60
client-query-buffer-limit 1gb
proto-max-bulk-len 512mb
hz 10dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-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
安装示例:
MATLAB与VB混合编程技术研究 WORD版
本文档主要讲述的是MATLAB与VB混合编程技术研究;着重探讨了在VB应用程序中集成MATLAB实现程序优化的四种方法,即利用Matrix VB、调用DLL动态链接库、应用Active自动化技术和动态数据交换技术,并分析了集成过程中的关键问题及其基本步骤。这种混合编程实现了VB的可视化界面与MATLAB强大的数值分析能力的结合。希望本文档会给有需要的朋友带来帮助;感兴趣的朋友可以过来看看
0 查看详情
sh redis_install.sh /usr/local/redis/ /usr/local/redis5/redis9008/ redis-5.0.4 9008

Redis实例的目录结构:

基于Python的Redis自动化集群实现:
基于Python的自动化集群实现,初始化节点为node_1~node_6,节点实例需要为集群模式,三主三从,自动化集群,分配slots,加入从节点,约3秒钟完成。
import redismaster
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:redis_conn_1.execute_command('cluster addslots {0}'.format(i))elif i < 10922:redis_conn_2.execute_command('cluster addslots {0}'.format(i))else:redis_conn_3.execute_command('cluster addslots {0}'.format(i))
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的集群,从实例的安装到集群的安装,如果环境依赖没有问题的话,基本上在一分钟内可以完成整个搭建过程。
以上就是Redis自动化安装以及集群实现的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/816511.html
微信扫一扫
支付宝扫一扫