In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
#
# redis official website: https://redis.io
# redis document: https://redis.io/documentation
# redis Cluster: https://redis.io/topics/cluster-tutorial
# redis common configuration explanation: https://yq.aliyun.com/articles/38806; https://github.com/linli8/cnblogs/blob/master/redis%E5%89%AF%E6%9C%AC.conf
# Software download
[root@node3 ~] # wget http://download.redis.io/releases/redis-3.2.9.tar.gz
# compiling
[root@node3 ~] # mkdir / usr/local/redis [root@node3 ~] # mkdir / usr/local/redis/ {data,conf,bin} [root@node3 ~] # tar-xf redis-3.2.9.tar.gz [root@node3 ~] # cd redis-3.2.9/ [root@node3 redis-3.2.9] # make
# copy the compiled file
[root@node3 redis-3.2.9] # cd src/ [root@node3 src] #\ cp-p mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb / usr/local/redis/bin/ [root@node3 src] # cd. [root@node3 redis-3.2.9] # cp-p redis.conf / usr/local/redis/conf/
# create a data directory
[root@node3 redis-3.2.9] # cd / usr/local/redis/data/ [root@node3 data] # mkdir {7000..7005} [root@node3 data] # ls7000 7001 7002 7003 7004 7005 [root@node3 data] #
# modify the corresponding port (roughly as follows)
[root@node3 conf] # grep'^ [Amurz] 'redis.conf bind 0.0.0.0dir / usr/local/redis/data/7000pidfile / var/run/redis_7000.pidappendfilename "appendonly-7000.aof" port 7000cluster-config-file nodes-7000.conf cluster-enabled yescluster-node-timeout 15000protected-mode notcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nologlevel warninglogfile "databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum nodbfilename dump.rdbslave-serve-stale-data yesslave-read -only yesrepl-diskless-sync yesrepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly yesappendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 100000slowlog-max-len 128hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0latency-monitor-threshold 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max -ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 64mb 16mb 60hz 10aof-rewrite-incremental-fsync yesmaxmemory-policy allkeys-lrumaxmemory-samples 5maxclients 10000
# copy configuration file
[root@node3 conf] # for i in {7000.7005}; do cp redis.conf $i.confiting done [root@node3 conf] # ls7000.conf 7001.conf 7002.conf 7003.conf 7004.conf 7005.conf redis.conf [root@node3 conf] # rm-f redis.conf# batch modification [root@node3 conf] # for i in {7000.7005}; do sed-I "s/7000/$i/g"$I" .conf; done
# modify script (very rough script, not recommended, please write by yourself)
[root@node3 ~] # cp-p redis-3.2.9/utils/redis_init_script / etc/init.d/redis [root@node3 ~] # vim / etc/init.d/redis [root@node3 ~] # cat / etc/init.d/redis #! / bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the / proc filesystem.#REDISPORT=$2EXEC=/usr/local/redis/bin/redis-serverCLIEXEC=/usr/local/redis/bin/redis -cliCONFDIR= "/ usr/local/redis/conf/" # PIDFILE=/var/run/redis_$ {REDISPORT} .pid # CONF= "$CONFDIR$ {REDISPORT} .conf" function main () {REDISPORT=$2PIDFILE=/var/run/redis_$ {REDISPORT} .pidCONF = "$CONFDIR$ {REDISPORT} .conf" case "$1" in start) if [- f $PIDFILE] then echo "$PIDFILE exists Process is already running or crashed "else echo" Starting Redis server... "$EXEC $CONF fi Stop) if [!-f $PIDFILE] then echo "$PIDFILE does not exist Process is not running "else PID=$ (cat $PIDFILE) echo" Stopping... "$CLIEXEC-p $REDISPORT shutdown while [- x / proc/$ {PID}] do echo" Waiting for Redis to shutdown... " Sleep 1 done echo "Redis stopped" fi;; *) echo "Please use start or stop as first parameter,port or all as second parameter."; esac} if ["$2" = = "all"] then for i in `ls $CONFDIR | grep [0-9] | cut-c 1-4`; domain $1$ i doneelse main $1 $2fi
# start the service
[root@node3 ~] # service redis start all [root@node3 ~] # netstat-lntup | grep redistcp 00 0.0.0.0root@node3 17000 0.0.0.0lntup * LISTEN 6735/redis-server 0 tcp 00 0.0.0.0root@node3 17001 0.0.0.0root@node3 * LISTEN 6737/redis-server 0 tcp 00 0.0.0.0 LISTEN 6747/redis-server 17002 0.0.0.0 LISTEN 6743/redis-server 0 tcp 00 0.0.0.0 LISTEN 6747/redis-server 0 tcp 00 0.0.0.0 LISTEN 6747/redis-server 17004 0.0.0.0 : * LISTEN 6749/redis-server 0 tcp 00 0.0.0.0LISTEN 6755/redis-server 17005 0.0.0.0LISTEN 6755/redis-server 0 tcp 00 0.0.0.070000.0.0.0LISTEN 6755/redis-server 0 tcp 00 0.0.0.0LISTEN 6743/redis-server 7001 0.0.0.0tcp * LISTEN 6737/redis-server 0 tcp 00 0.0.0.0VR 7002 0.0.0.0tcp 00 0.0.0.0LISTEN 6743/redis-server 7003 0.0.0.0LISTEN 6743/redis-server * LISTEN 6747/redis-server 0 tcp 00 0.0.0.0 LISTEN 6749/redis-server 7004 0.0.0.0 LISTEN 6749/redis-server 0 tcp 00 0.0.0.0 LISTEN 6749/redis-server 7005 0.0.0.0 LISTEN 6755/redis-server 0 [root@node3 ~] #
# create a cluster
[root@node3 conf] # yum install ruby ruby-devel rubygems rpm-build [root@node3 conf] # gem install redis # if there is no response You can change the source # change the source reference: http://gems.ruby-china.org/# gem update-- system # here please × × × now # gem sources-- add https://gems.ruby-china.org/-- remove https://rubygems.org/#[root@node3 conf] # cd / usr/local/redis/bin/ [root@node3 bin] # lsmkreleasehdr.sh redis-check-aof redis-cli redis-serverredis-benchmark redis-check-rdb redis- Sentinel redis-trib.rb [root@node3 bin] #. / redis-trib.rb create-- replicas 1127.0.0.1: 7000127.0.1redis-trib.rb create 7001127.0.0.1: 7002 127.0.0.1redis-trib.rb create 7003 127.0.0.1Vera 7004 127.0.0.1rig 7005 > > Creating cluster > Performing hash slots allocation on 6 nodes...Using 3 masters:127.0.0.1:7000127.0.0.1:7001127.0.0.1: 7002Adding replica 127.0.0.1 to 127.0.0.1:7001Adding replica 7004 to 127.0.0.1:7001Adding replica 127.0.0.1 to 127.0.1 7002M: de6c4b00953b0e354ea375106f29bd627ed3ab2e 127.0.0.1 de6c4b00953b0e354ea375106f29bd627ed3ab2e 7000000 slots:0-5460 (5461 slots) masterM: fce2cebafefeb540592c624c68b741d465ce095b 127.0.0.1 slots 7001 slots:5461-10922 (5462 slots) masterM: 83474177e39b72145adaad60cad1fe4523a0ee79 127.0.0.1 slots 7002 slots:10923 -16383 (5461 slots) masterS: af00ce59424417ab1cfba4edc145223d4b3ac999 127.0.0.1 af00ce59424417ab1cfba4edc145223d4b3ac999 7003 replicates de6c4b00953b0e354ea375106f29bd627ed3ab2eS: 64391b1f359b6bfdfdd5373c71388fb119dc2bb3 127.0.0.1 af00ce59424417ab1cfba4edc145223d4b3ac999 7004 replicates fce2cebafefeb540592c624c68b741d465ce095bS: 3509837665c9cfe7a798513b87c84c9b2d3c9f1d 127.0.0.1 af00ce59424417ab1cfba4edc145223d4b3ac999 7005 replicates 83474177e39b72145adaad60cad1fe4523a0ee79Can I set the above configuration? (type 'yes' to accept): yes > Nodes configuration updated > > Assign a different config epoch to each node > > Sending CLUSTER MEET messages to join the clusterWaiting for the cluster to join.... > > Performing Cluster Check (using node 127.0.0.1 master 7000) M: de6c4b00953b0e354ea375106f29bd627ed3ab2e 127.0.0.1 master 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) S: af00ce59424417ab1cfba4edc145223d4b3ac999 127. 0.0.1 slots 7003 slots: (0 slots) slave replicates de6c4b00953b0e354ea375106f29bd627ed3ab2eM: 83474177e39b72145adaad60cad1fe4523a0ee79 127.0.0.1 83474177e39b72145adaad60cad1fe4523a0ee79 7002 slots:10923-16383 (5461 slots) master 1 additional replica (s) S: 64391b1f359b6bfdfdd5373c71388fb119dc2bb3 127.0.0.1 83474177e39b72145adaad60cad1fe4523a0ee79 7004 slots: (0 slots) slave replicates fce2cebafefeb540592c624c68b741d465ce095bS: 3509837665c9cfe7a798513b87c84c9b2d3c9f1d 127.0.0.1slave replicates de6c4b00953b0e354ea375106f29bd627ed3ab2eM 7005 slots: (0 slots) slave replicates 83474177e39b72145adaad60cad1fe4523a0ee79 [OK] All nodes agree about slots configuration. > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered.
# log in to the cluster
[root@node3] # / usr/local/redis/bin/redis-cli-c-h 127.0.0.1-p 7000127.0.1cluster nodesfce2cebafefeb540592c624c68b741d465ce095b 7001 master-01495358027725 2 connected 5461-10922de6c4b00953b0e354ea375106f29bd627ed3ab2e 127.0.0.1VV 7000 myself Master-00 1 connected 0-5460af00ce59424417ab1cfba4edc145223d4b3ac999 127.0.0.1 5460af00ce59424417ab1cfba4edc145223d4b3ac999 7003 slave de6c4b00953b0e354ea375106f29bd627ed3ab2e 0 1495358029772 4 connected83474177e39b72145adaad60cad1fe4523a0ee79 127.0.0.1 master-01495358025682 3 connected 10923-1638364391b1f359b6bfdfdd5373c71388fb119dc2bb3 127.0.0.1Rover 7004 slave fce2cebafefeb540592c624c68b741d465ce095b 0 1495358028748 5 connected3509837665c9cfe7a798513b87c84c9b2d3c9f1d 127.0.1005 slave 83474177e39b72145adaad60cad1fe4523a0ee79 01495358026706 connected127.0.0.1:7000 > cluster infocluster_state:okcluster_slots_assigned:16384cluster_slots_ok:16384cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:6cluster_size:3cluster _ current_epoch:6cluster_my_epoch:1cluster_stats_messages_sent:77cluster_stats_messages_received:77127.0.0.1:7000 > cluster nodesfce2cebafefeb540592c624c68b741d465ce095b 127.0.0.1 master 7001 master-0 1495358038300 2 connected 5461-10922de6c4b00953b0e354ea375106f29bd627ed3ab2e 127.0.0.1 Vol 7000 myself Master-00 1 connected 0-5460af00ce59424417ab1cfba4edc145223d4b3ac999 127.0.0.1 5460af00ce59424417ab1cfba4edc145223d4b3ac999 7003 slave de6c4b00953b0e354ea375106f29bd627ed3ab2e 0 1495358039395 4 connected83474177e39b72145adaad60cad1fe4523a0ee79 127.0.0.1 master-01495358036106 3 connected 10923-1638364391b1f359b6bfdfdd5373c71388fb119dc2bb3 127.0.0.1From 7004 slave fce2cebafefeb540592c624c68b741d465ce095b 01495358033918 5 connected3509837665c9cfe7a798513b87c84c9b2d3c9f1d 127.0.0.1005 slave 83474177e39b72145adaad60cad1fe4523a0ee79 01495358040489 6 connected127.0.0.1:7000 >
# redis cluster built successfully
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.