redis 安装和使用

 

参考官网: https://redis.io/

 

下载:redis-6.2.3.tar.gz


// 解压
tar -xvzf redis-6.2.3.tar.gz

// 编译
cd redis
make

// 运行
cd src
./redis-server
[root@mapbox src]# ./redis-server
6857:C 22 May 2021 17:26:07.232 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6857:C 22 May 2021 17:26:07.233 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=6857, just started
6857:C 22 May 2021 17:26:07.233 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
6857:M 22 May 2021 17:26:07.234 * Increased maximum number of open files to 10032 (it was originally set to 1024).
6857:M 22 May 2021 17:26:07.234 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6857
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

6857:M 22 May 2021 17:26:07.235 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
6857:M 22 May 2021 17:26:07.235 # Server initialized
6857:M 22 May 2021 17:26:07.235 # 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.
6857:M 22 May 2021 17:26:07.236 * Ready to accept connections

 

### Redis 安装使用教程 #### 什么是 RedisRedis 是一种高性能的键值存储系统,全称为 Remote Dictionary Server (远程字典服务器)[^1]。它支持多种数据结构,如字符串、哈希、列表、集合等。 #### Redis 的许可与商标 Redis 开发者 Salvatore Sanfilippo 的工作由 Redis Labs 资助[^2]。Redis 遵循三条款 BSD 许可协议发布,并且其商标标志归属于 Redis Labs Ltd 所有。 #### 如何重启 Redis 服务? 如果需要重新启动 Redis 服务,可以执行以下命令来完成操作: ```bash sudo service redis-server restart ``` 此命令适用于基于 Debian 或 Ubuntu 的 Linux 发行版[^3]。 #### Redis 安装指南 以下是 Redis 的快速安装方法之一(以 Ubuntu 系统为例),具体步骤如下所示: 1. 更新包管理器索引文件: ```bash sudo apt update ``` 2. 安装 Redis 服务器及相关工具: ```bash sudo apt install redis-server ``` 3. 启动 Redis 服务并设置开机自启: ```bash sudo systemctl start redis.service sudo systemctl enable redis.service ``` 更多关于 Redis 安装的信息可以从官方文档或其他资源获取更多信息[^4]。 #### 基本使用示例 下面是一个简单的 Python 示例程序,展示如何通过 `redis-py` 库连接到 Redis 并进行基本的操作: ```python import redis # 创建 Redis 连接对象 r = redis.Redis(host='localhost', port=6379, decode_responses=True) # 设置键值对 r.set('name', 'Alice') # 获取键对应的值 value = r.get('name') print(f"The value of key 'name' is {value}") ``` 上述代码展示了如何利用 Python 中的 `redis-py` 库实现与本地 Redis 实例交互的功能。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值