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

Installation of redis cluster in ubuntu

步履不停
Release: 2019-07-02 16:38:36
Original
2204 people have browsed it

Installation of redis cluster in ubuntu

First check whether gcc is installed

gcc -v
Copy after login

If gcc is not installed, you need to install it

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

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
Copy after login

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/
Copy after login

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日志开启  有需要就开启,它会每次写操作都记录一条日志
Copy after login

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
Copy after login

View the service

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

The cluster must have 6 nodes

sudo apt-get install ruby
 sudo apt-get install rubygems
 sudo gem install redis
Copy after login
./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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template