In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
(at least 3 master nodes are needed for the cluster to work properly. Here we need to create 6 redis nodes, of which three are master nodes and three are slave nodes. The ip and port correspondence of the corresponding redis nodes are as follows)
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
127.0.0.1:7003
127.0.0.1:7004
127.0.0.1:7005
1. Download redis. Download version 3.0.0 on the official website, 2. 0 before. Which version does not support cluster mode
Wget https://github.com/antirez/redis/archive/3.0.0-rc2.tar.gz
two。 Decompression and installation
Tar-zxvf redis-3.0.0-rc2.tar.gz
Mv redis-3.0.0-rc2.tar.gz / usr/local/redis3.0
Cd / usr/local/redis3.0
Make executes if it reports an error (make MALLOC=libc)
Make install
Errors may be reported at compile time:
Installation error error: jemalloc/jemalloc.h: No such file or directory solution
Error description
Error installing Redis 2.8.18 Times:
Zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
Zmalloc.h:55:2: error: # error "Newer version of jemalloc required"
Make [1]: * * [adlist.o] Error 1
Make [1]: Leaving directory `/ data0/src/redis-2.6.2/src'
Make: * * [all] Error 2
Cause analysis
There is a passage in README.
Allocator
-
Selecting a non-default memory allocator when building Redis is done by setting
The `MALLOC` environment variable. Redis is compiled and linked against libc
Malloc by default, with the exception of jemalloc being the default on Linux
Systems. This default was picked because jemalloc has proven to have fewer
Fragmentation problems than libc malloc.
To force compiling against libc malloc, use:
% make MALLOC=libc
To compile against jemalloc on Mac OS X systems, use:
% make MALLOC=jemalloc
Speaking of allocator allocator, if there is an environment variable MALLOC, it will be used to create Redis.
And libc is not the default allocator, the default is jemalloc, because jemalloc has been shown to have fewer fragmentation problems than libc.
But if you don't have jemalloc and you only have libc, of course make goes wrong. So add such a parameter.
Solution.
Make MALLOC=libc
3. Directories required to create a cluster
Mkdir-p / usr.local/cluster
Cd / usr.local/cluster
4. Modify the configuration file redis.conf
Cp / usr/local/redis3.0/redis.conf / usr.local/cluster/
Vim redis.conf
# what needs to be modified # #
Port 7000
Daemonize yes
Cluster-enabled yes
Cluster-config-file nodes.conf
Cluster-node-timeout 5000
Appendonly yes
# # after modifying these configuration items in the redis.conf configuration file, copy the configuration file to the 7000Universe 7001and7002and7003and7004and7005 directory respectively
# # Note: after the copy is completed, modify the port parameter in the redis.conf file under the 7001Universe 7002Universe 7003Universe 7004ax 7005 directory, and change it to the name of the corresponding folder.
5. Start these 6 redis instances respectively
Cd / usr/local/cluster/7000
Redis-server redis.conf
Cd / usr/local/cluster/7001
Redis-server redis.conf
Cd / usr/local/cluster/7002
Redis-server redis.conf
Cd / usr/local/cluster/7003
Redis-server redis.conf
Cd / usr/local/cluster/7004
Redis-server redis.conf
Cd / usr/local/cluster/7005
Redis-server redis.conf
# # use the command to check the startup status of redis after startup ps-ef | grep redis
[root@localhost ~] # ps-ef | grep redis
Root 2495 1 0 20:09? 00:00:04 redis-server *: 7000 [cluster]
Root 2505 10 20:10? 00:00:05 redis-server *: 7001 [cluster]
Root 2510 10 20:10? 00:00:04 redis-server *: 7002 [cluster]
Root 2520 1 0 20:13? 00:00:04 redis-server *: 7003 [cluster]
Root 2528 1 0 20:14? 00:00:04 redis-server *: 7004 [cluster]
Root 2534 1 0 20:14? 00:00:04 redis-server *: 7005 [cluster]
Root 2878 1477 0 20:54 pts/0 00:00:00 grep redis
6. Execute the create cluster command of redis to create a cluster
Install the environment and plug-ins needed to create the cluster
Yum install-y ruby
Yum install-y rubygems
Gem install redis (interface between redis and ruby, installed using gem) (this experimental environment can be accessed on the Internet)
Cd / usr/local/redis3.0/src/
. / redis-trib.rb create-- replicas 1 127.0.0.1VR 7000 127.0.0.1V 7001 127.0.0.1V 7002 127.0.0.1R 7003 127.0.1V 7003 127.0.1V 7004 127.0.1V 7005
At this point, the redis cluster is built successfully!
7. Use the redis-cli command to enter the cluster environment
Redis-cli-c-p 7000
Add-c to automatically jump to the corresponding port when the key value entered is not in the specified port.
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.