In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Introduction to redis cluster:
After 3.0 version is added, decentralized design, different redis nodes can receive user requests and hold different data, each node shares node innode information to facilitate data finding.
Preparation for the experiment:
Test goal: 3 machines, each machine 2 nodes a total of 6 nodes to form a complete high-availability cluster.
Test environment:
HOSTIPsoftwarePORTSYSTEMnode1192.168.23.128redis-4.0.1070017004CentOS 7.4node2192.168.23.129redis-4.0.1070027005CentOS 7.4node3192.168.23.131redis-4.0.1070037006CentOS 7.4
Procedure:
1. Download the software to / usr/local:wget http://download.redis.io/releases/redis-4.0.10.tar.gz
two。 Compilation and installation
Tar xzf redis-4.0.10.tar.gzcd redis-4.0.10make & & make install # if there is a software dependency installation dependency package # copy the redis cluster management command cp / usr/local/redis-4.0.10/src/redis-trib.rb / usr/local/bin/
3. Configure nodes (take node1 node 7001 as an example)
Mkdir-p / data/redis-cluster/ {7001J 7004} cp / usr/local/redis-4.0.10/redis.conf / data/redis-cluster/7001/redis-7001.conf
The configuration file needs to be modified:
# vim / data/redis-cluster/7001/redis-7001.confbind 0.0.0.0port 7001daemonize yespidfile / var/run/redis_7001.piddir / data/redis-cluster/7001logfile "/ var/log/redis/7001.log" cluster-enabled yescluster-node-timeout 2000appendonly yescluster-config-file nodes-7001.conf## create a new log directory and file mkdir / var/log/redis## launch each redis instance cd 7001redis-server. / redis7001.conf
Copy the configuration file to another node and start it separately:
Grep-v "^ #" redis-7001.conf | grep-v "^ $" > redis.conf.temcp redis.conf.tem / data/redis-cluser/700X/redis-700X.confvim modify the copied configuration file::% s/7001/700X/g
4. Configure the cluster redis-trib.rb tool environment (written in ruby language)
Redis cluster management tool requires ruby2.2 or above. Check the version ruby-v.
It is recommended to install yum (only on one server):
Add yum install centos-release-scl-rh yum install rh-ruby23-yscl enable rh-ruby23 bashruby-v to the environment variable: echo "source / opt/rh/rh-ruby23/enable" > > / etc/profile source / etc/profilegem install redis # install the redis plug-in. If the download is slow, you can switch to the domestic Geme source # gem sources-l#gem sources-remove https://rubygems.org/#gem source-a https://gems.ruby-china.com.
Initialize the redis cluster
# Note that the hostname and DNS are not well supported when creating a cluster, so it is best to use IP:port.
Method 1: start a Master on each of the three hosts first, and cross-join each host Master,0,1 to indicate the number of slave nodes at the start of slave
# the odd number of designed ports is master and the even number is slaveredis-trib.rb create-- replicas 0 192.168.23.128replicas 7001 192.168.23.129replicas 7002 192.168.23.131:7003redis-trib.rb check 192.168.23.128replicas 7001 # check any host node And record that master-id### starts slave to join each Masterredis-trib.rb add-node-- slave-- master-id e3933a2276962abb7180ebe7767a544bdd539f27 192.168.23.128 Masterredis-trib.rb add-node 7004 (new node) 192.168.23.128 Masterredis-trib.rb add-node 7001 (any old node) redis-trib.rb add-node-- slave-- master-id cee9b75e480a3d707e7079631a280e732e0264b7 192.168.23.129 Masterredis-trib.rb add-node 7005 192.168.23.128:7001redis-trib.rb add-node-- slave-- master-id c61feb0e6f33d467758e8278436c03ce265c44b1 192.168.23.131Masterredis-trib.rb add-node 7006 192.168.23.1287001
Creation method 2 (recommended):
Redis-trib.rb create-- replicas 1 192.168.23.128redis-trib.rb check 7002 192.168.23.129RV 7002 192.168.23.131Rd 7003 192.168.23.128Rd 7004 192.168.23.129Rd 7004 192.168.23.129Rd 7005 192.168.23.131Rd 7006Vol # check the correspondence redis-trib.rb check 192.168.23.128Rd 7001
Attached: example of how to use redis-trib.rb tool:
Https://www.jianshu.com/p/21f67bd739cc
5. Memory optimization related
# modify system parameters echo never > / sys/kernel/mm/transparent_hugepage/enabledecho 511 > / proc/sys/net/core/somaxconn and add to / etc/rc.localvim / etc/sysctl.conf vm.overcommit_memory=1net.core.somaxconn = 511kernel.pid_max=1000000sysctl-pvim / etc/security/limits.conf * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535
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.