redis官网 : https://redis.io/
redis中文官网 : http://redis.cn/
- redis 下载
- 我使用的Linux系统是Centos-8
- 下载工具包
yum install -y gcc gcc-c++
- yum install gcc 下载下来gcc版本是8.3
- 如果你的系统是Centos-7 则需要升级gcc
- 升级gcc
yum install -y centos-release-scl
yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
- windows下载使用ftp工具上传到linux 或者 使用wget在线下载
yum install -y wget
wget https://download.redis.io/releases/redis-6.2.4.tar.gz
- 安装redis
tar -xf redis-6.2.4.tar.gz 解压源码包
cd redis-6.2.4 进入源码包
将redis编译到指定目录 ( 个人喜好 ) 不想编译到指定目录 直接make即可
make PREFIX=/usr/local/redis/ install
make install 安装
- redis 安装成功后同时会把可执行程序放到 /usr/local/bin 下面
- 这样可以在任意目录执行redis
- 生成配置文件
cd /home/src/redis-6.2.4
cd utils/
./install_server.sh
报错: 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!
- 解决报错
vim 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
注释掉以上内容
:wq 保存退出
- redis服务安装
选择redis的端口号 回车是默认6379 自定义就需要自己输入
Please select the redis port for this instance: [6379] 回车
Selecting default: 6379
配置文件路径以及名称 回车是默认路径/etc/redis/6379.conf 自定义就需要自己输入
Please select the redis config file name [/etc/redis/6379.conf]
/usr/local/redis/redis.conf
日志文件以及名称 回车是默认路径/var/log/redis_6379.log 自定义就需要自己输入
Please select the redis log file name [/var/log/redis_6379.log]
/usr/local/redis/log/redis.log
数据目录 回车是默认存放/var/lib/redis/6379 自定义就需要自己输入
Please select the data directory for this instance [/var/lib/redis/6379]
/usr/local/redis/data
启动文件 回车是默认是/usr/local/bin/redis-server 自定义就需要自己输入
redis安装成功后会在/usr/loacl/bin/redis-server也生成启动文件
Please select the redis executable path [/usr/local/bin/redis-server]
/usr/local/redis/bin/redis-server
Selected config:
Port : 6379
Config file : /usr/local/redis/redis.conf
Log file : /usr/local/redis/log/redis.log
Data dir : /usr/local/redis/data
Executable : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
检查没毛病就可以回车了
Is this ok? Then press ENTER to go on or Ctrl-C to abort. 回车
- 注意事项
运行服务安装程序后会让你根据提示安装如果需要指定目录就需要自己手动输入
不需要指定目录的话一直回车即可
手动输入需要注意 不能使用tab键 不能使用tab键 不能使用tab键 重要事情说三遍
也不能输入错误 如果出错就需要 ctrl+c 退出 重新来
我已经重来了好几遍
- redis服务安装成功后 redis目录会多出来配置文件以及目录
- 同时还会在 /etc/init.d/ 下面生成 redis的启动脚本 redis_6379
- redis设置开机自启动
- redis_6379脚本自带了 #chkconfig注释 所以直接添加即可
chkconfig --add redis_6379
chkconfig --list
- 重启
- 成功 ( 过程有点繁琐 多安装几次就简单了 而且这样安装易维护易操作 )