系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 数据库 > Redis > 详细页面

Redis 5.05 单独模式安装及配置方法

时间:2019-12-04来源:系统城作者:电脑系统城

操作系统Centos7 

1、下载redis 


 
  1. wget http://download.redis.io/releases/redis-5.0.5.tar.gz
  2. tar xzf redis-5.0.5.tar.gz
  3. cd redis-5.0.5
  4. make

2、启动服务 

命令执行完成之后,既可以启动Redis 服务


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

3、通过内置的客户端与redis 交互


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

日志的打开文件数,可通过如下命令设置

ulimit -n 10032

ps:下面看下Redis 5.0.5 单节点 安装配置

下载

http://download.redis.io/releases/redis-5.0.5.tar.gz

解压

tar -C /usr/local -xvf redis-5.0.5.tar.gz

编译安装


 
  1. cd /usr/local/redis-5.0.5
  2. make install

使用make install 安装,默认安装目录是/usr/local/bin/

Redis配置文件

将示例配置文件拷贝到/etc/redis/639.conf


 
  1. mkdir /etc/redis
  2. cp /usr/local/redis-5.0.5/redis.conf /etc/redis/6379.conf

关闭保护模式

protected-mode no

开放其他主机访问,注释掉bind 127.0.0.1

bind 127.0.0.1

更改为后台启动

daemonize yes

日志记录,需要先创建目录/var/applogs/redis

logfile "/var/applogs/redis/redis.log"

数据存储目录


 
  1. mkdir -p /var/redis-data/
  2. dir /var/redis-data

设置密码

requirepass xxxx

Redis配置开机启动服务

使用Redis自带的启动脚本


 
  1. cp /root/share/deploy-ready/redis-5.0.5/utils/redis_init_script /etc/init.d/redisd

配置开启自启动

chkconfig redisd on

设置开机自启动

chkconfig redisd on

防火墙开发6379端口


 
  1. firewall-cmd --permanent --add-port=6379/tcp
  2. firewall-cmd --reload

客户端连接Redis


 
  1. redis-cli -h 192.168.43.197 -p 6379 -a xxxx
分享到:

相关信息

  • redis分布式ID解决方案示例详解

    常用的分布式ID解决方案 UUID Snowflake Snowflake算法的Java代码: Leaf Leaf算法的Java代码: 基于数据库自增ID生成 基于UUID生成 基于Redis生成 基于ZooKeeper生成...

    2023-03-09

  • Redis并发访问问题详细讲解

    什么场景需要控制并发访问 并发访问的控制方法 1、加入锁机制 2、操作原子化...

    2022-12-06

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载