Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis cluster mode deployment (including networking and offline installation)

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

System environment system version: CentOS 6.8x86x64 (applicable to CentOS 7.*) gcc version 4.4.7 redis version: 4.0.8 installation method: source code installation redis package path: / opt/tools/ installation path: / usr/local/ dependent environment: Ruby environment (cluster construction needs to be created with ruby, ruby environment is above 2.2. Redis.gem, a package management tool for rubygems:ruby: the ruby plug-in required by the redis cluster, installs redis-4.0.1.gem through rubygems. 1 Redis single node deployment 1.1 download and compile [root@redis_1 ~] # cd / opt/tools/ [root @ redis_1 tools] # wget http://download.redis.io/releases/redis-4.0.8.tar.gz[root@redis_1 tools] # tar xf redis-4.0.8.tar.gz-C / usr/local/ [root @ redis_1 tools] # cd / usr/local/redis-4.0.8/ [root@redis_ 1 redis-4.0.8] # make[ root @ redis_1 redis-4.0.8] # make install will generate Redis server program redis-server and client program redis-cli in the src directory after compilation. 1.2 foreground launch service [root@redis_1 redis-4.0.8] # redis-server. The default is to run in foreground mode, and the default configuration is used. 1.3 background startup service can modify the daemonize parameter of redis.conf file to yes and specify the configuration file to start, for example: [root@redis_1 redis-4.0.8] # cp-a redis.conf {, _ $(date +% F)} [root@redis_1 redis-4.0.8] # vim redis.conf# By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in / var/run/redis.pid when daemonized.daemonize yes or execute the sed replacement command: [root@redis_1 redis-4.0.8] # sed-I' s#daemonize no#daemonize yes#g' red is.confs [root @ redis_1 redis-4.0.8] # grep 'daemonize yes' redis.confdaemonize yes specifies the configuration file to start. [root@redis_1 redis-4.0.8] # redis-server redis.conf stops the redis-server process started in the background: [root@redis_1 redis-4.0.8] # redis-cli-h $(hostname-I)-c-p ${Port} 192.168.1.101 redis-server 7000 > SHUTDOWNnot connected > exit

For example:

# specify configuration file backend launch [root@redis_1 redis-4.0.8] # src/redis-server redis.conf95778:C 30 Jan 00 Jan 44vv 37.633 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo95778:C 30 Jan 00vv 44vv 37.634 # Redis version=4.0.7, bits=64, commit=00000000, modified=0, pid=95778 Just started95778:C 30 Jan 00 145268 44 Redis 37.634 # Configuration loaded# View Redis process [root@redis_1 redis-4.0.8] # ps aux | grep redisroot 0.0 0.0 468? Ssl 00:44 0:00 src/redis-server 127.0.0.1 src/redis-server 6379 more startup parameters are as follows: [root@redis_1 src] #. / redis-server-- helpUsage:. / redis-server [/ path/to/redis.conf] [options]. / redis-server-(read config from stdin). / redis-server-v or-- version. / redis-server-h or-- help. / redis-server-test-memory Examples:. / redis-server (run the server with default conf). / redis-server / etc/redis/6379.conf. / redis-server-- port 7777. / redis-server-- port 7777-- slaveof 127.0.0.1 8888. / redis-server / etc/myredis.conf-- loglevel verboseSentinel mode:. / redis-server / etc/sentinel.conf-- sentinel1.4 Client test [root@redis_1 redis-4.0.8] # src/redis-cli redis > set foo bar OK redis > get foo "bar" 2. Redis cluster profile settings and startup instance 2.1 settings configuration file cluster deployment of Redis requires Redis to be installed on each machine deployed in the cluster You can refer to the above Redis deployment, and then modify the configuration to start in a cluster manner. We want to build a Redis cluster on a single machine by launching multiple instances through different TCP ports and then forming a cluster. It should be noted that there must be 3 or more master nodes, otherwise the creation of the cluster will fail, and when the number of surviving master nodes is less than half of the total number of nodes, the entire cluster will not be able to provide services. The minimum cluster mode requires three master instances. Generally speaking, it is recommended to start with six instances, that is, three masters and three slaves. So we created six directories named after the port number to hold the configuration files and other information for the instance. [root@redis_1 redis-4.0.8] # mkdir-pv redis-cluster/ {7000 cd redis-cluster/7000 7001 7002 7003 7004 7005} [root@redis_1 redis-4.0.8] # cd redis-cluster/7000

Create a redis.conf file in the directory of the corresponding port number. For the contents of the configuration file, please refer to the cluster mode configuration below. The port number port parameter in each configuration file changes to the port number of the corresponding directory. Modify the configuration file redis.conf, and the configuration file for cluster mode is as follows: [root@redis_1 7000] # vim redis.confdaemonize yes / / redis running in the background; port 7000 / / port 7000Magi 7001Magi 7002pm 7003pm 7004pm 7005timout 600 / / client unresponsive connection timeout Defaults to turn off bind 192.168.1.91 / / default ip is 127.0.0.1 need to be changed to ip accessible by other node machines, otherwise the corresponding port cannot be accessed when creating a cluster, and the cluster cannot be created; pidfile / var/run/redis_7000.pid / / pidfile file corresponds to 7000magentin 7002magistr7003Power7004Power7005clustercolor enabled yes / / enable the cluster to remove the comment # For the first time, the configuration file of the cluster-config-file nodes_7000.conf / / cluster starts automatic generation of 7007001rec 7002jr 7003jr 7004j 7005; cluster-node-timeout 15000 / / request timeout defaults to 15 seconds, which can be set by itself; appendonly yes / / aof log is enabled if necessary, and a log is recorded for each write operation. # see [root@redis_1 7000] # egrep "^ daemonize | ^ port | ^ timeout | ^ bind | ^ pidfile | ^ cluster-| ^ appendonly" redis.conf for more cluster configuration parameters, please see the description of Cluster module in the default configuration file redis.conf.

2.2 start the instance to copy the redis-server binaries to the redis-cluster directory, and start the redis service by specifying the configuration file. For example, [root@redis_1 7000] # pwd/usr/local/redis-4.0.8/redis-cluster/7000 [root@redis_1 7000] # redis-server. / redis.conf # needs to execute the file in the specified instance directory, and the file will be generated in the current directory of the command. 2497 May C 18 May 13 Redis version=4.0.8 24.279 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo2497:C 18 May 13 Redis version=4.0.8 24.279 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=2497, just started2497:C 18 May 13V 42V 24.279 # Configuration loaded if it is running in the foreground mode, the following information will be output on the console: [82462] 26 Nov 1156 Redis version=4.0.8 55.329 * No cluster configuration found, Isimm 97a3a64667477371c4479320d683e4c8db5858b1 generates a Node ID for each instance, similar to 97a3a64667477371c4479320d683e4c8db5858b1 Used as the unique identity of the Redis instance in the cluster, rather than through IP and Port,IP and Port may change, the Node ID will not change. For more information on directory structure, please see redis-cluster/ ├── 7000 │ ├── appendonly.aof │ ├── dump.rdb │ ├── nodes.conf │ redis.conf ├── 7001 │ ├── appendonly.aof │ ├── dump.rdb │ ├── nodes.conf │ └── redis.conf ├── 7002 │ ├── appendonly.aof │ ├── dump.rdb │ ├── nodes.conf │ └── redis.conf ├── 7003 │ ├── appendonly.aof │ ├── dump.rdb │ ├── nodes.conf │ └── redis.conf ├── 7004 │ appendonly.aof dump .rdb │ ├── nodes.conf │ └── redis.conf ├── 7005 │ ├── appendonly.aof │ ├── dump.rdb │ ├── nodes.conf │ └── redis.conf ├── redis-cli └── redis-server

Note: dump.rdb is a data storage file, which is not available when you start the cluster for the first time. After all the instances of Redis are running, you also need the redis-trib.rb tool to create the cluster. The redis-trib.rb binaries are in the src directory under the home directory of the Redis package. Running the tool depends on the Ruby environment and gem.

Note: following steps 3 and 4 for different environments, the server can connect to the public network recommended step 3, can not connect to the public network recommended step 4 source code installation dependency package, you can install one.

3 online installation of Redis cluster dependencies (Ruby and RubyGems and rvm and gem) 3.1 install Ruby [root @ redis_1 src] # yum install ruby rubygems-y to view Ruby version information. [root@redis_1 src] # ruby-- versionruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] because the centos6 system supports Ruby version 1.8.7 by default (centos7 system supports Ruby version 2.0.0 by default), the following error is reported when executing the gem install redis command. [root@redis_1 src] # gem install redisFetching: redis-4.0.1.gem ERROR: Error installing redis: redis requires Ruby version > = 2.2.2. The workaround is to install rvm before upgrading the ruby version. Install rvmcurl-L get.rvm.io | bash-s stable if you encounter the following error, execute the command gpg2-- recv-keys in the error report. [root@redis_1 ~] # curl-L get.rvm.io | bash-s stable% Total% Received% Xferd Average Speed Time Current Dload Upload Total Spent Left Speed100 194 100 194 00 3350 0 -:-335100 24090 100 24090 00 17421 00: 00:01 0:00:01-44446Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gzDownloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.ascgpg: signature created by CST at 04:59:21 on Monday, September 11, 2017 Using RSA, key number BF04FF17gpg: unable to check signature: no public key Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures). GPG signature verification failed for'/ usr/local/rvm/archives/rvm-1.29.3.tgz'-'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'! Try to install GPG v2 and then fetch the public key: gpg2-recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 or if it fails: command curl-sSL https://rvm.io/mpapis.asc | gpg2-- import-the key can be compared with: https://rvm.io/mpapis.asc https://keybase.io/mpapisNOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above. Execute the command of gpg2-recv-keys in the error report. For example: [root@redis_1 ~] # gpg2-- recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3gpg: key ring'/ root/.gnupg/secring.gpg' established gpg: download key 'D39DC0E3' From the hkp server keys.gnupg.netgpg: / root/.gnupg/trustdb.gpg: established the trust database gpg: key D39DC0E3: public key "Michal Papis (RVM signing)" imported gpg: did not find any absolutely trusted keys gpg: total number of processed: 1gpg: imported: 1 (RSA: 1) execute the command curl-L get.rvm.io again | bash-s stable. [root@redis_1 ~] # curl-L get.rvm.io | bash-s stable% Total% Received% Xferd Average Speed Time Current Dload Upload Total Spent Left Speed100 194 100 194 00 3100-309100 24090 100 24090 00 18230 00: 00:01 0:00:01-103kDownloading https://github.com/rvm/rvm/archive/1.29.3.tar.gzDownloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.ascgpg: signature created by CST at 04:59:21 on Monday, September 11, 2017 Using RSA, key number BF04FF17gpg: intact signature from "Michal Papis (RVM signing)" gpg: that is, "Michal Papis" gpg: that is, "[jpeg image of size 5015]" gpg: warning: this key has not been authenticated by a trusted signature! Gpg: there is no evidence that this signature belongs to the holder it claims to be. Master key fingerprints: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 subkey fingerprints: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17GPG verified'/ usr/local/rvm/archives/rvm-1.29.3.tgz'Creating group 'rvm'Installing RVM to / usr/local/rvm/Installation of RVM in / usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to' rvm' group, and logout-login again, anyone using rvm will be operating with `umask upright rwx Magnum * To start using RVM you need to run `source / etc/profile.d/ rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows. The above indicates that the execution was successful, and then execute the following command.

[root@redis_1 ~] # source / usr/local/rvm/scripts/rvm View the known ruby version rvm list known in the rvm library for example:

[root@redis_1 ~] # rvm list known # MRI Rubies [ruby-] 1.8.6 [- p420] [ruby-] 1.8.7 [- head] # security released on head [ruby-] 1.9.1 [- p431] [ruby-] 1.9.2 [- p330] [ruby-] 1.9.3 [- p551] [ruby-] 2.0.0 [- p648] [ruby-] 2 .1 [.10] [ruby-] 2.2 [.7] [ruby-] 2.3 [.4] [ruby-] 2.4 [.1] ruby-head. 3.3 upgrade Ruby# installation ruby

Rvm install 2.4.0

# remove the old version using the new version of rvm use 2.4.

Rvm remove 1.8." View the current version of ruby-- version for example:

[root@redis_1] # rvm install 2.4.0 Searching for binary rubies, this might take some time. Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/7/x86_64/ruby-2.4.0.tar.bz2 Checking requirements for centos. Installing requirements for centos. Installing required packages: autoconf, automake, bison, bzip2, gcc-c++, libffi-devel, libtool, readline-devel, sqlite-devel, zlib-devel, libyaml-devel, openssl-devel.. Requirements installation successful. Ruby-2.4.0-# configure ruby-2.4.0-# download% Total% Received% Xferd Average Speed Time Current Dload Upload Total Spent Left Speed100 14.0M 100 14.0M 00 852k 00: 00:16 0:00:16 -:-980kNo checksum for downloaded archive Recording checksum in user configuration.ruby-2.4.0-# validate archiveruby-2.4.0-# extractruby-2.4.0-# validate binaryruby-2.4.0-# setupruby-2.4.0-# gemset created / usr/local/rvm/gems/ruby-2.4.0@globalruby-2.4.0-# importing gemset / usr/local/rvm/gemsets/global.gems. .ruby-2.4.0-# generating global wrappers.ruby-2.4.0-# gemset created / usr/local/rvm/gems/ruby-2.4.0ruby-2.4.0-# importing gemsetfile / usr/local/rvm/gemsets/default.gems evaluated to empty gem listruby-2.4.0-# generating default wrappers.[ root @ redis_1 ~] # rvm use 2 .4.0Using / usr/local/rvm/gems/ruby-2.4.0 [root@redis_1 ~] # rvm remove 1.8.7ruby-1.8.7-p648-# already goneUsing / usr/local/rvm/gems/ruby-2.4.0 [root@redis_1 ~] # ruby--versionruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux] 3.4 install gem

[root@redis_1] # gem install redisFetching: redis-4.0.1.gem Successfully installed redis-4.0.1Parsing documentation for redis-4.0.1Installing ri documentation for redis-4.0.1Done installing documentation for redis after 2 seconds1 gem installed4 source code installation Redis cluster dependencies (Ruby and RubyGems and OpenSSL and Zlib-devel and gem) 4.1 installation Zlib-devel official website: https://pkgs.org/download/zlibhttps://pkgs.org/download/zlib-devel selection Select the zlib and zlib-devel packages for the corresponding system version This lab is CentOS 6 64 bit The zlib-1.2.3-29.el6.x86_64.rpm and zlib-devel-1.2.3-29.el6.x86_64.rpm packages that select el6 have yum sources: [root@redis_1 tools] # yum install zlib zlib-devel- y does not have yum sources: [root@redis_1 tools] # wget http://mirror.centos.org/centos/6/os/x86_64/Packages/zlib-1.2.3-29.el6.x86_64.rpm[root@ Redis_1 tools] # wget http://mirror.centos.org/centos/6/os/x86_64/Packages/zlib-devel-1.2.3-29.el6.x86_64.rpm [root@redis_1 tools] # rpm-ivh zlib-1.2.3-29.el6.x86_64.rpm zlib-devel-1.2.3-29.el6.x86_64.rpm4.2 install Ruby: to the Ruby official website: https://www.ruby-lang.org/ En/downloads/ found a stable version of Ruby above version 2.2 This lab uses ruby-2.3.6 Note: if the ruby-2.5.0 version is installed on CentOS6.*, you need to upgrade GCC (4.8) to enter linux and choose a location to store the installation package. My location is / opt/tools input command wget + the installation package URL that I just copied [root @ redis_1 tools] # pwd/opt/ tools [root @ redis_1 tools] # wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.gz[root@redis_1 tools] # tar zxf ruby-2.3.6.tar.gz-C / usr/local/ [root @ redis_1 tools] # cd / usr / local/ruby-2.3.6 [root@redis_1 ruby-2.3.6] #. / configure # can specify the installation path. / configure-- prefix=/usr/local/ ruby [root @ redis_1 ruby-2.3.6] # Mak [root @ redis_1 ruby-2.3.6] # make install verify: [root@redis_1 ruby-2.3.6] # source / etc/ profile [root @ redis_1 ruby-2. # ruby- vruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux] [root@redis_1 ruby-2.3.6] # cd ext/zlib/ [root @ redis_1 zlib] # pwd/usr/local/ruby-2.3.6/ext/zli [root@redis_1 zlib] # ruby. / extconf.rbchecking for deflateReset () in-lz... Yeschecking for zlib.h... Yeschecking for crc32_combine () in zlib.h... Yeschecking for adler32_combine () in zlib.h... Yeschecking for z_crc_t in zlib.h... Nocreating Makefile [root @ redis_1 zlib] # makecompiling zlib.clinking shared-object zlib.so [root @ redis_1 zlib] # make install/usr/bin/install-c-m 0755 zlib.so / usr/local/lib/ruby/site_ruby/2.3.0/x86_64- Linux [root @ redis_1 zlib] # 4.3 install RubyGems: official website https://rubygems.org/pages/downloadwget + URL Download the installation package online: [root@redis_1 tools] # wget https://rubygems.org/rubygems/rubygems-2.7.6.tgz[root@redis_1 tools] # tar xf rubygems-2.7.6.tgz-C / usr/local/ [root @ redis_1 tools] # cd / usr/local/rubygems-2.7.6/ [root@redis_1 rubygems-2.7.6] # ruby setup.rbBundler 1.16.1 installedRubyGems 2.7.6 installed... .. RubyGems installed the following executables: / usr/local/bin/gem / usr/local/bin/bundleRuby Interactive (ri) documentation was installed. Ri is kind of like manpages for Ruby libraries. You may access it like this: ri Classname ri Classname.class_method ri Classname#instance_methodIf you do not wish to install this documentation in the future, use the--no-document flag, or set it as the default in your ~ / gemrc file. See'gem help env' for details. Verification: [root@redis_1 rubygems-2.7.6] # gem-v2.7.64.4 install OpenSSL: official website: https://www.openssl.org/source/wget download installation package:

[root@redis_1 tools] # wget https://www.openssl.org/source/openssl-1.1.1-pre6.tar.gz[root@redis_1 tools] # tar xf openssl-1.1.1-pre6.tar.gz-C / usr/local/ [root @ redis_1 tools] # cd / usr/local/openssl-1.1.1-pre6/ [root@redis_1 openssl-1.1.1-pre6] # mkdir-v / usr/local/opensslmkdir: already Create the directory "/ usr/local/openssl" [root@redis_1 openssl-1.1.1-pre6] #. / config-- prefix=/usr/local/openssl-- Shared [root @ redis_1 openssl-1.1.1-pre6] # make[ root @ redis_1 openssl-1.1.1-pre6] # make install add "/ usr/local/openssl/lib" to the system class package: [root@redis_1 openssl-1.1.1-pre6] # echo- E "/ usr/local/openssl/lib" > / etc/ld.so.conf.d/ openssl.confs [root @ redis_1 openssl-1.1.1-pre6] # cat / etc/ld.so.conf.d/openssl.conf/usr/local/openssl/lib [root@redis_1 openssl-1.1.1-pre6] # ldconfig # add the reload class to the environment variable : [root@redis_1 openssl-1.1.1-pre6] # echo-e "# openssl\ nexport OPENSSL=/usr/local/openssl/bin\ nexport PATH=\ $OPENSSL:\ $PATH:\ $HOME/bin" > / etc/profile.d/ openssl.sh [root @ redis_1 openssl-1.1.1-pre6] # cat / etc/profile.d/openssl.sh # openssl export OPENSSL=/usr/local/openssl/bin export PATH=$OPENSSL:$PATH:$HOME/bin [root @ redis_1 openssl-1.1.1-pre6] # source / etc/profile # reload environment variables # verify: [root@redis_1 openssl-1.1.1-pre6] # echo $OPENSSL/usr/local/openssl/ [root @ redis_1 openssl-1.1.1-pre6] # 4.5 install redis.gem official website: https://rubygems.org/gems/redis[root@redis_1 redis-4.0.8] # cd / Usr/local/redis-4.0.8/ [root@redis_1 redis-4.0.8] # pwd/usr/local/redis-4.0.8 [root@redis_1 redis-4.0.8] # wget https://rubygems.org/downloads/redis-4.0.1.gem[root@redis_1 redis-4.0.8] # gem install-l. / redis-4.0.1.gemSuccessfully installed redis-4.0.1Parsing documentation for redis-4.0 .1Done installing documentation for redis after 3 seconds1 gem installed5 redis-trib create cluster # execute redis-trib.rb command

[root@redis_1 redis-4.0.8] # cd / usr/local/redis-4.0.8/src/ [root@redis_1 src] #. / redis-trib.rb create-- replicas 1 127.0.0.1VL 7000 127.0.0.1usr/local/redis-4.0.8/src/ 7001\ > 127.0.0.1usr/local/redis-4.0.8/src/ 7003 127.0.1Rank 7004 127.0.1VOD 7005 parameter create means to create a new cluster -- replicas 1 means to create a slave for each master. If the creation is successful, the following information is displayed

[OK] All 16384 slots covered for example:

[root@redis_1 src] #. / redis-trib.rb create-- replicas 1 127.0.0.1 replicas 7000 127.0.0.1 replicas 7002 127.0.1 replicas 7003 127.0.1 replicas 7004 127.0.0.1 replicas 7004 127.0.0.1 replicas 7004 127.0.0.1 Using 3 masters: 127.0.0.1 Adding replica 7002 Adding replica 127.0.1 Adding replica 7004 to 127.0.1 Adding replica 127.0.1 Vol 7005 to 127.0.1 Adding replica 7001 Adding replica 127.0.1 Adding replica 7003 to 127.0.0.1 Adding replica 7002 > Trying to optimize slaves allocation for anti-affinity [WARNING] Some slaves are In the same host as their master M: d5a834d075fd93eefab877c6ebb86efff680650f 127.0.0.1 slots 7000slots:0-5460 (5461 slots) master M: 13d0c397604a0b2644244c37b666fce83f29faa8 127.0.0.1slots:0 7001 slots:5461-10922 (5462 slots) master M: be2718476eba4e56f696e56b75e67df720b7fc24 127.0.0.1 slots 7002 slots:10923-16383 (5461 slots) master S: 3d02f59b34047486faecc023685379de7b38076c 127.0.0.1 replicates 13d0c397604a0b2644244c37b666fce83f29faa8 7003 replicates 13d0c397604a0b2644244c37b666fce83f29faa8 S: dedf672f0a75faf37407ac4edd5da23bc4651e25 127.0.0.1 Ride 7004 replicates Be2718476eba4e56f696e56b75e67df720b7fc24 S: 99c07119a449a703583019f7699e15afa0e41952 127.0.0.1:7005 replicates d5a834d075fd93eefab877c6ebb86efff680650f Can I set the above configuration? (type 'yes' to accept): yes # agrees with yes > > Nodes configuration updated > Assign a different config epoch to each node > Sending CLUSTER MEET messages to join the cluster Waiting for the cluster to join.... > Performing Cluster Check (using node 127.0.0.1slots:0 7000) M: d5a834d075fd93eefab877c6ebb86efff680650f 127.0.0.1Vera 7000 slots:0-5460 (5461 slots) master 1 additional replica (s) M: be2718476eba4e56f696e56b75e67df720b7fc24 127.0.0.1 master 7002 slots:10923-16383 (5461 slots) master 1 additional replica (s) M: 13d0c397604a0b2644244c37b666fce83f29faa8 127.0.0.1 master 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) S: 3d02f59b34047486faecc023685379de7b38076c 127.0.0.1 slave replicates 13d0c397604a0b2644244c37b666fce83f29faa8 7003 slots: (0 slots) slave replicates be2718476eba4e56f696e56b75e67df720b7fc24 S: 99c07119a449a703583019f7699e15afa0e41952 127.0.0.1 99c07119a449a703583019f7699e15afa0e41952 7005 slots: (0 slots) slave replicates d5a834d075fd93eefab877c6ebb86efff680650f S: dedf672f0a75faf37407ac4edd5da23bc4651e25 127.0.1 slave replicates be2718476eba4e56f696e56b75e67df720b7fc24 7004 slots: (0 slots) slave replicates be2718476eba4e56f696e56b75e67df720b7fc24 [OK] All nodes agree about slots configuration. > Check for open slots... > Check slots coverage... [OK] All 16384 slots covered.6 cluster deployment result verification 6.1 client verification uses client redis-cli binary to access an instance and performs set and get tests. Syntax: redis-cli-h $IP-c-p $PORT-a $PASSWORD [root @ redis_1 src] # redis-cli-c-p 7000redis 127.0.0.1PORT 7000 > set foo bar- > Redirected to slot [12182] located at 127.0.0.1:7002OKredis 127.0.0.1PORT 7002 > set hello world- > Redirected to slot [866] located at 127.0.0.1:7000OKredis 127.0.1purl 7000 > get foo- > Redirected to slot [12182] located at 127. 0.0.1 bar 7002 "bar" redis 127.0.0.1 get hello- > Redirected to slot [866] located at 127.0.0.1 located at 7000 "world" 6.2 Cluster status use the cluster info command to view the cluster status.

127.0.0.1 cluster infocluster_state:ok 7000 > cluster_slots_ok:16384 # Cluster status cluster_slots_assigned:16384 # number of slots allocated cluster_slots_ok:16384 # correctly allocated slots cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:6 # current node cluster_size:3cluster_current_epoch:6cluster_my _ epoch:1cluster_stats_messages_ping_sent:48273cluster_stats_messages_pong_sent:49884cluster_stats_messages_sent:98157cluster_stats_messages_ping_received:49879cluster_stats_messages_pong_received:48273cluster_stats_messages_meet_received:5cluster_stats_messages_received:981576.3 node status use the cluster nodes command to view the node status. 127.0.0.1 cluster nodesbe2718476eba4e56f696e56b75e67df720b7fc24 7002 "17002 master-0 1517303607000 3 connected 10923-1638313d0c397604a0b2644244c37b666fce83f29faa8 127.0.0.1" 7001 "17001 master-01517303606000 2 connected 5461-109223d02f59b34047486faecc023685379de7b38076c 127.0.0.1" 7003 "17003 slave 13d0c397604a0b2644244c37b666fce83f29faa8 01517303606030 4 connectedd5a834d075fd93eefab877c6ebb86efff680650f 127.0.0.1 Master-0 1517303604000 1 connected 0-546099c07119a449a703583019f7699e15afa0e41952 127.0.0.1 connected 7005mm 17005 slave d5a834d075fd93eefab877c6ebb86efff680650f 01517303607060 6 connecteddedf672f0a75faf37407ac4edd5da23bc4651e25 127.0.1Parse 7004mm 17004 slave be2718476eba4e56f696e56b75e67df720b7fc24 01517303608082 5 connected7 reference: https://redis.io/downloadhttps://redis.io/topics/cluster-tutorialhttp://blog.csdn.net/huwh_/article/details/79242625http://blog.csdn.net/michaelehome/article/details/795334968 attachment: redis cluster password setting 8.1 password setting (recommended) Method 1: modify the redis.conf files in all Redis clusters to add: masterauth passwd123 requirepass passwd123 description: this way requires restarting each node mode 2: enter each instance to set: redis-cli-h $IP-c-p port. / redis-cli-c-p 7000 config set masterauth passwd123 config set requirepass passwd123 config rewrite and then use. / redis-cli-c-p 7001 respectively. . / redis-cli-c-p 7002... .. Command to set a password for each node. Note: the password of each node must be the same, or the Redirected will fail. This method is recommended, which writes the password to the redis.conf without restarting. Use method 2 to change the password,. / redis-trib.rb check 10.104.111.174Sorry 6379 may be reported to [ERR] Sorry, can't connect to node 10.104.111.174Sorry 6379, because 6379 of the redis.conf did not find the password configuration. 8.2 after setting the password, if you need to use various commands of redis-trib.rb, such as:. / redis-trib.rb check 127.0.0.1v7000 Will report an error ERR] Sorry Can't connect to node 127.0.0.1 can't connect to node 7000 solution: vim / usr/local/rvm/gems/ruby-2.3.0/gems/redis-4.0.1/lib/redis/client.rb # networking installation path vim / usr/local/lib/ruby/gems/2.3.0/gems/redis-4.0.1/lib/redis/client.rb # Source Code installation path Note: client.rb The path can be found through the find command: find /-name 'client.rb' and then modify passordclass Client DEFAULTS = {: url = > lambda {ENV ["REDIS_URL"]} : scheme = > "redis",: host = > "127.0.0.1",: port = > 6379,: path = > nil,: timeout = > 5.0,: password = > "passwd123",: db = > 0,: driver = > nil,: id = > nil,: tcp_keepalive = > 0,: reconnect_attempts = > 1 : inherit_socket = > false} access cluster with password. / redis-cli-c-p 7000-a passwd123END

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.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report