服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|数据库技术|

服务器之家 - 数据库 - Redis - Redis 5.05 单独模式安装及配置方法

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

2019-11-28 14:59余-雷 Redis

这篇文章主要介绍了Redis 5.05 单独模式安装,文中通过代码给大家介绍了Redis 5.0.5 单节点 安装配置方法,需要的朋友可以参考下

操作系统Centos7 

1、下载redis 

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

2、启动服务 

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@zk02 redis]# src/redis-server
5265:C 23 Oct 2019 16:58:04.682 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5265:C 23 Oct 2019 16:58:04.682 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=5265, just started
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
5265:M 23 Oct 2019 16:58:04.683 * Increased maximum number of open files to 10032 (it was originally set to 1024).
  _._      
  _.-``__ ''-._     
 _.-`` `. `_. ''-._  Redis 5.0.5 (00000000/0) 64 bit
 .-`` .-```. ```\/ _.,_ ''-._    
 ( ' , .-` | `, ) Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
 | `-._ `._ / _.-' | PID: 5265
 `-._ `-._ `-./ _.-' _.-'    
 |`-._`-._ `-.__.-' _.-'_.-'|    
 | `-._`-._ _.-'_.-' |  http://redis.io
 `-._ `-._`-.__.-'_.-' _.-'    
 |`-._`-._ `-.__.-' _.-'_.-'|    
 | `-._`-._ _.-'_.-' |    
 `-._ `-._`-.__.-'_.-' _.-'    
 `-._ `-.__.-' _.-'    
  `-._ _.-'     
  `-.__.-'     
 
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.
5265:M 23 Oct 2019 16:58:04.684 # Server initialized
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.
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.
5265:M 23 Oct 2019 16:58:04.684 * Ready to accept connections

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

?
1
2
3
4
5
6
[root@zk02 redis]# src/redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
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
2
cd /usr/local/redis-5.0.5
make install

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

Redis配置文件

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

?
1
2
mkdir /etc/redis
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
2
mkdir -p /var/redis-data/
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
2
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload

客户端连接Redis

?
1
redis-cli -h 192.168.43.197 -p 6379 -a xxxx

 

原文链接:https://blog.csdn.net/yulei_qq/article/details/102694798

延伸 · 阅读

精彩推荐
  • Redis详解Redis复制原理

    详解Redis复制原理

    与大多数db一样,Redis也提供了复制机制,以满足故障恢复和负载均衡等需求。复制也是Redis高可用的基础,哨兵和集群都是建立在复制基础上实现高可用的...

    李留广10222021-08-09
  • RedisRedis 事务知识点相关总结

    Redis 事务知识点相关总结

    这篇文章主要介绍了Redis 事务相关总结,帮助大家更好的理解和学习使用Redis,感兴趣的朋友可以了解下...

    AsiaYe8232021-07-28
  • Redisredis 交集、并集、差集的具体使用

    redis 交集、并集、差集的具体使用

    这篇文章主要介绍了redis 交集、并集、差集的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友...

    xiaojin21cen10152021-07-27
  • RedisRedis的配置、启动、操作和关闭方法

    Redis的配置、启动、操作和关闭方法

    今天小编就为大家分享一篇Redis的配置、启动、操作和关闭方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧 ...

    大道化简5312019-11-14
  • RedisRedis全量复制与部分复制示例详解

    Redis全量复制与部分复制示例详解

    这篇文章主要给大家介绍了关于Redis全量复制与部分复制的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用Redis爬虫具有一定的参考学习...

    豆子先生5052019-11-27
  • Redisredis中如何使用lua脚本让你的灵活性提高5个逼格详解

    redis中如何使用lua脚本让你的灵活性提高5个逼格详解

    这篇文章主要给大家介绍了关于redis中如何使用lua脚本让你的灵活性提高5个逼格的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具...

    一线码农5812019-11-18
  • RedisRedis如何实现数据库读写分离详解

    Redis如何实现数据库读写分离详解

    Redis的主从架构,能帮助我们实现读多,写少的情况,下面这篇文章主要给大家介绍了关于Redis如何实现数据库读写分离的相关资料,文中通过示例代码介绍...

    罗兵漂流记6092019-11-11
  • Redisredis实现排行榜功能

    redis实现排行榜功能

    排行榜在很多地方都能使用到,redis的zset可以很方便地用来实现排行榜功能,本文就来简单的介绍一下如何使用,具有一定的参考价值,感兴趣的小伙伴们...

    乘月归5022021-08-05