Ubuntu上安装Redis的详细教程

1、安装redis

首先,访问Redis官网,点击首页的【Get Started】,然后点击Install Redis on Linux

安装

终端依次输入以下命令,如果过程中没有错误提示,则redis安装完成。

sudo apt install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis

执行过程

ubuntu@ip-172-0-0-00:~$
ubuntu@ip-172-0-0-00:~$ sudo apt install lsb-release curl gpg
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
lsb-release is already the newest version (12.0-2).
curl is already the newest version (8.5.0-2ubuntu10.2).
gpg is already the newest version (2.4.4-2ubuntu17).
gpg set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
ubuntu@ip-172-0-0-00:~$
ubuntu@ip-172-0-0-00:~$ curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
ubuntu@ip-172-0-0-00:~$
ubuntu@ip-172-0-0-00:~$ echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb noble main
ubuntu@ip-172-0-0-00:~$
ubuntu@ip-172-0-0-00:~$ sudo apt-get update
Hit:1 https://mirrors.aliyun.com/docker-ce/linux/ubuntu noble InRelease
Hit:2 http://cn-north-1.ec2.archive.ubuntu.com/ubuntu noble InRelease
Get:3 http://cn-north-1.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:5 http://cn-north-1.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease
Get:6 https://packages.redis.io/deb noble InRelease [3854 B]
Get:7 https://packages.redis.io/deb noble/main amd64 Packages [1645 B]
Get:8 https://packages.redis.io/deb noble/main all Packages [747 B]
Ign:9 https://download.docker.com/linux/ubuntu focal InRelease
Ign:9 https://download.docker.com/linux/ubuntu focal InRelease
Ign:9 https://download.docker.com/linux/ubuntu focal InRelease
Err:9 https://download.docker.com/linux/ubuntu focal InReleaseCannot initiate the connection to download.docker.com:443 (2a03:2880:f131:83:face:b00c:0:25de). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (67.228.235.93), connection timed out
Fetched 132 kB in 37s (3549 B/s)
Reading package lists... Done
W: https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/InRelease  Cannot initiate the connection to download.docker.com:443 (2a03:2880:f131:83:face:b00c:0:25de). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (67.228.235.93), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
ubuntu@ip-172-0-0-00:~$
ubuntu@ip-172-0-0-00:~$ sudo apt-get install redis
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:redis-server redis-tools
Suggested packages:ruby-redis
The following NEW packages will be installed:redis redis-server redis-tools
0 upgraded, 3 newly installed, 0 to remove and 5 not upgraded.
Need to get 1633 kB of archives.
After this operation, 9595 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://packages.redis.io/deb noble/main amd64 redis-tools amd64 6:7.4.0-1rl1~noble1 [1554 kB]
Get:2 https://packages.redis.io/deb noble/main amd64 redis-server amd64 6:7.4.0-1rl1~noble1 [63.9 kB]
Get:3 https://packages.redis.io/deb noble/main amd64 redis all 6:7.4.0-1rl1~noble1 [15.3 kB]
Fetched 1633 kB in 3s (520 kB/s)
Selecting previously unselected package redis-tools.
(Reading database ... 98676 files and directories currently installed.)
Preparing to unpack .../redis-tools_6%3a7.4.0-1rl1~noble1_amd64.deb ...
Unpacking redis-tools (6:7.4.0-1rl1~noble1) ...
Selecting previously unselected package redis-server.
Preparing to unpack .../redis-server_6%3a7.4.0-1rl1~noble1_amd64.deb ...
Unpacking redis-server (6:7.4.0-1rl1~noble1) ...
Selecting previously unselected package redis.
Preparing to unpack .../redis_6%3a7.4.0-1rl1~noble1_all.deb ...
Unpacking redis (6:7.4.0-1rl1~noble1) ...
Setting up redis-tools (6:7.4.0-1rl1~noble1) ...
Setting up redis-server (6:7.4.0-1rl1~noble1) ...
Setting up redis (6:7.4.0-1rl1~noble1) ...
Processing triggers for man-db (2.12.0-4build2) ...
Scanning processes...
Scanning candidates...
Scanning linux images...Pending kernel upgrade!
Running kernel version:6.8.0-1010-aws
Diagnostics:The currently running kernel version is not the expected kernel version 6.8.0-1013-aws.Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.Restarting services...Service restarts being deferred:/etc/needrestart/restart.d/dbus.servicesystemctl restart networkd-dispatcher.servicesystemctl restart systemd-logind.servicesystemctl restart unattended-upgrades.serviceNo containers need to be restarted.No user sessions are running outdated binaries.No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-0-0-00:~$

2、修改配置

允许外网端访问

redis的配置文件在/etc/redis/redis.conf,打开这个文件

