数据库
首页 > 数据库> > LInux系统下搭建redis集群

LInux系统下搭建redis集群

作者:互联网

一、准备

 首先安装C语言的编译环境

apt-get install   gcc
或者
apt-get install  build-essential

  

一、下载redis编译安装

$ wget http://download.redis.io/releases/redis-4.0.10.tar.gz
$ tar xzf redis-4.0.10.tar.gz
$ cd redis-4.0.10
$ make //编译

 

在编译时出现以下错误:

1)、

cd src && make all
make[1]: Entering directory '/home/ubuntu/redis-4.0.11/src'
    CC adlist.o
/bin/sh: 1: cc: not found
Makefile:228: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory '/home/ubuntu/redis-4.0.11/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

解决办法:sudo apt-get install gcc

  

2)、

cd src && make all
make[1]: Entering directory '/home/ubuntu/redis-4.0.11/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:228: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory '/home/ubuntu/redis-4.0.11/src'

解决办法:make MALLOC=libc

  

二、进入到redis-4.0.10的src目录下,

执行编译命令:make install

三、安装ruby环境

命令>pt-get install ruby
命令>
gem install redis

四、
接下来我们创建6个配置文件,redis.6379.conf、redis.6379.conf、redis.6379.conf、redis.6379.conf、redis.6379.conf、redis.6379.conf,分别代表6个实例
配置如下:
port 6380
bing 10.211.55.8 #本机IP
daemonize  no  appendonly yes appendfilename "appendonly.6380.aof" cluster-enabled yes cluster-config-file nodes.6380.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes

  

五、分别启动六个服务
redis-server redis.6379.conf
redis-server redis.6380.conf
redis-server redis.6381.conf
redis-server redis.6382.conf
redis-server redis.6383.conf
redis-server redis.6384.conf

 六、创建集群

./redis-trib.rb create --replicas 1 10.211.55.8:6379 10.211.55.8:6380 10.211.55.8:6381 10.211.55.8:6382 10.211.55.9:6383 10.211.55.9:6384

 七、查看集群节点信息

./redis-trib.rb check 10.211.55.8:6379
elic@elic-Parallels-Virtual-Platform:~/桌面/redis-cluster$ ./redis-trib.rb check 10.211.55.8:6379
/var/lib/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 10.211.55.8:6379)
M: 3148d0c07c7ad9399c7cb22cc9060db141464552 10.211.55.8:6379
   slots:0-5460 (5461 slots) master,nofailover
   1 additional replica(s)
M: 9691a8e66f6e68294bb7eda44221c32a2d5260f9 10.211.55.9:6383
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 0f14d8221f6a48cb32250618ea18e7367f75df2a 10.211.55.8:6382
   slots: (0 slots) slave,nofailover
   replicates 9691a8e66f6e68294bb7eda44221c32a2d5260f9
S: 916e34afe5c38cb368abd2144ad56fe6fc227037 10.211.55.9:6384
   slots: (0 slots) slave
   replicates 8b76dde765ecb5a153b0303f645de8f97d063d17
S: 93653cbc9aee3d61d576b6ddd9cb6f05e19ab8e6 10.211.55.8:6381
   slots: (0 slots) slave,nofailover
   replicates 3148d0c07c7ad9399c7cb22cc9060db141464552
M: 8b76dde765ecb5a153b0303f645de8f97d063d17 10.211.55.8:6380
   slots:10923-16383 (5461 slots) master,nofailover
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

  

  八、启动集群中的节点客户端

redis-cli -h 10.211.55.8 -p 6379 -c

  

 
 




 

标签:55.8,make,redis,集群,conf,LInux,slots,10.211
来源: https://www.cnblogs.com/cyit/p/14833864.html