安装redis-5.0.12

1. 解压安装包

 tar -zxvf redis-5.0.12.tar.gz -C /opt/bdp/redis

解压完 文件里的redis.conf 配置文件很重要

2.编译Redis源文件(需要用工具来编译 提前安装gcc软件包先 yum -y install gcc gcc-c++)

 执行命令 :make MALLOC=libc

    出现这个就代表成功了 Hint: It's a good idea to run 'make test' ;)

3.进入 cd src 目录

  里面有几个重要的脚本 redis-cli 是客户端脚本,redis-server 是服务端脚本,redis-sentinel 是哨兵脚本,redis-trib.rb 是集群脚本

执行 make install 命令 ( 启动成功Hint: It's a good idea to run 'make test' ;)

此时, cd /usr/local/bin ,可以看到多了很多脚本,这是3.X 的特性,会将脚本都放到这

4.修改配置文件 redis.conf

        4.1 修改参数 

         bind 192.168.72.101(自己的ip地址)

      4.2 修改Redis 日志文件夹(指定日志打印位置)

       mkdir /opt/bdp/redis/logs/redis.log(创建日志文件)

        logfile "/opt/bdp/redis/logs/redis.log" (指定文件位置)

     4.3修改数据文件存储(redis 数据存储内存 一旦宕机 保存到磁盘)

         mkdir /opt/bdp/redis/datas(创建存储数据文件夹)

        dbfilename dump.rdb    每隔一段时间,会将数据写到dir 指定的目录

        dir /opt/bdp/redis/datas(指定文件路径) 目录会有rdb文件

5 启动

/usr/local/bin/redis-server 脚本启动命令

ps -ef | grep 6379 查看是否启动成功

 

有可能会报没有关闭保护模式错误

DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside

在开启redis的时候指定redis的配置文件是哪个就好了

/usr/local/bin/redis-server /opt/bdp/redis/redis.conf

6.客户端登录

./redis-cli -h 192.168.200.101 -p 6379 (h  指定ip ,p 指定端口,默认6379)

 6.1客户端和服务段 关闭

 客户端:quit

 服务端:./redis-cli -h 192.168.200.101 -p 6379 shutdown

7 关闭Redis 保护模式

 vi redis.conf 配置文件  把 protected-mode改为 no就行了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
redis安装 1: 下载redis-5.0.4.tar.gz 2: 解压源码并进入目录 tar zxvf redis-5.0.4.tar.gz cd redis-5.0.4 3: 不用configure 4: 直接make (如果是32位机器 make 32bit) 查看linux机器是32位还是64位的方法:file /bin/ls 注:易碰到的问题,时间错误. 原因: 源码是官方configure过的,但官方configure时,生成的文件有时间戳信息, Make只能发生在configure之后, 如果你的虚拟机的时间不对,比如说是2012年 解决: date -s ' yyyy-mm-dd hh:mm:ss ' 重写时间 再 clock -w 写入cmos 5: 可选步骤: make test 测试编译情况 (可能出现: need tcl >8.4这种情况, yum -y install tcl ) 6: 安装到指定的目录,比如 /usr/local/redis make PREFIX=/usr/local/redis install 注: PREFIX要大写 7: 复制配置文件 cp redis.conf /usr/local/redis 注path为解压后的安装包路径 /root/gsj/redis-3.0.6 8: 让redis以后台进程的形式运行 vim /usr/local/redis/redis.conf 编辑redis.conf配置文件,修改如下内容; daemonize yes 9: make install之后,cd /usr/local/redis/bin得到如下几个文件 redis-benchmark 性能测试工具 redis-check-aof 日志文件检测工(比如断电造成日志损坏,可以检测并修复) redis-check-dump 快照文件检测工具,效果类上 redis-cli 客户端 redis-server 服务端 10: 启动与连接 启动redis并指定配置文件 cd /usr/local/redis ./bin/redis-server ./redis.conf #设置随机启动 vim /etc/rc.local 最后添加: /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf 连接: 用redis-cli cd /usr/local/redis/bin/ ./redis-cli #进入 exit /quit #退出 关闭redis pkill redis-server #关闭 ./redis-cli shutdown #关闭 查看是否启动成功 ps -ef | grep redis #查看端口是否占用 netstat -tunpl | grep 6379 11: 测试 String(字符串)类型: set name lijie #设置键name的值为lijie get name #获取name的值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值