一、Redis概况
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件。它支持多种类型的数据结构,如 字符串(strings), 散列(hashes), 列表(lists), 集合(sets), 有序集合(sorted sets) 与范围查询, bitmaps, hyperloglogs 和 地理空间(geospatial) 索引半径查询。 Redis 内置了 复制(replication),LUA脚本(Lua scripting), LRU驱动事件(LRU eviction),事务(transactions) 和不同级别的 磁盘持久化(persistence), 并通过 Redis哨兵(Sentinel)和自动 分区(Cluster)提供高可用性(high availability)。
二、安装
https://download.redis.io/releases/redis-6.2.1.tar.gz
使用Xshell工具进行linux系统上的Redis安装。
-
首先使用Xshell连接远程服务器(连接不上可以参考xshell为什么连接不上ubuntu—could not connect to ‘ip’ (port 22): Connection failed.文章)
-
yum install wget (先安装wget)
-
wget https://download.redis.io/releases/redis-6.2.1.tar.gz(Redis官网的Download it)
-
tar xf redis-6.2.1.tar.gz (解压文件)
-
cd redis-6.2.1(进入文件夹进行操作)
-
vi README.md(参考配置手册来进行配置)
-
make (这里有报错的地方 cc:command not found,缺少C语言编译器)
-
yum install gcc (这步是安装cc语言编译器的,系统有就不需要再进行下载安装)
-
安装成功后再进行 make 编译,如果这里还有报错的现象,就先执行指令 make distclen再执行make继续编译
-
cd src 进入src文件夹后执行 ./redis-server 指令,这里能看见Redis启动成功了,但是这样的效果不是想要的,在公司不可能人工干预进行操作。以下继续配置自动化启动任务
-
cd utils/ 在utils文件夹中能看见一些脚本程序(./install_server.sh)
-
然后重新回到redis-6.2.1文件目录下,执行 make install PREFIX=/opt/redis6
-
执行成功后,能看见生成了一个redis6的文件夹,里面有一个bin目录
-
回到redis-6.2.1目录下执行 vi /etc/profile (编辑profile文件),以下代码追加文件末尾并保存
export REDIS_HOME=/opt/redis6
export PATH= P A T H : PATH: PATH:REDIS_HOME/bin -
然后source一下 source /etc/profile
-
echo $PATH 这里能看见刚才编辑的环境变量在最后追加了
-
再执行utis目录下的 install_server.sh
-
此时会提示错误信息:
Welcome to the redis service installer
This script will help you easily set up a running redis server
This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
- 编辑install_server.sh文件 vi ./install_server.sh
- 注释掉下面这段代码,然后重新执行install_server.sh
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
-
重新执行 ./install_server.sh,出现以下内容就说明启动成功
-
执行 cd /etc/init.d 命令出现redis_6379就证明安装成功
. -
接下来就可以在任意目录下进行redis的启动 service redis_6379 start/stop/status 以下流程就是启动服务成功了
-
ps -fe | grep redis 指令查看redis进程