sudo vim /etc/redis/redis.conf
#注释下面内容
bind 127.0.0.1 -::1#添加
bind 0.0.0.0修改为no
protected-mode no

增加密码

 3、相关命令

启动方式一
/etc/init.d/redis-server start
启动方式二
systemctl start redis-server
启动方式三
service redis-server start
重启
service redis-server restart
关闭
service redis-server stop
查看状态
service redis-server status

操作记录

ubuntu@ip-172-0-0-00:/etc$ sudo /etc/init.d/redis-server start
Starting redis-server (via systemctl): redis-server.service.
ubuntu@ip-172-0-0-00:/etc$
ubuntu@ip-172-0-0-00:/etc$ service redis-server status
● redis-server.service - Advanced key-value storeLoaded: loaded (/usr/lib/systemd/system/redis-server.service; disabled; preset: enabled)Active: active (running) since Tue 2024-08-13 11:46:55 UTC; 15min agoDocs: http://redis.io/documentation,man:redis-server(1)Main PID: 503818 (redis-server)Status: "Ready to accept connections"Tasks: 6 (limit: 18951)Memory: 3.5M (peak: 4.1M)CPU: 2.882sCGroup: /system.slice/redis-server.service└─503818 "/usr/bin/redis-server 127.0.0.1:6379"Aug 13 11:46:55 ip-172-0-0-00 systemd[1]: Starting redis-server.service - Advanced key-value store...
Aug 13 11:46:55 ip-172-0-0-00 systemd[1]: Started redis-server.service - Advanced key-value store.
ubuntu@ip-172-0-0-00:/etc$

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

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

相关文章

计算机科学速成课笔记

计算机速成课个人理解概要 1.计算机的本质 计算机的本质:极其简单的组件,经过一层层复杂的抽象,做出复杂的工作 2.控制电流的技术发展 继电器→真空管→晶体管 拥有了细微控制电流的手段 tip:早期机械计算机,被虫子(bug)卡住…

基于SpringCloud的能源管理系统-能源管理平台源码-能源在线监测平台-双碳平台源码-SpringCloud全家桶-能管管理系统源码

介绍 适用于高能耗企业、建筑、工厂、园区的水、电、气、热、油、空压机等能源数据采集、分析、报表; 基于SpringCloud的能源管理系统-能源管理平台源码-能源在线监测平台-双碳平台源码-SpringCloud全家桶-能管管理系统源码 软件架构 软件功能 数字大屏 使用说明

机器学习第十一章-特征选择与稀疏学习

11.1子集收集与评价 属性称为"特征" ,对当前学习任务有用的属性称为"相关特征" 、没什么用的属性称为"无关特 征" . 从给定的特征集合中选择出相关特征于集的过程,称为"特征选择"。 特征选择是一个重要的"…

Linux | Linux进程万字全解:内核原理、进程状态转换、优先级调度策略与环境变量

目录 1、从计算机组成原理到冯诺依曼架构 计算机系统的组成 冯诺依曼体系 思考:为什么计算机不能直接设计为 输入设备-CPU运算-输出设备 的结构? 2、操作系统(Operator System) 概念 设计OS的目的 描述和组织被管理对象 3、进程 基本概念 进程id和父进程…

数据结构入门——07堆

1.堆 堆(Heap)是一种特殊的完全二叉树数据结构,具有以下两个主要特性: 结构特性: 堆是一棵完全二叉树,即除了最后一层的叶子节点外,每一层都是满的,最后一层的叶子节点从左向右依次…

志愿服务管理系统--论文pf

TOC springboot360志愿服务管理系统--论文pf 第1章 绪论 1.1选题动因 当前的网络技术,软件技术等都具备成熟的理论基础,市场上也出现各种技术开发的软件,这些软件都被用于各个领域,包括生活和工作的领域。随着电脑和笔记本的广…

[SWPUCTF 2021 新生赛]babyrce

我们传cookie admin1 访问http://node5.anna.nssctf.cn:29911/rasalghul.php 在PHP中,preg_match函数是一个用于进行正则表达式匹配的内置函数。它可以通过正则表达式对一个字符串进行匹配,判断该字符串是否满足正则表达式的规则。 发现过滤空格&#x…

xss之DOM破坏

文章目录 DOM破坏漏洞的复现https://xss.pwnfunction.com/基于bp学院DOM破坏漏洞复现思路分析实现 常见的xss触发的标签没有过滤的情况存在过滤的情况 DOM破坏 DOM破坏就是⼀种将 HTML 代码注⼊⻚⾯中以操纵 DOM 并最终更改⻚⾯上 JavaScript ⾏为的技术。 在⽆法直接 XSS的情…

牛客JS题(四十五)数组去重

