Init
This commit is contained in:
7
readme.txt
Normal file
7
readme.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
1.进入redis-4.0.6源码目录make clean;make -j;make install;
|
||||
2.创建/home/mesasoft/redis/reids-node目录;
|
||||
3.将安装目录下的redis-node中文件拷贝到/home/mesasoft/redis/reids-node;
|
||||
4.创建节点执行./run_redis.sh 16 //默认16个节点,可依据需要更改
|
||||
5.添加守护执行./redis_protect 16 //默认16个节点,可依据需要更改
|
||||
6.创建集群执行./build_cluster.sh 16 //默认16个节点,可依据需要更改创建集群
|
||||
7.验证是否创建成功,执行: redis-cli -h 127.0.0.1 -p 9001 cluster info //输出cluster_state:ok 表示创建成功
|
||||
BIN
redis-4.0.6.tar.gz
Normal file
BIN
redis-4.0.6.tar.gz
Normal file
Binary file not shown.
29
redis-node/build_cluster.sh
Normal file
29
redis-node/build_cluster.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#./redis-trib.rb 10.0.6.240:9012 10.0.6.240:9013 10.0.6.240:9014 10.0.6.240:9015 10.0.6.240:9016 10.0.6.240:9017 10.0.6.240:9018 10.0.6.240:9019 10.0.6.240:9020 10.0.6.240:9021 10.0.6.240:9022 10.0.6.240:9023 10.0.6.240:9024 10.0.6.240:9025 10.0.6.240:9026 10.0.6.240:9027
|
||||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
if [ $# -lt 1 ];then
|
||||
echo -e "usage:\n\tbuild_cluster.sh redis_instance_num\nexample:\n\tbuild_cluster.sh 16"
|
||||
exit 1
|
||||
fi
|
||||
((n = $1))
|
||||
slot_num=16384
|
||||
s=9001
|
||||
host=127.0.0.1
|
||||
#redis-cli -p $s -c
|
||||
m=`expr $slot_num / $n`
|
||||
echo "m value:"$m
|
||||
for((i=1;i<$n;i++));
|
||||
do
|
||||
((p=$s+$i))
|
||||
#echo "i value:"$i
|
||||
redis-cli -h $host -p $s -c cluster meet 127.0.0.1 $p >>/dev/null
|
||||
done
|
||||
for((i=0;i<$n;i++))
|
||||
do
|
||||
((p=$s+$i))
|
||||
for((j=$i*m;j<($i+1)*m;j++))
|
||||
do
|
||||
#echo "j value":$j
|
||||
redis-cli -h $host -p $p cluster addslots $j >>/dev/null
|
||||
done
|
||||
done
|
||||
5
redis-node/redis.conf
Normal file
5
redis-node/redis.conf
Normal file
@@ -0,0 +1,5 @@
|
||||
include /home/mesasoft/redis/redis-node/redis_comm.conf
|
||||
port 9000
|
||||
pidfile /home/mesasoft/redis/redis-node/9000/redis.pid
|
||||
dir /home/mesasoft/redis/redis-node/9000
|
||||
logfile /home/mesasoft/redis/redis-node/9000/redis.log
|
||||
1053
redis-node/redis_comm.conf
Normal file
1053
redis-node/redis_comm.conf
Normal file
File diff suppressed because it is too large
Load Diff
2
redis-node/redis_protect
Normal file
2
redis-node/redis_protect
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
/home/mesasoft/redis/redis-node/redis_protect.sh $1 &
|
||||
18
redis-node/redis_protect.sh
Normal file
18
redis-node/redis_protect.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
if [ $# -lt 1 ];then
|
||||
echo -e "usage:\n\tprotect.sh redis_instance_num\nexample:\n\tprotect.sh 6"
|
||||
exit 1
|
||||
fi
|
||||
((n = $1+1))
|
||||
while true; do
|
||||
redis_num=`ps -ef|grep redis-server|wc -l`
|
||||
#echo $redis_num
|
||||
if [ $redis_num -lt $n ];then
|
||||
for dir in $(ls /home/mesasoft/redis/redis-node/)
|
||||
do
|
||||
[ -d $dir ] && `redis-server /home/mesasoft/redis/redis-node/$dir/redis.conf`
|
||||
done
|
||||
#echo program crashed, restart at `date +"%w %Y/%m/%d, %H:%M:%S"` >> RESTART.log
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
35
redis-node/run_redis.sh
Normal file
35
redis-node/run_redis.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#/bin/bash
|
||||
if [ $# -lt 1 ];then
|
||||
echo -e "usage:\n\trun_redis.sh redis_instance_num\nexample:\n\trun_redis.sh 6"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
killall redis-server
|
||||
sleep 1
|
||||
n=$1
|
||||
echo $n
|
||||
s=9001
|
||||
dir=/home/mesasoft/redis/redis-node/
|
||||
deldir=$dir"9*"
|
||||
rm -rf $deldir
|
||||
echo 16384 >> /proc/sys/net/core/somaxconn
|
||||
echo 'ulimit -n 16384' >> /etc/profile
|
||||
for((i=0;i<$n;i++));
|
||||
do
|
||||
((p=$s+$i))
|
||||
mkdir $p
|
||||
node_dir=${dir}${p}
|
||||
cd $node_dir
|
||||
echo "include "$dir"redis_comm.conf" >> redis.conf
|
||||
port="port "${p}
|
||||
echo $port >> redis.conf
|
||||
pidfile="pidfile "${node_dir}"/redis.pid"
|
||||
echo $pidfile >> redis.conf
|
||||
work_dir="dir "${node_dir}
|
||||
echo $work_dir >> redis.conf
|
||||
log="logfile "${node_dir}"/redis.log"
|
||||
echo $log >> redis.conf
|
||||
redis-server redis.conf
|
||||
cd ..
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user