centos--redis
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
tar -zxvf redis-4.0.6.tar.gz
tar -zxvf redis-4.0.6.tar.gz
yum安装gcc依赖
yum install gcc
yum install gcc
mv redis-4.0.6 redis
cd redis
make MALLOC=libc
cd src
cd redis
make MALLOC=libc
cd src
make install
修改redis.conf文件
daemonize yes
src下执行
./redis-server ../redis.conf
./redis-server ../redis.conf
kill 进程
./redis-server ../redis.conf
./redis-server ../redis.conf
ps -ef|grep redis
连接不上 修改redis.conf
bind 127.0.0.1修改为bind 0.0.0.0
bind 127.0.0.1修改为bind 0.0.0.0
redis-cli
---集群搭建
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
tar -zxvf redis-4.0.6.tar.gz
yum安装gcc依赖
yum install gcc
yum install gcc
mv redis-4.0.6 redis
cd redis
make MALLOC=libc
cd src
cd redis
make MALLOC=libc
cd src
复制集群所需脚本
cp redis-trib.rb /usr/local/bin
cp redis-trib.rb /usr/local/bin
cd /usr/local/bin;ll
指定文件夹创建redis集群 (我喜欢使用/home)
mkdir redis_cluster
cd redis_cluster/
mkdir 7001 7002 7003 7004 7005 7006
mkdir redis_cluster
cd redis_cluster/
mkdir 7001 7002 7003 7004 7005 7006
复制conf文件至这几个文件夹
cp redis/redis.conf redis_cluster/7001/
cp redis/redis.conf redis_cluster/7001/
修改以下项目
#bind 127.0.0.1 #注释掉,使其他机器也可访问
protected-mode no #关闭保护模式 port 7001 #六个节点配置文件分别是7001-7006
daemonize yes #redis后台运行
pidfile /var/run/redis_7001.pid #pidfile文件对应7001-7006
cluster-enabled yes #开启集群
cluster-config-file nodes_7001.conf #保存节点配置,自动创建,自动更新对应7001-7006
cluster-node-timeout 5000 /#集群超时时间,节点超过这个时间没反应就断定是宕机
#bind 127.0.0.1 #注释掉,使其他机器也可访问
protected-mode no #关闭保护模式 port 7001 #六个节点配置文件分别是7001-7006
daemonize yes #redis后台运行
pidfile /var/run/redis_7001.pid #pidfile文件对应7001-7006
cluster-enabled yes #开启集群
cluster-config-file nodes_7001.conf #保存节点配置,自动创建,自动更新对应7001-7006
cluster-node-timeout 5000 /#集群超时时间,节点超过这个时间没反应就断定是宕机
cp redis_cluster/7001/redis.conf redis_cluster/7002/
cp redis_cluster/7001/redis.conf redis_cluster/7003/
cp redis_cluster/7001/redis.conf redis_cluster/7004/
cp redis_cluster/7001/redis.conf redis_cluster/7005/
cp redis_cluster/7001/redis.conf redis_cluster/7006/
cp redis_cluster/7001/redis.conf redis_cluster/7003/
cp redis_cluster/7001/redis.conf redis_cluster/7004/
cp redis_cluster/7001/redis.conf redis_cluster/7005/
cp redis_cluster/7001/redis.conf redis_cluster/7006/
/usr/local/bin/redis-server redis_cluster/7001/redis.conf
/usr/local/bin/redis-server redis_cluster/7002/redis.conf
/usr/local/bin/redis-server redis_cluster/7003/redis.conf
/usr/local/bin/redis-server redis_cluster/7004/redis.conf
/usr/local/bin/redis-server redis_cluster/7005/redis.conf
/usr/local/bin/redis-server redis_cluster/7006/redis.conf
/usr/local/bin/redis-server redis_cluster/7002/redis.conf
/usr/local/bin/redis-server redis_cluster/7003/redis.conf
/usr/local/bin/redis-server redis_cluster/7004/redis.conf
/usr/local/bin/redis-server redis_cluster/7005/redis.conf
/usr/local/bin/redis-server redis_cluster/7006/redis.conf
ps -ef|grep redis
使用ruby安装集群
yum install ruby
sudo yum install curl
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
curl -L get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm
rvm list known
rvm install 2.3.3
rvm use 2.3.3
rvm remove 2.0.0
gem install redis
yum install ruby
sudo yum install curl
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
curl -L get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm
rvm list known
rvm install 2.3.3
rvm use 2.3.3
rvm remove 2.0.0
gem install redis
ruby redis-trib.rb create --replicas 1 192.168.73.128:7001 192.168.73.128:7002 192.168.73.128:7003 192.168.73.128:7004 192.168.73.128:7005 192.168.73.128:7006