Home >Database >Redis >Installation of redis cluster in ubuntu

Installation of redis cluster in ubuntu

步履不停
步履不停Original
2019-07-02 16:38:362192browse

Installation of redis cluster in ubuntu

First check whether gcc is installed

gcc -v

If gcc is not installed, you need to install it

#centosyum install gcc-c++#ubuntusudo apt-get install gcc#不安装会有问题sudo apt install make

Download

wget http://download.redis.io/releases/redis-3.2.1.tar.gz
tar -zxvf redis-3.2.1.tar.gz cd redis-3.2.1
 make 
 make install PREFIX=/usr/local/redis

Creation of the cluster

cd /usr/local/
  mkdir redis_cluster  //创建集群目录
  mkdir 7000 7001 7002  //分别代表三个节点    其对应端口 7000 7001 7002
  
  cp /usr/local/redis-3.2.1/redis.conf  ./redis_cluster/7000/   
 //拷贝到7001目录
 cp /usr/local/redis-3.2.1/redis.conf  ./redis_cluster/7001/   
 //拷贝到7002目录
 cp /usr/local/redis-3.2.1/redis.conf  ./redis_cluster/7002/   
 
 sudo cp -r redis/bin/ redis_cluster/7000/
 sudo cp -r redis/bin/ redis_cluster/7001/
 sudo cp -r redis/bin/ redis_cluster/7002/

Modify the corresponding configurations of the three files in the 7001, 7002, and 7003 folders

daemonize    yes                          //redis后台运行pidfile  /var/run/redis_7000.pid          //pidfile文件对应7000,7002,7003port  7000                                //端口7000,7002,7003cluster-enabled  yes                      //开启集群  把注释#去掉cluster-config-file  nodes_7000.conf      //集群的配置  配置文件首次启动自动生成 7000,7001,7002cluster-node-timeout  5000                //请求超时  设置5秒够了appendonly  yes                           //aof日志开启  有需要就开启,它会每次写操作都记录一条日志

Create 3 nodes at 192.168.1.238: change the corresponding ports to 7003, 7004, 7005. Just change the configuration accordingly.

Start each node on two machines (the two servers are the same)

cd /usr/localredis-server  redis_cluster/7000/redis.conf
redis-server  redis_cluster/7001/redis.conf
redis-server  redis_cluster/7002/redis.conf
redis-server  redis_cluster/7003/redis.conf
redis-server  redis_cluster/7004/redis.conf
redis-server  redis_cluster/7005/redis.conf

View the service

ps -ef | grep redis   #查看是否启动成功
 netstat -tnlp | grep redis #可以看到redis监听端口

The cluster must have 6 nodes

sudo apt-get install ruby
 sudo apt-get install rubygems
 sudo gem install redis
./redis-trib.rb create --replicas 1 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

For more Redis-related technical articles, please visit the Redis Tutorial column to learn!

The above is the detailed content of Installation of redis cluster in ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to start redisNext article:How to start redis

Related articles

See more