2019-07-05 redisツール拡張、収縮ノード

3149 ワード

redisツール拡張ノード


1.db 01に新しいノードを作成する

mkdir -p /opt/redis_cluster/redis_{6390,6391}/{conf,logs,pid}

mkdir -p /data/redis_cluster/redis_{6390,6391}

cd /opt/redis_cluster/

cp redis_6380/conf/redis_6380.conf redis_6390/conf/redis_6390.conf

cp redis_6380/conf/redis_6380.conf redis_6391/conf/redis_6391.conf

sed -i 's#6380#6390#g' redis_6390/conf/redis_6390.conf

sed -i 's#6380#6391#g' redis_6391/conf/redis_6391.conf


2.db 01で新しいノードを起動する

sh /server/scripts/redis_shell.sh start 6390

sh /server/scripts/redis_shell.sh start 6391

3.ツールを使用してノードを検出し、スロットを再割り当て

cd /opt/redis_cluster/redis/src/

./redis-trib.rb add-node 10.0.0.51:6390 10.0.0.51:6380

./redis-trib.rb add-node 10.0.0.51:6391 10.0.0.51:6380

./redis-trib.rb reshard 10.0.0.51:6380

4.拡張プロセス

#           
How many slots do you want to move (from 1 to 16384)? XXXX

#         ID
What is the receiving node ID? XXXX

#       ID(all  )
Source node #1:all

#    
Do you want to proceed with the proposed reshard plan (yes/no)? yes

#    
[root@db01 ]# sh /server/scripts/redis_shell.sh login 6390
10.0.0.51:6390> CLUSTER NODES

10.0.0.51:6390> CLUSTER INFO

#       (    )
  db03 6381  db01 6390
  db01 6391  db01 6380

#     


redisツール収縮ノード


1.スクリプトディレクトリへ

cd /opt/redis_cluster/redis/src/

./redis-trib.rb reshard 10.0.0.51:6391

2.収縮過程

#        
How many slots do you want to move (from 1 to 16384)? XXXX

#         ID
What is the receiving node ID? XXXX

#       ID
Source node #1:XXXX
Source node #2:done

#    
Do you want to proceed with the proposed reshard plan (yes/no)? yes

#    
[root@db01 ]# sh /server/scripts/redis_shell.sh login 6380
10.0.0.51:6380> CLUSTER NODES

10.0.0.51:6380> CLUSTER INFO

#      ID
1.xxxxx 
2.done

#    
yes

#      
cd /opt/redis_cluster/redis/src/
./redis-trib.rb del-node 10.0.0.51:6390 ca07d35324306f7f035d598e76427a04523f08ec
./redis-trib.rb del-node 10.0.0.51:6391 cad275c00c314aad7e71e4ccd90b550a8ae1b515


3.データインポートエクスポートツール

1.    
cd /opt/redis_cluster/
git clone https://github.com/vipshop/redis-migrate-tool.git
cd redis-migrate-tool/
autoreconf -fvi
./configure
make && make install 


2.      
cat > redis_6379_to_6380.conf  <

4.占有スペースの比較的大きいキーを分析する

    
redis           ,               ,           .

    
yum install python-pip gcc
pip install --upgrade pip
pip install rdbtools

    
cd /data/redis_cluster/redis_6379/
rdb -c memory redis_6379.rdb -f 6379_memory.csv

  rdb
awk -F ',' '{print $4,$2,$3,$1}' 6379_memory.csv |sort  > 6379.sort