当前位置: 首页 > news >正文

Ubuntu - Redis 安装、远程访问


参考教程:

https://blog.csdn.net/houor/article/details/126672577

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


查看是否安装

redis-cli --version

Ubuntu 上安装

更新:

sudo apt update 
sudo apt upgrade 

sudo apt install redis-server


查看状态

systemctl status redis.service 

$ systemctl status redis.service 
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor pres>
     Active: activating (start) since Sun 2025-02-23 10:49:45 UTC; 1min 14s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
    Process: 211377 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exi>
      Tasks: 0 (limit: 154141)
     Memory: 484.0K
     CGroup: /system.slice/redis-server.service

Feb 23 10:49:45 gitlab-server systemd[1]: Starting Advanced key-value store...
Feb 23 10:49:45 gitlab-server systemd[1]: redis-server.service: Can't open PID file>

macOS 上安装

brew install redis 

查看运行状态

brew services info redis

%brew services info redis  
redis (homebrew.mxcl.redis)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: pc087
PID: 66794

运行

brew services start redis 

停止

brew services stop redis

配置Redis远程设置

sudo nano /etc/redis/redis.conf   

修改配置信息 :

# 注释掉绑定地址#bind 127.0.0.1,让Redis可远程访问
# bind 127.0.0.1 ::1
bind 0.0.0.0

#取消注释requirepass 启动密码认证,并设置访问密码
requirepass your-pass-word

# 以守护进程运行Redis 
daemonize yes


开放端口:

sudo ufw allow 6379

配置完成后,保存并关闭文件。然后重启Redis:

systemctl restart redis-server

验证输入的是本机密码

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'redis-server.service'.
Authenticating as: xx
Password: 
==== AUTHENTICATION COMPLETE ===

Job for redis-server.service failed because a timeout was exceeded.
See "systemctl status redis-server.service" and "journalctl -xe" for details

临时解决方法:重启系统


查看状态:

systemctl status redis-server.service

停止 redis 服务

查看状态

sudo systemctl status redis

停止服务

sudo systemctl stop redis

禁用服务(可选)

sudo systemctl disable redis

再次检查端口占用

sudo netstat -tuln | grep 6379

相关文章:

  • 图书馆系统源码详解
  • 萌新学 Python 之自定义函数
  • Unity技术突破
  • Leetcode 3463. Check If Digits Are Equal in String After Operations II
  • 2025版-Github账号注册详细过程
  • 【C语言】第八期——指针
  • UE_C++ —— Logging in Unreal
  • 初识XML
  • LeetCode 热题 100 206. 反转链表
  • ASP.NET Core Clean Architecture
  • 如何选择适合自己电脑的本地部署模型,模型的大小与b之间的关系,模型参数,量化Q
  • 嵌入式之内存管理
  • 【Git】多人协作
  • 【c++】【线程池】线程池模式
  • Python常见面试题的详解16
  • DeepSeek掘金——基于DeepSeek-R1构建文档问答机器人
  • C 语言文件操作
  • Seata1.5.2学习(二)——使用分布式事务锁@GlobalLock
  • 微信小程序 - 页面跳转(wx.navigateTo、wx.redirectTo、wx.switchTab、wx.reLaunch)
  • Python--函数入门
  • 台州网站制作台州网站建设/windows优化软件哪个好
  • 页游网站如何做推广/如何推销自己的产品
  • 织梦网站环境搭建/北京网站seo优化推广
  • 至尊传奇手游官方正版下载/娄底seo
  • 河南省建设厅网站136号文件/百度霸屏推广一般多少钱
  • 三明住房建设局网站/竞价推广托管公司价格