redis安装


tar -xvf redis-4.0.2.tar.gz 
ln -s redis-4.0.2 redis   #软连接有利于以后升级
cd redis
make
make install


2. 查看redis的版本
redis-cli -v
redis-cli 4.0.2

3. 启动redis
三种方法:默认配置,运行配置启动, 配置文件启动。

[root@CentOS-Zabbix redis]# redis-server 
43885:C 16 Nov 12:11:02.766 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
43885:C 16 Nov 12:11:02.766 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=43885, just started
43885:C 16 Nov 12:11:02.766 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
43885:M 16 Nov 12:11:02.766 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
          _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._          Redis 4.0.2 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
(    '      ,      .-`  | `,    )    Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|    Port: 6379
|    `-._  `._    /    _.-'    |      PID: 43885
  `-._    `-._  `-./  _.-'    _.-'                                  
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |          http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                  
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              

43885:M 16 Nov 12:11:02.769 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
43885:M 16 Nov 12:11:02.769 # Server initialized
43885:M 16 Nov 12:11:02.769 # 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.
43885:M 16 Nov 12:11:02.769 # 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.
43885:M 16 Nov 12:11:02.769 * Ready to accept connections


4. 运行启动
redis-server --port 6380  加上端口参数

5.配置文件启动:
redis-server redis.conf 
vim /usr/local/redis/etc/redis.conf
将daemonize的值改为yes ,后台启动

6.命令行客户端:
[root@CentOS-Zabbix redis]# redis-cli -h 127.0.0.1 -p 6380
127.0.0.1:6380> set hello world
OK
127.0.0.1:6380> get hello
"world"

[root@CentOS-Zabbix redis]# redis-cli -h 127.0.0.1 -p 6380 get hello
"world"

7. 停止服务 (端口默认,以及在主机执行可省略-h和-p参数)
[root@CentOS-Zabbix redis]# redis-cli -h 127.0.0.1 -p 6380 shutdown
44004:M 16 Nov 12:21:37.927 # User requested shutdown...
44004:M 16 Nov 12:21:37.927 # Redis is now ready to exit, bye bye...
[1]+  完成                  redis-server --port 6380

8. 注意:
1. redis关闭:要断开与客户端的链接,持久文件生成。
2.不要kill -9,不但不会持久化操作,还会造成缓冲区等资源不能优雅关闭,极端情况还会造成数据丢失。
3.shudown nosave/save : 代表关闭之前,生成持久化文件


9.安装错误整理
[root@demo-8 redis]# make
cd src && make all
make[1]: Entering directory `/tools/redis-4.0.2/src'
    CC Makefile.dep
make[1]: Leaving directory `/tools/redis-4.0.2/src'
make[1]: Entering directory `/tools/redis-4.0.2/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数。解决办法:make时添加参数。
make MALLOC=libc

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值