Redis {REmote DIctionary Server} 高性能数据库

  • 1. What is Redis?
    • 1.1. 基于内存的数据存储
  • 2. Install Redis on Linux
  • 3. Starting and stopping Redis in the background
    • 3.1. `systemctl`
    • 3.2. `service `
  • 4. Connect to Redis
  • 5. 退出 Redis 的命令行界面 (redis-cli)
  • 6. redis-server 统计信息
  • References

Redis (REmote DIctionary Server)
https://redis.io/

1. What is Redis?

Redis (REmote DIctionary Server) is an open source, in-memory, NoSQL key/value store that is used primarily as an application cache or quick-response database.
Redis (REmote DIctionary Server) 是一个开源的内存数据库,遵守 BSD 协议,它提供了一个高性能的键值 (key-value) 存储系统,常用于缓存、消息队列、会话存储等应用场景。Redis 是一个开源的使用 ANSI C 语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value 数据库,并提供多种语言的 API。

Redis stores data in memory, rather than on a disk or solid-state drive (SSD), which helps deliver unparalleled speed, reliability, and performance.
Redis 将数据存储在内存中,而不是磁盘或固态硬盘 (SSD) 上,这有助于提供无与伦比的速度、可靠性和性能。

Redis 将数据存储在内存中,以提供快速的读写访问速度,并且能够通过异步的方式将数据持久化到磁盘上。

1.1. 基于内存的数据存储

Redis 是一个内存中的数据结构存储系统,意味着它使用计算机的主内存 (RAM) 来存储所有的数据。这种内存优先的设计使得 Redis 能够提供极高的性能,因为内存的数据访问速度远远超过了传统硬盘存储。

由于存储在内存中,Redis 能够以微秒级别的延迟对数据进行读写操作,这对于需要快速响应的应用来说至关重要,如缓存系统、实时分析平台和高频交易系统等。然而,内存资源相对有限且价格较高,因此 Redis 也提供了数据驱动的逐出策略和精细的内存管理功能,确保有效利用可用内存。

2. Install Redis on Linux

https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/

sudo apt update
sudo apt install redis-server

Note there are redis-server and redis packages in the Ubuntu repository. Both will install the same software, so you can use either and have the same outcome.

(base) yongqiang@yongqiang:~$ sudo apt update
(base) yongqiang@yongqiang:~$ sudo apt install redis-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:libfwupdplugin1 libxmlb1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:libhiredis0.14 libjemalloc2 liblua5.1-0 lua-bitop lua-cjson redis-tools
Suggested packages:ruby-redis
The following NEW packages will be installed:libhiredis0.14 libjemalloc2 liblua5.1-0 lua-bitop lua-cjson redis-server redis-tools
0 upgraded, 7 newly installed, 0 to remove and 327 not upgraded.
Need to get 915 kB of archives.
After this operation, 4077 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
...

3. Starting and stopping Redis in the background

3.1. systemctl

You can start the Redis server as a background process using the systemctl command. This only applies to Ubuntu/Debian when installed using apt, and Red Hat/Rocky when installed using yum.

sudo systemctl start <redis-service-name> # redis or redis-server depending on platform

To stop the server, use:

sudo systemctl stop <redis-service-name> # redis or redis-server depending on platform

适用于 Linux 的 Windows 子系统 (WSL) 默认不启用 systemd,因此 sudo systemctl start redis-server 可能无效。

3.2. service

‌通过服务命令启动,并查看服务状态。

(base) yongqiang@yongqiang:~$ sudo service redis-server start
Starting redis-server: redis-server.
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ sudo service redis-server status* redis-server is running
(base) yongqiang@yongqiang:~$

‌通过服务命令关闭,并查看服务状态。

