Redis是一个开源(采用BSD许可证),用作数据库、缓存、消息代理和流处理引擎的内存数据结构存储系统。
Redis提供诸如字符串[1]、哈希[2]、列表[3]、集合[4]、带有范围查询的有序集合[5]、位图[6]、HyperLogLogs[7]、地理空间索引[8]和流[9]等数据结构[10]。Redis内置了复制、Lua脚本、LRU驱逐、事务和不同级别的磁盘持久性,并通过Redis Sentinel[11]实现了高可用性,通过Redis Cluster[12]实现了自动分区。
在 CentOS 系统上通过源码安装 Redis,你可以按照以下步骤进行:
确保你的系统已经安装了编译工具和一些必要的依赖项,包括 GCC、Make 和 tcl。
$ sudo yum install gcc make tcl你可以从 Redis 的官方网站下载最新版本的源代码:https://redis.io/download
$ wget hhttps://github.com/redis/redis/archive/7.2.4.tar.gz解压下载的 Redis 源码包。
$ tar xzf redis-7.2.4.tar.gz
$ cd redis-7.2.4执行 make 命令编译 Redis;编译完成后,执行 make install 命令安装 Redis。
$ make
$ sudo make installRedis 的配置文件位于安装目录下的 redis.conf 文件中。你可以根据需要修改配置文件,设置监听端口、持久化选项、日志等。
$ sudo cp redis.conf /etc/redis.conf修改配置文件:
# 后台运行
daemonize yes
# 关闭保护模式
protected-mode no
# 解除本地访问限制,默认绑定的地址只能本机访问,注释或修改为指定IP地址
# bind 127.0.0.1
# 配置访问密码
requirepass foobared你可以通过以下命令启动 Redis 服务器。
$ sudo /usr/local/bin/redis-server /etc/redis.conf可以通过 redis-cli 连接 Redis 服务:
# 因为配置了密码,本地访问可以使用以下命令
$ redis-cli -a foobared声明:本作品采用署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)[13]进行许可,使用时请注明出处。 Author: mengbin[14] blog: mengbin[15] Github: mengbin92[16] cnblogs: 恋水无意[17] 腾讯云开发者社区:孟斯特[18]
[1] 字符串: https://redis.io/docs/data-types/strings/
[2] 哈希: https://redis.io/docs/data-types/hashes/
[3] 列表: https://redis.io/docs/data-types/lists/
[4] 集合: https://redis.io/docs/data-types/sets/
[5] 有序集合: https://redis.io/docs/data-types/sorted-sets/
[6] 位图: https://redis.io/docs/data-types/bitmaps/
[7] HyperLogLogs: https://redis.io/docs/data-types/hyperloglogs/
[8] 地理空间索引: https://redis.io/docs/data-types/geospatial/
[9] 流: https://redis.io/docs/data-types/streams/
[10] 数据结构: https://redis.io/docs/data-types/
[11] Redis Sentinel: https://redis.io/topics/sentinel
[12] Redis Cluster: https://redis.io/topics/cluster-tutorial
[13] 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0): https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh
[14] mengbin: mengbin1992@outlook.com
[15] mengbin: https://mengbin.top
[16] mengbin92: https://mengbin92.github.io/
[17] 恋水无意: https://www.cnblogs.com/lianshuiwuyi/
[18] 孟斯特: https://cloud.tencent.com/developer/user/6649301