注释很详细&#xff0c;直接上代码 涉及知识点&#xff1a; set的灵活用法去除的判别标准 题干&#xff1a; 我的答案 <!DOCTYPE html> <html><head><meta charset"UTF-8" /><style>/* 填写样式 */</style></head><bo…

【Docker】Docker Compose(容器编排)

一、什么是 Docker Compose docker-compose 是 Docker 官方的开源项目&#xff0c;使用 python 编写&#xff0c;实现上调用了 Docker 服务的 API 进行容器管理及编排&#xff0c;其官方定义为定义和运行多个 Docker 容器的应用。 docker-compose 中有两个非常重要的概念&…

趣映 v2.3.8 高级版 剪映替代品 解锁会员功能

看到名字&#xff0c;想必很多网友会联想到剪映&#xff0c;没错&#xff0c;趣映也是一款类似剪映的视频编辑工具。趣映为用户提供了全面的视频编辑和制作&#xff0c;更专注于动画视频制作的软件。功能齐全&#xff0c;操作简单&#xff0c;可以帮助用户从灵感创作到成片输出…

MYSQL----表的创建

1.创建表 create table 表名&#xff08; field1 datetype, field2 datetype, field3 datetype &#xff09; 1.field字段名&#xff0c;也就是属性&#xff0c;相当于java类里面的成员属性 2.datetype 数据类型 3.最后一个字段的定义&#xff0c;结束没有逗号 4.字段的定义在…

【学习总结】JVM篇

JVM JVM基础知识 主力机型 HotSpot VM HotSpot虚拟机时OpenJDK和OracleJDK中默认的Java虚拟机。它最初并非由Sun公司所开发&#xff0c;而是由一家名为“Longview Technologies”的小公司设计。Sun公司注意到这款虚拟机在即时编译等多个方面有着优秀的理念和实际成果&#…

解决问题:Arcgis10.8“数据“-“导出至CAD“时就卡死了

问题现象&#xff1a;我们在使用Arcgis10.8软件&#xff0c;执行 “数据导出至CAD”操作时&#xff0c;会出现卡死的情况&#xff0c;步骤如下图所示&#xff1a; 解决方案&#xff1a;在菜单栏依次选择“地理处理”-“地理处理选项”&#xff0c;然后在“后台处理”和“发生错…

金价多次尝试刷新最高纪录,美国零售销售数据是绊马索

金价一直在试探新高&#xff0c;该纪录为每盎司2,485美元。而且&#xff0c;强劲的美国零售销售报告正在阻止金价的上涨。 由于强大的阻力&#xff0c;金价无法继续上涨。一周的净空头头寸大增。 发布了强于预期的美国零售销售报告后&#xff0c;金价承受了压力。期望的50个基…

递归--数据结构--黑马

递归 总结一句话&#xff0c;上手直接多刷Leetcode&#xff0c;比看这个更有用。 定义 递归是一种解决计算问题的方法&#xff0c;其中解决方案取决于同一类问题的更小子集。 例如&#xff0c;单链表递归遍历的例子&#xff1a; void f(Node node) {if (node null) {retu…

Ubuntu18.04 配置EtherCAT主站IGH SOEM

IGH IGH 是开源的EtherCAT 主站软件 一、安装依赖 sudo apt update sudo apt install build-essential linux-headers-$(uname -r) mercurial autoconf libtool 也不知道安装的完全不完全 uname -r 可以查看内核&#xff0c;我安装的ubuntu18.04的内核版本是 5.4.0-84-gen…

Koa商城项目-轮播图模块(后端)

前言 通过这次独自做前后端发现有很多需要提升的地方&#xff0c;很多细节处理不到位。下面简单看一下本人自己做的效果吧~~ Git地址 https://gitee.com/ah-ah-bao/koa_system 效果图 后端逻辑分析 首先编写route->banner.router.js /*** author: zxb* date: 2024-08-06…

k8s 部署polardb-x集群

前言 体验了基于源码构建的部署polardb-x 单机部署&#xff0c;当然也想体验性能更好的完全分布式集群。这边文章将重点介绍如何部署polardb-x集群 简介 PolarDB-X 是一款面向超高并发、海量存储、复杂查询场景设计的云原生分布式数据库系统。其采用 Shared-nothing 与存储计…

二叉树详解(1)

文章目录 目录1. 树的概念及结构1.1 树的相关概念1.2 树的表示1.3 树在实际中的运用&#xff08;表示文件系统的目录树结构&#xff09; 2. 二叉树的概念及结构2.1 概念2.2 特殊的二叉树2.3 二叉树的存储结构 3. 二叉树的顺序结构及实现3.1 二叉树的顺序结构3.2 堆的概念及结构…