Redis Cli工具

Redis have two main usage types. One is using API provided by redis these API’s can be used by different programming languages like Python, Php C#, Java etc. Other way to interact with redis is using cli tool named redis cli. Redis cli provides simple command line interface to test, use, troubleshot redis service.

Redis有两种主要的用法类型。 一种是使用redis提供的API,这些API可以被不同的编程语言使用,例如Python,Php C#,Java等。与redis进行交互的另一种方法是使用名为redis cli的cli工具。 Redis cli提供了简单的命令行界面来测试,使用,排除故障redis服务。

指定IP地址 (Specify IP Address)

redis-cli will connect localhost or 127.0.0.1 IP address by default. We can also specify the IP address we want to connect explicitly with -h option. In this example we will connect IP address 192.168.122.11

redis-cli默认会连接localhost或127.0.0.1 IP地址。 我们还可以使用-h选项指定要显式连接的IP地址。 在此示例中,我们将连接IP地址192.168.122.11

$ redis-cli -h 192.168.122.11

指定端口 (Specify Port)

redis-cli will connect TCP port 6379 by default. If the redis server is listening different than 6379 we can specify the port number explicitly with -p option. In this example we will connect to port number 7000 .

默认情况下,redis-cli将连接TCP端口6379。 如果redis服务器侦听的不是6379,则可以使用-p选项显式指定端口号。 在此示例中,我们将连接到端口号7000。

$ redis-cli -h 192.168.122.11 -p 7000

指定密码 (Specify Password)

Redis server have some security measures to protect against attackers. Password is one of them . If we set a password for the redis we should provide it with -a option while connecting. In this example we will use sosecret as password.

Redis服务器有一些安全措施可以防止攻击者。 密码就是其中之一。 如果我们为redis设置了密码,则在连接时应为它提供-a选项。 在此示例中,我们将使用sosecret作为密码。

$ redis-cli -a "sosecret"

与PING核对 (Check with PING)

redis-cli provides a health check functionality named PING . We can use PING like below. It will simply return PONG if everything is OK.

redis-cli提供了名为PING的运行状况检查功能。 我们可以像下面这样使用PING。 如果一切正常,它将仅返回PONG。

$ redis-cli PING
Check with PING
Check with PING
与PING核对

互动模式(Interactive Mode)

redis-cli provides interactive mode where we get a redis shell after connected to the redis server. This shell provides all commands batch mode have. We can write redis commands and get information with interactive mode in real time. In order to start interactive shell mode we will simply connect to the redis server and do not provide any command. But if needed we should provides options like host, port or password information.

redis-cli提供了交互模式,在该模式下,连接到redis服务器后我们将获得一个redis shell。 这个shell提供了批处理模式下所有的命令。 我们可以编写redis命令并以交互方式实时获取信息。 为了启动交互式shell模式,我们将简单地连接到redis服务器,并且不提供任何命令。 但是,如果需要,我们应该提供主机,端口或密码信息之类的选项。

$ redis-cli
Interactive Mode
Interactive Mode
互动模式

批处理模式(Batch Mode)

Batch mode is alternative to the interactive mode. In batch mode we will provide the commands we want to run to the redis-cli directly. This commands output will be printed to the current operating system shell like bash, ms dos etc. We should provide the command we want to run after options. In this example we will list redis help in batch mode. We should also provide the hostname, port and password options if needed.

批处理模式可以替代交互模式。 在批处理模式下,我们将直接提供要运行到redis-cli的命令。 此命令输出将被打印到当前的操作系统外壳,如bash,ms dos等。我们应该在选项后提供要运行的命令。 在此示例中,我们将以批处理模式列出redis帮助。 如果需要,我们还应该提供主机名,端口和密码选项。

$ redis-cli help

Batch Mode
Batch Mode
批处理模式
LEARN MORE  Install Redis To Linux, Ubuntu, Debian ,Fedora, CentOS, RedHat
了解更多信息将Redis安装到Linux,Ubuntu,Debian,Fedora,CentOS,RedHat

翻译自: https://www.poftut.com/redis-cli-tool/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值