-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_redis_confs.sh
executable file
·73 lines (68 loc) · 2.48 KB
/
gen_redis_confs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#environment variables
REDIS_CONFS_DIR=/home/jye20/redis_test/redis_confs
REDIS_CONFS_LISTS=/home/jye20/redis_test/redis_confs_lists
# redis config variables
RDB_COMPRESSION_OPS=("yes" "no")
IO_THREADS_VALS=(1 4)
HZ_VALS=(10 50)
RDB_SAVE_INCREMENTAL_FSYNC_OPS=("yes" "no")
SAVE_PARAS_LISTS=("15 1,5 10,1 10000" "900 1,300 10,60 10000")
#create and clean redis confs dir
if [ ! -d ${REDIS_CONFS_DIR} ]; then
mkdir -p ${REDIS_CONFS_DIR}
fi
#clean DEPLOYMENT_CONF_DIR
rm -f ${REDIS_CONFS_DIR}/*
rm -f ${REDIS_CONFS_LISTS}
write_basic_redis_conf_items(){
redis_conf_file=$1
echo "port 6379" >> ${redis_conf_file}
echo "protected-mode no" >> ${redis_conf_file}
echo "daemonize yes" >> ${redis_conf_file}
echo "loglevel notice" >> ${redis_conf_file}
echo "logfile redis.log" >> ${redis_conf_file}
echo "cluster-enabled yes" >> ${redis_conf_file}
echo "cluster-config-file nodes.conf" >> ${redis_conf_file}
echo "cluster-node-timeout 15000" >> ${redis_conf_file}
}
echo "Begin to generate redis config files...."
# iterate different configuration Items and generate redis configuration files
seq=0
for hz in "${HZ_VALS[@]}"
do
for rdb_save_incremental in "${RDB_SAVE_INCREMENTAL_FSYNC_OPS[@]}"
do
for rdbcompression in "${RDB_COMPRESSION_OPS[@]}"
do
for io_threads in "${IO_THREADS_VALS[@]}"
do
for save_paras in "${SAVE_PARAS_LISTS[@]}"
do
seq=$((seq + 1))
redis_conf_file=${REDIS_CONFS_DIR}/redis_${seq}.conf
if [ -f ${redis_conf_file} ]; then
echo "" > ${redis_conf_file}
fi
#write the basic config items to redis conf file
write_basic_redis_conf_items ${redis_conf_file}
#write other config items
echo "rdbcompression ${rdbcompression}" >> ${redis_conf_file}
echo "rdb-save-incremental-fsync ${rdb_save_incremental}" >> ${redis_conf_file}
echo "io-threads ${io_threads}" >> ${redis_conf_file}
echo "io-threads-do-reads yes" >> ${redis_conf_file}
echo "hz ${hz}" >> ${redis_conf_file}
save_lists=(`echo ${save_paras} |tr ' ' '&'| tr ',' ' '`)
for save in "${save_lists[@]}"
do
save=`echo ${save} |tr '&' ' '`
echo "save ${save}" >> ${redis_conf_file}
done
# append the config path to redis_conf_lists file
echo ${redis_conf_file} >> ${REDIS_CONFS_LISTS}
done
done
done
done
done
echo "End to generate redis conf files....."