环境篇之 redis 的 linux 和 Windows 测试|学习笔记

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: 快速学习环境篇之 redis 的 linux 和 Windows 测试

开发者学堂课程【大数据 Flink 实时旅游平台环境篇 2020版:环境篇之 redis 的linux 和 Windows 测试】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址https://developer.aliyun.com/learning/course/643/detail/10705


环境篇之 redis 的 linux 和 Windows 测试

内容介绍:

一、做配置文件

二、开机自启动

三、启动测试


一、做配置文件

vi ./redis

先来做一个启动的配置文件,可以直接启动,此处讲解做一个配置文件

内容如下,可以直接复制

#!/bin/bash

#chkconfig: 2345 80 90

# Simple Redis init.d script conceived to work on Linux systems

# as it does use of the /proc filesystem.

PATH=/usr / local/bin:/sbin :/usr/bin:/bin

REDISPORT=6379

EXEC=/usr /local/redis-4.0.11/bin/redis-server

REDIS_CLI=/usr /local /redis-4.0.11/bin/redis-cli

PIDFILE=/var/run/redis.pid

CONF="/usr /local/redis-4.0.11/etc/redis.conf"

case "$1" in

start)

if [ -f $PIDFILE ]

then

echo "SPIDFILE exists,process is already running or crashed"

else

echo “Starting Redis server...”

$EXEC $CONF

fi

if [“$?”=”0”]

then

echo “Redis is running”

fi

;;

stop)

if [ ! -f $PIDFILE]

then

echo”$PIDFILE does not exist,process is not running ”

else

PID=$(cat $PIDFILE)

echo “Stopping...”

$REDIS_CLI -p $REDISPORT SHUTDOWN

while [-x ${PIDFILE}]

do

echo “Waiting for Redis to shutdown...”

done

echo “Redis stopped”

fi

restart|force-reload)

${0} stop

${0} start

;;

echo “Usage:  

/etc/init.d/redis {start|stop|restart|force-reload}” >&2

exit 1

esac

二、开机自启动

之后需要设置开机自启动:

#复制脚本文件到 init.d 目录下

cp redis /etc/init.d/

#给脚本增加运行权限

chmod +x /etc/init.d/redis

#查看服务列表

chkconfig --list

#添加服务

chkconfig --add redis

#配置启动级别

chkconfig --level 2345 redis on

三、启动测试

再来进行启动测试:

Linux 端测试

systemctl start redis#或者

/etc/init.d/redis start[root@hadoop01 redis-4.0.11]# systemct1 stop redis#或者/etc/init.d/redis stop

启动之后可以输入以下查看 redis 进程:

ps -ef l grep redis

结果可以看到默认端口6379

也可以使用 netstat 查看端口是否启动,如下:

netstat -an | grep 6379

完成后进行客户端连接测试:输入

redis-cli -h hadoop01

进入后输入 auth root 为 OK

输入keys 密码

设置值输入set r1 redis1

再输入get r1

结果显示”redis1”代表测试成功

再来输入 ping 会自动返回一个 PONG

Windows 端

在本机中打开软件 redis-desktop-manager-0.8.0.3841.exe

进行安装,Destination Folder 为

D:\installed\RedisDesktopManger

安装到桌面后点击软件,如图

image.png

点击 Connect to Redis Server

输入name为hadoop-redis

Host 为192.168.216.111

Auth 为 root

然后点击测试 Test Connection,显示成功连接点击 OK

之后点击 hadoop-redis 可以看到默认是16个库

image.png

点击 db0,点击 r1 右侧就会显示 value 值:redis1

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
相关文章
|
12天前
|
安全 Linux iOS开发
Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
73 0
Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
|
12天前
|
安全 Linux 生物认证
Nexpose 8.18.0 for Linux & Windows - 漏洞扫描
Nexpose 8.18.0 for Linux & Windows - 漏洞扫描
26 0
Nexpose 8.18.0 for Linux & Windows - 漏洞扫描
|
14天前
|
安全 Linux iOS开发
SonarQube Server 2025 Release 4.2 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
SonarQube Server 2025 Release 4.2 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
56 0
SonarQube Server 2025 Release 4.2 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
|
16天前
|
NoSQL IDE MongoDB
Studio 3T 2025.14 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.14 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
80 0
Studio 3T 2025.14 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
缓存 运维 NoSQL
收藏的博客 -- Redis学习
收藏的博客 -- Redis学习
185 0
|
4月前
|
缓存 NoSQL 关系型数据库
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
|
4月前
|
缓存 NoSQL Java
Redis+Caffeine构建高性能二级缓存
大家好,我是摘星。今天为大家带来的是Redis+Caffeine构建高性能二级缓存,废话不多说直接开始~
566 0
|
4月前
|
消息中间件 缓存 NoSQL
基于Spring Data Redis与RabbitMQ实现字符串缓存和计数功能(数据同步)
总的来说,借助Spring Data Redis和RabbitMQ,我们可以轻松实现字符串缓存和计数的功能。而关键的部分不过是一些"厨房的套路",一旦你掌握了这些套路,那么你就像厨师一样可以准备出一道道饕餮美食了。通过这种方式促进数据处理效率无疑将大大提高我们的生产力。
161 32
|
4月前
|
缓存 NoSQL Java
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡
93 5
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