个人随笔
目录
当前位置: 首页 Redis Redis环境搭建
Redis环境搭建
2020-07-06 22:33:06

摘要:redis,环境搭建

这篇文章介绍如何搭建redis环境,其实很简单,步骤如下。

环境

CentOS7,redis-6.0.5

一、搭建

我们可以取官网https://redis.io 查看我们需要搭建的版本,这里用的是最新的版本redis-6.0.5。

1、下载redis版本

  1. cd /usr/local
  2. wget http://download.redis.io/releases/redis-6.0.5.tar.gz

2、解压

  1. tar -zxvf redis-6.0.5.tar.gz
  2. mv redis-6.0.5 redis

3、编译

  1. make

报错:make:cc 命令未找到的解决方法
解决:安装相关环境

  1. yum install gcc
  2. yum install gcc-c++

继续执行make编译:

报错:jemalloc/jemalloc.h:没有那个文件或目录
解决:默认用的是 jemalloc分配器,指定libc即可

  1. make MALLOC=libc

继续执行

  1. make install

报错:

  1. server.c:5127:29: 错误:‘struct redisServer’没有名为‘pidfile’的成员

解决:gcc版本老问题,新版本的redis6.0以上,不兼容。
升级版本:

  1. [root@linux7 redis]# gcc -v # 查看gcc版本
  2. [root@linux7 redis]# yum -y install centos-release-scl # 升级到9.1版本
  3. [root@linux7 redis]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
  4. [root@linux7 redis]# scl enable devtoolset-9 bash
  5. 以上为临时启用,如果要长期使用gcc 9.1的话:
  6. [root@linux7 redis]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

继续执行

  1. make install

成功!

4、启动redis

  1. [root@linux6 redis]# cd src/
  2. [root@linux6 src]# ./redis-server
  1. 8867:C 07 Jul 2020 05:12:30.787 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  2. 8867:C 07 Jul 2020 05:12:30.788 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=8867, just started
  3. 8867:C 07 Jul 2020 05:12:30.788 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  4. 8867:M 07 Jul 2020 05:12:30.789 * Increased maximum number of open files to 10032 (it was originally set to 1024).
  5. _._
  6. _.-``__ ''-._
  7. _.-`` `. `_. ''-._ Redis 6.0.5 (00000000/0) 64 bit
  8. .-`` .-```. ```\/ _.,_ ''-._
  9. ( ' , .-` | `, ) Running in standalone mode
  10. |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
  11. | `-._ `._ / _.-' | PID: 8867
  12. `-._ `-._ `-./ _.-' _.-'
  13. |`-._`-._ `-.__.-' _.-'_.-'|
  14. | `-._`-._ _.-'_.-' | http://redis.io
  15. `-._ `-._`-.__.-'_.-' _.-'
  16. |`-._`-._ `-.__.-' _.-'_.-'|
  17. | `-._`-._ _.-'_.-' |
  18. `-._ `-._`-.__.-'_.-' _.-'
  19. `-._ `-.__.-' _.-'
  20. `-._ _.-'
  21. `-.__.-'
  22. 8867:M 07 Jul 2020 05:12:30.789 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
  23. 8867:M 07 Jul 2020 05:12:30.789 # Server initialized
  24. 8867:M 07 Jul 2020 05:12:30.789 # 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.
  25. 8867:M 07 Jul 2020 05:12:30.790 # 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.
  26. 8867:M 07 Jul 2020 05:12:30.790 * Ready to accept connections

出现上图所示,表示启动成功!

5、测试

  1. [root@linux6 src]# ./redis-cli
  2. 127.0.0.1:6379> set name linwenhua
  3. OK
  4. 127.0.0.1:6379> get name
  5. "linwenhua"
  6. 127.0.0.1:6379>

二、总结

上面只是最简单的环境搭建,但是过程中还是遇到了蛮多异常的这篇文章也是为了接下来的集群环境搭建做准备。

 428

啊!这个可能是世界上最丑的留言输入框功能~


当然,也是最丑的留言列表

有疑问发邮件到 : suibibk@qq.com 侵权立删
Copyright : 个人随笔   备案号 : 粤ICP备18099399号-2