redis安装

来源:互联网 发布:mac版导入铃声 编辑:程序博客网 时间:2024/06/08 19:28

1.系统环境VirtualBox-4.3.6-91406-Win+CentOS-6.8-x86_64-bin-DVD1.iso

  【请安装DVD版本的 CD版本的操作无法保存】,

   参照 http://www.2cto.com/os/201407/318477.html

   如果无法上网:/etc/sysconfig/network-scripts/ifcfg-eth0  修改ONBOOT=YES

   然后 service network restart

2.opt目录创建redis目录,下载redis源码包 http://download.redis.io/releases/redis-3.2.8.tar.gz

   tar xzf redis-3.2.8.tar.gz 
   cd redis-3.2.8

   make【make失败提示没有gcc 和 cc 则yum install gcc则可以】

   make MALLOC=libc  【newer version of jemalloc required 报错则使用这个命令】

   make install PREFIX=/opt/redis/redis-cluster 

   

 在bin 目录下增加redis.conf文件配置如下 参照 http://blog.csdn.net/neubuffer/article/details/17003909

    daemonize yes #后台启动

    port 7001 #修改端口号,从7001到7006

    appendonly yes

    loglevel notice #日志级别

    logfile "/usr/redis/log/redis.log" #日志路径

    requirepass myRedis  #连接密码

3.如果需要在window主机上连接需要关闭centos防火墙,而且虚拟机的使用桥接模式网络

 

1) 临时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
 
2) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off

4.window客户端测试

  redis-cli.exe -h *.*.*.1 -p 7001 -a myRedis 


5.redis-benchmark测试redis的性能。

  参照: http://files.cnblogs.com/files/threestone/redis-benchmark.zip

          http://www.cnblogs.com/threestone/p/5423171.html

           https://my.oschina.net/hanruikai/blog/313724


6.redis主从配置   http://www.cnblogs.com/liuling/p/2014-4-19-02.html

   1.主redis配置

       daemonize yes
       port 7001
       appendonly yes
        loglevel notice
        logfile "/opt/redis/redis-cluster/log/redis01.log"
       requirepass


   2.从redis配置

       daemonize yes

       port 7002

      appendonly yes
      loglevel notice
      logfile "/opt/redis/redis-cluster/log/redis02.log"
      requirepass 密码
      slaveof IP 端口
     masterauth 密码

 客户端使用info命令查看


7.安装redis集群

  yum install ruby

  yum install rubygems 
  本机下载安装gem-redis    https://rubygems.org/downloads/redis-3.3.3.gem

 https://rubygems.org/gems/redis/versions/3.3.3


 ./redis-trib.rb create --replicas 1 *.*.*.*:7001 *.*.*.*:7002 [此处的IP最好不要用127.0.0.1 用局域网IP或者公网IP],否则客户端无法redirect


方式二:进入各个实例进行设置:
./redis-cli -c -p 7000
config set masterauth passwd123
config set requirepass passwd123
config rewrite

设置密码后,redis-trib.rb check 192.168.0.107:6379  

设置密码后,redis-trib.rb check 192.168.0.107:6379  报错连接不上实例,解决方法:

vim /usr/lib/ruby/gems/1.8/gems/redis-3.3.0/lib/redis/client.rb

修改密码  :password => "gh*8pass",


1.如果是使用redis-trib.rb工具构建集群,集群构建完成前不要配置密码,集群构建完毕再通过config set + config rewrite命令逐个机器设置密码

2.如果对集群设置密码,那么requirepass和masterauth都需要设置,否则发生主从切换时,就会遇到授权问题,可以模拟并观察日志

3.各个节点的密码都必须一致,否则Redirected就会失败

参照 http://www.bubuko.com/infodetail-1672054.html



redis集群报错Node is not empty

删除rdb和aof文件和nodes.conf文件
参照http://blog.51yip.com/nosql/1735.html



redis客户端

http://blog.csdn.net/liubenlong007/article/details/53766734


redis监控

zabbix作为主要的监控数据收集工具。




参照: http://blog.csdn.net/fengshizty/article/details/51368004

         http://www.cnblogs.com/java-zhao/p/6134337.html


        高端: http://www.cnblogs.com/thrillerz/p/5604752.html


       高端问题: http://blog.csdn.net/chenleixing/article/details/50530419







0 0
原创粉丝点击