1.安装wget
yum -y install wget
2.获取连接并解压
mkdir /opt/software/redis -p && cd /opt/software/redis
wget https://github.com/redis/redis/archive/7.2.4.tar.gz
3.编译安装
yum -y install lsb-release curl gpg gcc*
make && make install # 使用make install会自动安装到/usr/local/bin
根据redis自带的README.md可以知道
In order to install Redis binaries into /usr/local/bin, just use:
% make install
You can usemake PREFIX=/some/other/directory install
if you wish to use a
different destination.
以上便可以直接使用redis命令, 因为他的安装目录归属于PATH
当我们在生产环境使用的时候需要继续安装.基于上述步骤进行补充即可
- 确保redis make&& make install
- 切回到redis的解压目录
- 进入utils目录, 执行脚本
cd utils
./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!!
这个时候我们需要去脚本里面注释一段代码,重新执行即可
#_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
4.查看运行状态
yum -y install bash-completion # 自动补全命令
systemctl status redis_6379.service
5.测试
redis-cli #进行客户端
redis-cli -h # 命令帮助
登入redis客户端
help #帮助命令
help @string # help @group, 获取这个组别的所有命令, 这个通常可以用来查看reids对应的数据类型, string, list, hash, set, sorted-set
help set # 用于查找具体命令的使用,以及作用,组别