(base) yongqiang@yongqiang:~$ sudo service redis-server stop
Stopping redis-server: redis-server.
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ sudo service redis-server status* redis-server is not running
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ sudo service redis-server status* redis-server is running
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ ps aux | grep redis
redis      882  0.1  0.1  60924  6272 ?        Ssl  21:58   0:01 /usr/bin/redis-server 127.0.0.1:6379
yongqia+   897  0.0  0.0   8172  2304 pts/0    S+   22:08   0:00 grep --color=auto redis
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ redis-cli --version
redis-cli 5.0.7
(base) yongqiang@yongqiang:~$ sudo service redis-server stop
Stopping redis-server: redis-server.
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ ps aux | grep redis
yongqia+   910  0.0  0.0   8172  2432 pts/0    S+   22:11   0:00 grep --color=auto redis
(base) yongqiang@yongqiang:~$

4. Connect to Redis

Check the Redis command-line client version by entering the following to ensure it is configured properly:

redis-cli --version
(base) yongqiang@yongqiang:~$ redis-cli --version
redis-cli 5.0.7
(base) yongqiang@yongqiang:~$

Once Redis is running, you can test it by running redis-cli:

redis-cli

Test the connection with the ping command:

127.0.0.1:6379> ping
PONG
(base) yongqiang@yongqiang:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

5. 退出 Redis 的命令行界面 (redis-cli)

使用 exit 命令:

(base) yongqiang@yongqiang:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
(base) yongqiang@yongqiang:~$

使用 quit 命令:

(base) yongqiang@yongqiang:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> quit
(base) yongqiang@yongqiang:~$

6. redis-server 统计信息

(base) yongqiang@yongqiang:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> INFO
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:66bd629f924ac924
redis_mode:standalone
os:Linux 6.6.87.2-microsoft-standard-WSL2 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.3.0
process_id:939
run_id:036b682fce7ef9126ec09d7b6210f7df004ff9f0
tcp_port:6379
uptime_in_seconds:57
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:10352588
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf# Clients
connected_clients:1
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0# Memory
used_memory:859360
used_memory_human:839.22K
used_memory_rss:5902336
used_memory_rss_human:5.63M
used_memory_peak:859360
used_memory_peak_human:839.22K
used_memory_peak_perc:100.12%
used_memory_overhead:845926
used_memory_startup:796232
used_memory_dataset:13434
used_memory_dataset_perc:21.28%
allocator_allocated:1575864
allocator_active:1880064
allocator_resident:10461184
total_system_memory:4029890560
total_system_memory_human:3.75G
used_memory_lua:41984
used_memory_lua_human:41.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.19
allocator_frag_bytes:304200
allocator_rss_ratio:5.56
allocator_rss_bytes:8581120
rss_overhead_ratio:0.56
rss_overhead_bytes:-4558848
mem_fragmentation_ratio:7.22
mem_fragmentation_bytes:5084984
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:49694
mem_aof_buffer:0
mem_allocator:jemalloc-5.2.1
active_defrag_running:0
lazyfree_pending_objects:0# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1755182995
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0# Stats
total_connections_received:1
total_commands_processed:2
instantaneous_ops_per_sec:0
total_net_input_bytes:45
total_net_output_bytes:11475
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0# Replication
role:master
connected_slaves:0
master_replid:23df661e5962e2a8c907cb36e19637d3d74662a2
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0# CPU
used_cpu_sys:0.073876
used_cpu_user:0.052958
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000# Cluster
cluster_enabled:0# Keyspace
127.0.0.1:6379> exit
(base) yongqiang@yongqiang:~$

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] What is Redis? https://www.ibm.com/think/topics/redis

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/918780.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/918780.shtml
英文地址,请注明出处:http://en.pswp.cn/news/918780.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL中的DML(二)

DML(Data Manipulation Language) : 数据库操作语言&#xff0c;对数据库中表的数据进行增删改操作。 创建student表&#xff1a; CREATE DATABASE test; use test; CREATE TABLE student (id int,name varchar(255),address varchar(255),city varchar(255) );INSERT INTO stu…

linux 主机驱动(SPI)与外设驱动分离的设计思想

