Redis安装

这节讲一下Linux环境下Redis的安装

下载安装包

下载安装包redis-3.2.9.tar.gz, 官网地址:http://www.redis.cn/download.html

依赖软件安装

注意:如果大家的Linux系统上已经安装了gcc和tcl,这一步请忽略

安装这个的目的是为了后面执行make命令,没有安装的话,下一步骤会报错

yum -y install gcc tcl -y

开始编译

make && make install

成功编译后,Redis会在/usr/local/bin下面生成Redis的操作命令,另外这一步也直接把redis加入了环境变量中(看第三张截图)

下面第一张图是编译过程中的日志,画圈处就表明了redis命令的存放目录

第二张图是具体的命令

启动Redis服务器

这里为了给大家展示环境变量的效果,我专门切换了目录,在/opt下面运行的命令

注意:直接敲redis-server命令,加载的是redis目录下默认的配置,配置文件:redis.conf

[root@test2 redis-3.2.9]# cd ../
[root@test2 opt]# redis-server 
4564:C 08 Aug 21:16:40.755 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
4564:M 08 Aug 21:16:40.756 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 4564
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4564:M 08 Aug 21:16:40.756 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4564:M 08 Aug 21:16:40.756 # Server started, Redis version 3.2.9
4564:M 08 Aug 21:16:40.756 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
4564:M 08 Aug 21:16:40.756 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
4564:M 08 Aug 21:16:40.756 * The server is now ready to accept connections on port 6379

检测redis服务,命令:netstat -anpt

使用默认配置和使用redis.conf配置,端口信息是不一样的

用本机客户端测试redis服务

在另外一台服务器上访问Redis服务

1.把usr/local/bin目录下的redis-cli文件命令拷贝到主机名为 test3 这台服务器的相同目录下

2.配置redis目录下的redis.conf文件,修改服务地址,由原来的127.0.0.1改为192.168.159.12

具体操作请看下列截图

复制文件到test3上

原来的redis.conf配置

加入地址192.168.159.12

在test3服务器上就可以访问test2(IP为192.168.159.12)的redis服务啦

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是一名程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值