<!--[if !supportLists]-->l <!--[endif]-->Redis安装
安装包redis-3.0.7.tar.gz
redis启动命令
#/usr/local/redis/redis-server ./redis.conf &
redis停止命令
#/usr/local/redis/redis-cli shutdown或#kill -9 PID
安装步骤
<!--[if !supportLists]-->1. <!--[endif]-->安装gcc
#yum -y install gcc
<!--[if !supportLists]-->2. <!--[endif]-->解压redis-3.0.7.tar.gz后编译
#tar -zxf redis-3.0.7.tar.gz
#cp -r ./redis-3.0.7 /usr/local/redis
# cd /usr/local/redis
#make
<!--[if !supportLists]-->3. <!--[endif]-->开放iptables6379端口
蛋疼的在这里,注意:安装集群要再开通一个在上一端口上+10000的端口,这个是redis的集群总线端口,否则redis集群无法互通
重启服务
#service iptables restart
<!--[if !supportLists]-->4. <!--[endif]-->启动redis服务
<!--[if !supportLists]-->5. <!--[endif]-->用客户端测试一下是否启动成功
<!--[if !supportLists]-->6. <!--[endif]-->设置开机自启动,将redis启动项目追加入rc.local保证redis在服务器开机时启动
#
<!--[if !supportLists]-->l <!--[endif]-->Redis集群
<!--[if !supportLists]-->1. <!--[endif]-->安装zlib
#tar -xvzf zlib-1.2.8.tar.gz
#cd zlib-1.2.8
#./configure
#make
#sudo make install
<!--[if !supportLists]-->2. <!--[endif]-->安装Ruby
# sudo yum install ruby
这里自动安装的是1.8版本的,要重新安装2.3版本的
# yum install ruby-rdoc
# tar –zxvf ruby-2.3.0.tar.gz
# cd ruby-2.3.0
# su
# ./configure –prefix=/usr/local/ruby-2.3.0
# make (这里等待较长)
# make install
# cp /usr/local/ruby-2.3.0/bin/* /usr/local/bin
应用2.3版本的执行文件,ruby –v可以查看版本
<!--[if !supportLists]-->3. <!--[endif]-->安装rubygems
#tar –zxf rubygems-2.6.1.gz
#cd rubygems-2.6.1
#sudo ruby setup.rb
# gem install -l /33e9/tools/redis-3.2.2.gem
这个要安装,不然会报kernel_require.rb:55:in `require': cannot load such file – redis错误
<!--[if !supportLists]-->4. <!--[endif]-->修改配置文件redis.conf
#vi /usr/local/redis/redis.conf
##修改配置文件中的下面选项
daemonize yes
port 6379
stop-writes-on-bgsave-error no
appendonly yes
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 5000
<!--[if !supportLists]-->5. <!--[endif]-->启动集群
# ./src/redis-trib.rb create --replicas 1 10.0.7.154:7000 10.0.7.154:7001 10.0.7.155:7002 10.0.7.155:7003 10.0.7.156:7004 10.0.7.156:7005
(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
使用如下命令解决:
config set stop-writes-on-bgsave-error no