一、 主机驱动与外设驱动分离Linux中的SPI、I2c、USB等子系统都利用了典型的把主机驱动和外设驱动分离的想法&#xff0c;让主机端负责产生总线上的传输波形&#xff0c;而外设端只是通过标准的API来让主机端以适当的波形访问自身。因此这里涉及了4个软件模块&#xff1…

如何生成.patch?

文章目录 ​​方法 1:使用 `git format-patch`(推荐)​ ​​步骤​​ ​方法 2:使用 `diff`命令(适用于非 Git 项目)​ ​​方法 3:使用 `git diff`(生成未提交的变更)​ ​方法 4:使用 `quilt`(适用于大量补丁管理) ​如何提交补丁给上游项目?​ ​总结​​ 在 L…

【计算机网络 | 第6篇】计算机体系结构与参考模型

文章目录计算机体系结构与参考模型分层思想&#x1f342;常见的3种模型&#xff08;网络体系结构&#xff09;&#x1f426;‍&#x1f525;TCP/IP体系结构各层包含的主要协议&#x1f95d;每层所解决的主要问题&#x1f914;层次间的交互规则&#x1f95d;实体与对等实体协议服…

Autoware Universe 感知模块详解 | 第一节 感性认识多源传感器标定

传感器与感知模块 在基于规则的自动驾驶系统中&#xff0c;感知模块&#xff0c;承担着理解车体周围环境信息的重要职责。它通过融合多种传感器数据&#xff0c;与定位模块共同为规划与控制模块提供准确、系统化的输入信息。正如人可以通过眼睛观察周围的环境&#xff08;盲人也…

docker搭建java运行环境(java或者springboot)

目录1. 创建测试代码2. 编译打包3. 代码环境运行使用普通运行方式使用docker挂载项目&#xff08;长期运行&#xff09;1. 创建 Dockerfile2. 构建并后台运行使用docker swram实现零停机更新&#xff08;推荐&#xff09;1. 初始化swarm2. 创建 Dockerfile3. 使用Dockerfile 构…

哈希表特性与unordered_map/unordered_set实现分析

目录 一、哈希表核心特性总结 1.开放地址法 2.链地址法 二、unordered_map/unordered_set实现要点分析 1. 哈希表核心实现(HashTable2.h) (1) 哈希函数处理 (2) 链地址法实现 (3) 迭代器设计 (4) hashtable设计 2. unordered_map实现要点 3. unordered_map实现要点 一…

生产环境sudo配置详细指南

目录 1. 语法格式 2. 配置示例 3. 使用 /etc/sudoers.d/ 目录管理&#xff08;推荐&#xff09; 4. 基础配置&#xff1a;用户权限管理 4.1 ​​添加用户到sudo组 ​​4.2 验证用户组信息 5. sudo日志配置 5.1 修改sudoers配置文件 5.2 创建日志目录与权限设置 6. Su…

CSS动态视口单位:彻底解决移动端适配顽疾,告别布局跳动

你是否曾被这些问题困扰&#xff1a; 移动端页面滚动时&#xff0c;地址栏收缩导致页面高度突变&#xff0c;元素错位&#xff1f;100vh在移动设备上实际高度超出可视区域&#xff1f;全屏弹窗底部总被浏览器UI遮挡&#xff1f; 这些痛点背后都是传统视口单位的局限——无法响应…

【P27 4-8】OpenCV Python——Mat类、深拷贝(clone、copyTo、copy)、浅拷贝,原理讲解与示例代码

P27 4-8 1 Mat结构体2 深拷贝VS浅拷贝3 代码示例1 Mat结构体 2 深拷贝VS浅拷贝 只拷贝了头部&#xff0c;header&#xff0c;&#xff0c;但是data部分是共用的&#xff0c;速度非常快&#xff1b; 缺点&#xff0c;任意一个修改&#xff0c;另一个data跟着变&#xff0c;这就是…

容器运行时支持GPU,并使用1panel安装ollama

