zoukankan      html  css  js  c++  java
  • Redis安装与常用命令

    一、安装

    1.上传 redis-4.0.2.tar.gz到Redis服务器的/usr/local/src目录下

    2.解压Redis基础安装包,然后进入解压后的目录,指以定安装位置的方式安装Redis,命令如下:
      # cd /usr/local/src
      # tar -zxvf redis-4.0.2.tar.gz
      # cd redis-4.0.2
      # make
      # make install PREFIX=/usr/local/redis

    3.创建/usr/local/redis/conf目录和/usr/local/redis/log
      # mkdir /usr/local/redis/conf
      # mkdir /usr/local/redis/log

    4.上传redis.conf文件到/usr/local/redis/conf目录,主要修改配置文件中的几项内容如下:
      bind 0.0.0.0 #绑定ip,只有通过此ip才能访问redis服务,修改为本机ip
      port 6379 #修改为规划端口
      pidfile /usr/local/redis/conf/redis_6379.pid #进程id文件地址,6379改为规划端口
      logfile "/usr/local/redis/log/redis_6379.log" #日志文件地址,6379改为规划端口
      dbfilename dump_6379.rdb #rdb文件名称,6379改为规划端口
      dir /usr/local/redis/conf #redis默认路径,修改为配置文件所在路径
      requirepass foobared #连接redis密码,如需启用密码,先取消注释,再修改为规划的redis服务密码
      appendfilename "appendonly_6379.aof" #aof文件名称,6379改为规划端口

    5.集群环境还需修改以下配置
      cluster-enabled yes #修改为yes开启集群模式
      cluster-config-file nodes_6379.conf #集群节点配置文件名称,6379修改为规划端口
      cluster-node-timeout 15000 #集群检测超时时间,修改为15000,即15秒

    二、常用命令

    1、进入redis:redis-cli -h IP地址 -p 端口 ,如:redis-cli -h 127.0.0.1 -p 6381
    结果展示:127.0.0.1:6381>

    2、查看slowlog总条数:SLOWLOG LEN ,如:127.0.0.1:6381> slowlog len
    结果展示:
    (integer) 4

    3、查看slowlog:SLOWLOG GET ,如:127.0.0.1:6381> slowlog get
    结果展示:
    1) 1) (integer) 26 // slowlog唯一编号id
    2) (integer) 1440057815 // 命令执行时的时间戳,代表本条命令的执行时间
    3) (integer) 47 // 命令执行耗时(微妙),代表本条命令查询耗时47微秒
    4) 1) "SLOWLOG" // 执行的命令,完整命令为 SLOWLOG GET,slowlog最多保存前面的31个key和128字符
    2) "GET"

    4、查看集群节点的情况:cluster nodes ,如:cluster nodes

    5、停用redis节点:redis-cli -p Redis端口号 shutdown

    6、启用redis节点:redis-server 节点配置文件路径

    7、启用redis集群:src/redis-trib.rb create --replicas 1 172.16.4.132:6380 172.16.4.132:6381 172.16.4.133:6380 172.16.4.133:6381 172.16.4.134:6380 172.16.4.134:6381 172.16.4.135:6380 172.16.4.135:6381

    JAVA_OPTS="-Xms32m -Xmx128m -Xss32K -XX:PermSize=16m -XX:MaxPermSize=64m"

    附:tcpdump -s0 -i eth0 -w /opt/testDump.cap 抓eth0网卡的所有包命令

  • 相关阅读:
    jQuery基础【1】
    qTip2 精致的jQuery提示信息插件
    jquery tools 系列(三)——scrollable(2)
    JQuery常用函数及功能小结
    【转】JQ命令汇总 jQuery
    jquery tools系列(一)——tabs(选项卡/页签)
    jquery tools系列(四)——overlay
    肚子
    今天买了部数码相机NiKon S510
    《文渊阁四库全书》书目
  • 原文地址:https://www.cnblogs.com/chen/p/11242849.html
Copyright © 2011-2022 走看看