#!/usr/bin/env python #coding:utf-8 #author:yang #data:2014-11-24 import os port_list = ['6379','6380','6381','6382'] reids_conf_path = "/etc/redis/" redis_log = "/opt/logs/" redis_data = "/opt/redis/" texts=""" daemonize yes pidfile /var/run/redis/redis_63xx.pid port 63xx tcp-backlog 511 timeout 300 tcp-keepalive 0 loglevel notice logfile /opt/logs/redis_63xx.log databases 16 save "" stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump_63xx.rdb dir /opt/redis/ slave-serve-stale-data yes slave-read-only yes repl-disable-tcp-nodelay no slave-priority 100 maxmemory 7gb appendonly no appendfilename "appendonly.aof" 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 128 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64s set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 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 aof-rewrite-incremental-fsync yes """ if not os.path.isdir(reids_conf_path): os.mkdir(reids_conf_path) if not os.path.isdir(redis_log): os.mkdir(redis_log) def WriteToFile(file,i): fd = open(file, 'a+') fd.write(i) print file + " is ok" fd.close() for i in port_list: file_name = "redis_"+ i +".conf" port_file = "port_" + i port_file = texts.replace("63xx",i) redis_data_path = redis_data + "redis_" + i if not os.path.isdir(redis_data_path): os.makedirs(redis_data_path) if not os.path.isfile(reids_conf_path+file_name): WriteToFile(reids_conf_path+file_name,port_file)