下载Linux安装包 点击下载5.0.7
tar -zxvf redis-5.0.7.tar.gz
mv redis-5.0.7 /usr/local/redis
make -j 4
可以直接使用make即可,make -j -4 是使用4个CPU进行make,加快make速度
make install
修改redis配置文件
cd /usr/local/redis
vim redis.conf
-
将bind 127.0.0.1 修改为0.0.0.0 127.0.0.1表示只允许本机访问,0.0.0.0代表所有IP都可以访问
-
daemonize no 改为 yes 表示支持后台执行
-
port 6379 修改端口,可以根据自己的需求去改变端口号
-
requirepass foobared 修改密码 requirepass 123456
-
保存,退出,启动Redis
redis-server /usr/local/redis/redis.conf
设置redis为系统服务(这步可以不做)
进入redis的utils目录
cd /usr/local/redis/utils
找到install_server.sh并执行它
./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
确认服务的端口号,一般这块默认直接回车
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
/usr/local/redis/redis.conf
确认redis的conf配置文件,这块输入/usr/local/redis/redis.conf,然后回车
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/log/redis.log
确认Redis的log文件目录位置,我这边使用/usr/local/redis/log/redis.log 回车, 都在统一目录下方便查找
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/data
确认Redis的数据存储路劲,我这边使用/usr/local/redis/data 然后回车
Please select the redis executable path [/usr/local/bin/redis-server]
确认Redis的启动项,这块默认就是刚刚安装路劲,直接回车
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/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
询问是否确认这些配置,直接回车确认
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful!
当弹出这个,代表成功。接着查看一下服务,是不是真的配置成功
chkconfig --list | grep redis
// 输出
redis_6379 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
启动、停止、查看状态命令
centos7
systemctl status redis_6379 //查看状态
systemctl stop redis_6379 //停止
systemctl start redis_6379 //启动
Centos6
service redis_6379 status
service redis_6379 stop
service redis_6379 start
好了,安装结束。