一、安装
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
tar xzvf redis-4.0.8.tar.gz
cd redis-4.0.8
make
cd src
make install PREFIX=/usr/local/redis
cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc
vi /usr/local/redis/etc/redis.conf
daemonize yes //将daemonize no 改成daemonize yes
#bind 127.0.0.1 //将bind本机IP注释掉
protected-mode no //将protected-mode yes改为protected-mode no
vi /etc/rc.local //在里面添加内容:
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
二、多端口、多实例运行
Redis是默认安装在/etc/redis目录之下,并且是安装好了就自动启动的。Redis的配置文件目录默认是在/etc/redis/redis.conf,默认端口为6379。现在我们需要将Redis设置多端口多实例运行,并且开机自动运行,需要以下几个简单的步骤:
cp redis.conf redis_6380.conf
pidfile /var/run/redis/redis-server-6380.pid
port 6380
logfile /var/log/redis/redis-server-6380.log
dbfilename dump_6380.rdb
redis-server /etc/redis/redis_6380.conf
redis-server /etc/redis/redis_6380.conf
常用命令
redis-server /usr/local/redis/etc/redis.conf //启动redis
pkill -9 redis //停止redis
rm -rf /usr/local/redis //删除安装目录
rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本
rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