2025年redis-cli 端口(redis端口6379)

redis-cli 端口(redis端口6379)div class hide article box text center div linux 下 yum 安装 redis 以及使用 1 yum install redis nbsp nbsp nbsp nbsp nbsp 查看是否有 redis nbsp amp

大家好,我是讯享网,很高兴认识大家。




讯享网

<div class="hide-article-box text-center"> </div> linux下yum安装redis以及使用 

讯享网


1、yum install redis&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; –查看是否有redis&nbsp;&nbsp; yum 源

[root@localhost ~]# yum install redis
已加载插件:fastestmirror
base | 3.6 kB 00:00
docker-ce-edge | 2.9 kB 00:00
docker-ce-stable | 2.9 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
extras/7/x86_64/primary_db | 145 kB 00:00
Loading mirror speeds from cached hostfile
* base: mirrors.sohu.com
* extras: mirrors.sohu.com
* updates: mirrors.sohu.com
没有可用软件包 redis。
错误:无须任何处理

2、yum install epel-release&nbsp;&nbsp;&nbsp; –下载fedora的epel仓库

[root@localhost ~]# yum install epel-release
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.sohu.com
* extras: mirrors.sohu.com
* updates: mirrors.sohu.com
正在解决依赖关系
–&gt; 正在检查事务
—&gt; 软件包 epel-release.noarch.0.7-9 将被 安装
–&gt; 解决依赖关系完成

依赖关系解决

=====================================================================
Package 架构 版本 源 大小
=====================================================================
正在安装:
epel-release noarch 7-9 extras 14 k

事务概要
=====================================================================
安装 1 软件包

总下载量:14 k
安装大小:24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-9.noarch.rpm | 14 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : epel-release-7-9.noarch 11
验证中 : epel-release-7-9.noarch 11

已安装:
epel-release.noarch 0:7-9

完毕!



3、yum install redis&nbsp;&nbsp;&nbsp; – 安装redis数据库

[root@localhost ~]# yum install redis
已加载插件:fastestmirror
epel/x86_64/metalink | 7.9 kB 00:00
epel | 4.7 kB 00:00
(13): epel/x86_64/updateinfo | 857 kB 00:00
(23): epel/x86_64/group_gz | 266 kB 00:01
(33): epel/x86_64/primary_db | 6.1 MB 00:05
Loading mirror speeds from cached hostfile
* base: mirrors.sohu.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.sohu.com
* updates: mirrors.sohu.com
正在解决依赖关系
–&gt; 正在检查事务
—&gt; 软件包 redis.x86_64.0.3.2.10-2.el7 将被 安装
–&gt; 正在处理依赖关系 libjemalloc.so.1()(64bit),它被软件包 redis-3.2.10-2.el7.x86_64 需要
–&gt; 正在检查事务
—&gt; 软件包 jemalloc.x86_64.0.3.6.0-1.el7 将被 安装
–&gt; 解决依赖关系完成

依赖关系解决

=====================================================================
Package 架构 版本 源 大小
=====================================================================
正在安装:
redis x86_64 3.2.10-2.el7 epel 545 k
为依赖而安装:
jemalloc x86_64 3.6.0-1.el7 epel 105 k

事务概要
=====================================================================
安装 1 软件包 (+1 依赖软件包)

总下载量:650 k
安装大小:1.7 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/jemalloc-3.6.0-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
jemalloc-3.6.0-1.el7.x86_64.rpm 的公钥尚未安装
(12): jemalloc-3.6.0-1.el7.x86_64.rpm | 105 kB 00:00
(22): redis-3.2.10-2.el7.x86_64.rpm | 545 kB 00:01
———————————————————————
总计 385 kB/s | 650 kB 00:01
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
用户ID : “Fedora EPEL (7) &lt;&gt;”
指纹 : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
软件包 : epel-release-7-9.noarch (@extras)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : jemalloc-3.6.0-1.el7.x86_64 12
正在安装 : redis-3.2.10-2.el7.x86_64 22
验证中 : redis-3.2.10-2.el7.x86_64 12
验证中 : jemalloc-3.6.0-1.el7.x86_64 22

已安装:
redis.x86_64 0:3.2.10-2.el7

作为依赖被安装:
jemalloc.x86_64 0:3.6.0-1.el7

完毕!

4、service redis start&nbsp;
 &nbsp; systemctl start redis.service&nbsp;&nbsp; –开启redis服务
 &nbsp; redis-server /etc/redis.conf&nbsp;&nbsp; –开启方式二
[root@localhost ~]# service redis start
Redirecting to /bin/systemctl start redis.service


5、ps -ef | grep redis&nbsp;&nbsp; – 查看redis是否开启
[root@localhost ~]# systemctl start redis.service
[root@localhost ~]# ps -ef|grep redis
redis&nbsp;&nbsp;&nbsp;&nbsp; 5024&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; 0 07:58 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5054&nbsp; 4497&nbsp; 0 08:00 pts/0&nbsp;&nbsp;&nbsp; 00:00:00 grep –color=auto redis


6、redis-cli&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; – 进入redis服务
复制代码
[root@localhost ~]# redis-cli
127.0.0.1:6379&gt; ?
redis-cli 3.2.10
To get help about Redis commands type:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “help @&lt;group&gt;” to get a list of commands in &lt;group&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “help &lt;command&gt;” for help on &lt;command&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “help &lt;tab&gt;” to get a list of possible help topics
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “quit” to exit

To set redis-cli perferences:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “:set hints” enable online hints
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “:set nohints” disable online hints
Set your preferences in ~/.redisclirc
127.0.0.1:6379&gt; get
(error) ERR wrong number of arguments for ‘get’ command
127.0.0.1:6379&gt; get key
(nil)
127.0.0.1:6379&gt; get key abc
(error) ERR wrong number of arguments for ‘get’ command
127.0.0.1:6379&gt; set key abc
OK
127.0.0.1:6379&gt; get key abc
(error) ERR wrong number of arguments for ‘get’ command
127.0.0.1:6379&gt; get key
“abc”
127.0.0.1:6379&gt;



7、redis-cli&nbsp; shutdown&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; –关闭服务
复制代码
[root@localhost ~]# redis-cli
127.0.0.1:6379&gt; shutdown
not connected&gt;
not connected&gt;
[root@localhost ~]# ps -ef |grep redis
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5127&nbsp; 4497&nbsp; 0 08:34 pts/0&nbsp;&nbsp;&nbsp; 00:00:00 grep –color=auto redis
[root@localhost ~]# systemctl start redis.service
[root@localhost ~]# ps -ef |grep redis
redis&nbsp;&nbsp;&nbsp;&nbsp; 5134&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; 0 08:34 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5138&nbsp; 4497&nbsp; 0 08:35 pts/0&nbsp;&nbsp;&nbsp; 00:00:00 grep –color=auto redis
[root@localhost ~]#



8、开放端口6379、6380的防火墙
/sbin/iptables -I INPUT -p tcp –dport 6379&nbsp; -j ACCEPT&nbsp;&nbsp; 开启6379
/sbin/iptables -I INPUT -p tcp –dport 6380 -j ACCEPT&nbsp; 开启6380
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp –dport 6379 -j ACCEPT
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp –dport 6380 -j ACCEPT
9、使用redis&nbsp; desktop manager连接redis

小讯
上一篇 2025-06-13 18:47
下一篇 2025-04-28 14:41

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/207400.html