1、Redis下载
官网地址:
下载地址:
2、Redis安装
Redis是C语言开发,建议在Linux系统上运行,本教程使用Centos6.8作为安装环境。
①在VMware中搭建Linux服务器集群
准备三台虚拟机
192.168.1.100
192.168.1.101
192.168.1.102
在每个虚拟机上部署两个redis
192.168.1.100:6378
192.168.1.100:6379
192.168.1.101:6378
192.168.1.101:6379
192.168.1.102:6378
192.168.1.102:6379
②在Linux中安装Redis的依赖环境
make MALLOC=libc && make install
yum -y install gcc
yum -y install gcc-c++
yum -y install ruby
yum -y install rubygem*
yum -y install ruby-rdoc
yum -y install ruby-devel rubygems rpm-build
gem install redis
③将下载的Redis源码包上传到Linux服务器
sftp>put -r "your own path"
④解压缩Redis源码包
tar -zxvf redis-3.0.0.tar.gz
⑤编译redis源码
cd redis-3.0.0
make
⑥安装Redis
make install PREFIX=/usr/local/redis
⑦配置Redis环境变量
vim /etc/profile
export REDIS_HOME=/usr/local/redis
export PATH=$PATH:$REDIS_HOME/bin
⑧修改Redis配置文件
vim redis.conf
port 6378
cluster-enabled yes
cluster-config-file nodes-6378.conf
cluster-node-timeout 5000
appendonly yes
⑨复制一份Redis目录到当前目录下,并修改redis.conf
vim redis.conf
port 6379
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 5000
appendonly yes
⑩分发Redis目录
分发到其他机器两份,做主从(master and slave)
3、Redis启动
①分别在3台Linux虚拟机中启动6台Redis服务
./redis-server
②运行Redis集群
./redis-trib.rb
create --replicas
1
192.168.1.100:6378
192.168.1.100:6379
192.168.1.101:6378
192.168.1.101:6379
192.168.1.102:6378
192.168.1.102:6379