前言 安装Docker请看之前博文&#xff1a;Docker实战中1panel方式安装Docker。 安装 NVIDIA 容器工具包 https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html 安装 先决条件 阅读有关平台支持的部分。为您的 Linux 发行版安装…

高并发内存池 性能瓶颈分析与基数树优化(9)

文章目录前言一、性能瓶颈分析操作步骤及其环境配置分析性能瓶颈二、基数树优化单层基数树二层基数树三层基数树三、使用基数树来优化代码总结前言 到了最后一篇喽&#xff0c;嘻嘻&#xff01;   终于是要告一段落了&#xff0c;接下来我们将学什么呢&#xff0c;再说吧&…

C#面试题及详细答案120道(01-10)-- 基础语法与数据类型

《前后端面试题》专栏集合了前后端各个知识模块的面试题&#xff0c;包括html&#xff0c;javascript&#xff0c;css&#xff0c;vue&#xff0c;react&#xff0c;java&#xff0c;Openlayers&#xff0c;leaflet&#xff0c;cesium&#xff0c;mapboxGL&#xff0c;threejs&…

机器翻译:回译与低资源优化详解

文章目录一、机器翻译的瓶颈二、回译&#xff08;Back-Translation&#xff09;2.1 什么是回译&#xff1f;2.2 为什么回译有效&#xff1f;2.3 回译的缺点与挑战三、低资源优化详解3.1 数据层面策略3.2 模型层面策略3.3 架构层面策略四、回译与低资源优化对比4.1 回译与低资源…

leetcode-python-344反转字符串

题目&#xff1a; 编写一个函数&#xff0c;其作用是将输入的字符串反转过来。输入字符串以字符数组 s 的形式给出。 不要给另外的数组分配额外的空间&#xff0c;你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 示例 1&#xff1a; 输入&#xff1a;s [“h”,“…

【Python】新手入门:什么是python字符编码?python标识符?什么是pyhon保留字?

🌈 个人主页:(时光煮雨) 🔥 高质量专栏:vulnhub靶机渗透测试 👈 希望得到您的订阅和支持~ 💡 创作高质量博文(平均质量分95+),分享更多关于网络安全、Python领域的优质内容!(希望得到您的关注~) 🌵文章目录🌵 前言 💡一、编码 📝二、标识符 🎯三、Py…

为什么要使用消息队列呢?

消息队列&#xff08;Message Queue&#xff0c;MQ&#xff09;在分布式系统中扮演着 ​异步通信枢纽​ 的角色&#xff0c;其核心价值在于解决系统间的解耦、流量削峰、异步处理等关键问题。以下是它的核心价值及典型应用场景&#xff1a;⚙️ 一、核心价值&#xff1a;解决什…

ROS机器人云实践案例博客建议和范文-AI版本

海报图AI图1AI图2zhangrelay的博客以技术深度、跨界思考和社会洞察为特色&#xff0c;内容兼具实用性与前瞻性&#xff0c;但部分观点存在争议&#xff0c;需结合具体主题辩证看待。以下从内容特色、技术深度、社会洞察、争议点四个维度展开分析&#xff1a;一、内容特色&#…

UE小:编辑器模式下「窗口/鼠标不在焦点」时仍保持高帧率

要在UE编辑器模式下「窗口/鼠标不在焦点」时仍保持高帧率&#xff0c;可按下面做法&#xff1a; 关闭编辑器的后台降频选项&#xff1a;在 Edit -> Editor Preferences -> General -> Performance 中取消勾选 “Use Less CPU when in Background”。

VS2022 + Qt 5.15.2+Occ开发环境搭建流程

Visual Studio 2022 Qt 5.15.2 图形处理开发环境搭建流程 1. 安装 Visual Studio 2022 下载安装程序&#xff1a;Visual Studio 官网选择工作负载&#xff1a; ✔️ “使用C的桌面开发”✔️ “通用Windows平台开发”&#xff08;可选&#xff09; 安装组件&#xff1a; ✔️…