redis-- build clusters

1, linux version

1、pwd                       
## to view the current path, will be downloaded redis upload. redis stable version for the first two even.
2、/home/bxapp              
 ## current path
3、mkdir redis               
## redis create the files, redis -4.0.11.tar.gz uploaded to the / opt folder
 4, tar -zxvf redis-4.0.11 .tar.gz  
## extract the folder
5, cd repeat-4.0.11 /
6、 make && make PREFIX=/usr/local/redis install  
 ## installing Redis (requires root privileges) by the make command
7、cd /usr/local/  
8、mkdir -p /usr/local/redis-cluster
9、cd redis-cluster/
10、mkdir 7031 7032 7033 7034 7035 7036    
Number ## to set the number of clusters
11、cp opt/redis-4.0.11/redis.conf  usr/local/redis-cluster
12、cp redis.conf 7031
13 , corresponding redis.conf edit files, respective item information modified as follows (detailed configuration information, see Notes)
             1) bound port, port 7031
            2) binding the IP, the bind 192.168.174.128 (: 172.20.105.192 )
             . 3) designating data storage path, dir / usr / local / redis -cluster / 7031
            4) Start the cluster model, Cluster- Enabled yes
             5) specifies the cluster node configuration file, config-File-Cluster Nodes-7031 .conf
             7 ) back to start, yes daemonize
             8) specifies the cluster node timeout, cluster-node-timeout 5000
            9 ) specify the persistent mode, appendOnly Yes
             10 ) disposed password requirepass
 14, 7031 will be copied to the remaining redis.conf folder, replace all the nodes 7031 corresponding to the port number (Port, Cluster-config- File, the dir three place)
cp redis.conf /usr/local/redis-cluster/7032 
cp redis.conf /usr/local/redis-cluster/7036

## error-prone and ruby ​​and gem-related
15, install ruby. If you have on your system ruby, a version lower than 2.2.2 uninstall it. Installation of high version of ruby. (Official website is now the most stable version 2.5 )
     ruby -v 
     View ruby ​​version number
     yum remove ruby 
     Uninstall ruby
     Offline installation ruby ​​faster (online installation always fail, I found a hundred letters within the network environment, linux pull files total failure):
     ## It is strongly recommended to install an offline version of the high ruby, high version comes gem.
     1) upload a file-2.5.7 Ruby .tar.gz
      2) tar -zxvf Ruby-2.5.7 .tar.gz Unzip the file
      3) mkdir -p / usr / local / Ruby create the installation directory
      4) ./ configure - = prefix / usr / local / Ruby configuration and mounting position of the development
      . 5) the make && the make and install the install the compiler (turtle speed)
      . 5) Ruby prompt -v / usr / bin / Ruby: No File or Directory SUCH 
      . 7) acknowledgment / usr is / local / Ruby / bin / Ruby - Version
      ## If you have version information, it means that the ruby is attached to the directory, rather than the system think of / usr / bin / ruby           
      8) establish a soft link ln -s / usr / local / ruby / bin / ruby / usr / bin / Ruby              
      . 9) Ruby - V complete the OK
     Ruby 1.9 after .2 version is installed by default Ruby Gem. So after installing ruby, view the gem version, gem also need to create a soft link
     If this happens also install the gem [ -bash: / usr / bin / gem: No SUCH File or Directory] is the same reason
      10) LN -s / usr / local / Ruby / bin / gem / usr / bin / gem establish gem soft connection
## comes as ruby ​​gem, not the operation of Step 16     
16, yum install rubygems # If the source can not be installed, the installation manual, and finally establish a flexible connection -s LN / usr / local / ruby / bin / GEM / usr / bin / GEM
 . 17 , the install redis GEM (ruby mounting interface program and redis )
      1 ) error 1:
     ERROR:  Loading command: install (LoadError)
        cannot load such file -- zlib
     ERROR:  While executing gem ... (NoMethodError)
     Method, `invoke_with_build_args undefined 'for nil: NilClass
      reasons: Missing zlib library dependencies
     Solution: Install zlib dependent

    1)ERROR:  Could not find a valid gem 'rails' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Connection timed out - connect(2) for "s3.amazonaws.com" port 443 (https://api.rubygems.org/latest_specs.4.8.gz)

     Solution: Internet, said the situation above need to switch sources, the source is now easy to use
            Sources GEM sudo -r HTTPS: // rubygems.org ## to remove the source 
            sudo GEM Sources -a HTTPS: // rubygems.org ## to add the source 
            sudo GEM Sources -a HTTP: // gems.ruby-china.com/ ## 
            gem sources - L View gem all sources

# Start redis examples
18 is, CD / usr / local / redis- Cluster
 . 19, for ((I =. 1; I <=. 6; I ++)); do / usr / local / Redis / bin / Redis-Server / usr / local / Redis-Cluster / i $ 703 / redis.conf; DONE
 20, PS -aux | grep is running successfully redis redis View 
 21, find redis-trib.rb files are generally under redis redis-trib.rb src source directory, and if you do not know find / -name "redis-trib.rb"
22, into the / src / bin /   ## seems to be in the src folder below  
 23 ,
./redis-trib.rb create --replicas 1 127.0.0.1:7031  127.0.0.1:7032  127.0.0.1:7033  127.0.0.1:7034  127.0.0.1:7035  127.0.0.1:7036
24 , cluster set up a successful test
  / usr / local / redis / bin / redis-cli -c -h 127.0.0.1 -p 7031  

#redis command -trib.rb program is to create, represents the creation of a new cluster. Options --replicas 1 represents the creation of a node from the cluster node of each primary
1 actually represents a ratio of the number of nodes is the main / ratio from the number of nodes. For Redis slot cluster, a place to store data corresponding to one slot. For each Master concerned, there will be a range of a slot, and Slave no. In Redis cluster, still Master can read, write, and read-only Slave. Write data is actually stored in the slot in the distribution.

25 , the cluster is restarted to restart the normal individual may be restarted, then allowed configuration information
 26, shut down the cluster   for ((. 1 = I; I <=. 6; I ++)); do / usr / local / Redis / bin / redis- cli -c -h 127.0.0.1 -p 703 $ i   shutdown; done

 

Guess you like

Origin www.cnblogs.com/lpp-xjj/p/11918035.html