redis5.0.4-测试

本文详细介绍了Redis 5.0.4的下载配置、启动过程以及解决启动时遇到的问题。重点讲解了Redis的主从模式、Sentinel哨兵模式和Cluster集群模式的搭建与测试,包括主从数据同步、Sentinel故障转移和Cluster的高可用特性。此外,还涉及了如何处理启动警告、调整系统参数和应对主节点故障的情况。
摘要由CSDN通过智能技术生成

redis下载配置启动

wget http://download.redis.io/releases/redis-5.0.4.tar.gz
tar zxf redis-5.0.4.tar.gz && mv redis-5.0.4/ /usr/local/redis
[root@docker-registry redis]# ./src/redis-server
84658:C 13 Feb 2020 16:04:11.513 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
84658:C 13 Feb 2020 16:04:11.513 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=84658, just started
84658:C 13 Feb 2020 16:04:11.513 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
84658:M 13 Feb 2020 16:04:11.514 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 84658
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

84658:M 13 Feb 2020 16:04:11.515 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
84658:M 13 Feb 2020 16:04:11.515 # Server initialized
84658:M 13 Feb 2020 16:04:11.515 # 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.
84658:M 13 Feb 2020 16:04:11.515 # 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.
84658:M 13 Feb 2020 16:04:11.515 * DB loaded from disk: 0.000 seconds
84658:M 13 Feb 2020 16:04:11.515 * Ready to accept connections

解决启动时候遇到的三个warning

  1. WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
永久解决

[root@docker-registry redis]# cat /etc/sysctl.conf |grep -v "#"
net.ipv4.ip_forward = 1
net.core.somaxconn= 1024
[root@docker-registry redis]# sysctl -p
net.ipv4.ip_forward = 1
net.core.somaxconn = 1024

2、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.

添加vm.overcommit_memory = 1到/etc/sysctl.conf

[root@docker-registry redis]# sysctl -p
net.ipv4.ip_forward = 1
net.core.somaxconn = 1024
vm.overcommit_memory = 1

3、you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.、

[root@docker-registry redis]# source /etc/rc.local
[root@docker-registry redis]# cat  /etc/rc.local|grep -v "#"

touch /var/lock/subsys/local
echo never > /sys/kernel/mm/transparent_hugepage/enabled

重启redis_server

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

遇到的一些问题

  • 启动redis_server时候ctrl+z[1]+ 已停止 ./src/redis-server,后台进程是存在的,但是本地redis-cli没有连接redis-server成功
[root@docker-registry redis]# ./src/redis-cli -h 127.0.0.1 -p 6379
^C
[root@docker-registry redis]# ps aux|grep redis
root      84658  0.0  0.6 153888  6716 pts/0    Tl   16:04   0:00 ./src/redis-server *:6379

  • 解决方法
解决方法一:开启server后,开辟另一个终端redis-cli即可

解决方法二:修改redis.conf文件将daemonize改
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 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的值。
Redis 5.0.4是一个开源的内存数据库软件,可以用来缓存数据和处理高并发的读写请求。然而,Redis在Windows下的支持相对较弱,因为Redis的开发主要集中在Linux和Unix操作系统上。尽管如此,Redis 5.0.4也可以在Windows上进行安装和使用。 在安装Redis 5.0.4之前,需要满足一些前提条件。首先,需要在Windows上安装合适的C编译器,如MSYS2或Cygwin。此外,还需要安装Redis的依赖库,包括hiredis和libevent。 一种在Windows上安装Redis 5.0.4的方法是通过WSL(Windows Subsystem for Linux)。WSL提供了一个兼容Linux内核的环境,可以在Windows上运行原生的Linux二进制文件。通过在WSL中安装Redis 5.0.4,可以获得更好的稳定性和兼容性。 另一种方法是通过虚拟机,在Windows上安装一个Linux发行版,如Ubuntu或CentOS,并在虚拟机中安装Redis 5.0.4。这种方法可以提供更接近纯Linux环境的性能和功能。 无论选择哪种安装方法,在Windows上使用Redis 5.0.4时需要注意一些事项。首先,由于Windows的文件系统与Unix的文件系统有一些差异,所以在配置Redis的持久化功能时需要留意路径设置。此外,Redis在Windows上的性能可能不如在Linux上那么高效,因为Windows的架构和调度方式与Linux有所不同。 总的来说,Redis 5.0.4可以在Windows上安装和使用,但它对Linux和Unix操作系统的支持更全面。在Windows上使用Redis时,需要注意一些配置和性能方面的问题,并选择适合自己情况的安装方法。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值