wget http://download.redis.io/releases/redis-4.0.1.tar.gz
tar zxvf redis-4.0.1.tar.gz
cd redis-4.0.1
make
第二、设置redis
mkdir -p /usr/local/redis/{bin,etc,var} 我把redis装在/usr/local/redis下,目录根据自己的调整
拷贝文件
cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} /usr/local/redis/bin/
cp redis.conf /usr/local/redis/etc/
ln -s /usr/local/redis/bin/* /usr/local/bin/
sed -i "s@logfile.*@logfile /usr/local/redis/var/redis.log@" /usr/local/redis/etc/redis.conf
sed -i "s@^dir.*@dir /usr/local/redis/var@" /usr/local/redis/etc/redis.conf
sed -i 's@daemonize no@daemonize yes@' /usr/local/redis/etc/redis.conf
sed -i "s@^# bind 127.0.0.1@bind 127.0.0.1@" /usr/local/redis/etc/redis.conf
sed -i "s@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 123000000" /usr/local/redis/etc/redis.conf 根据自己机器的内存来设置,一般不超过3/4
useradd -M -s /sbin/nologin redis
chown -R redis:redis /usr/local/redis/{var,etc}
第三、设置开机启动
cp /opt/soft/Redis-server-init /etc/init.d/redis-server
cc /opt/soft/start-stop-daemon.c -o /sbin/start-stop-daemon
chkconfig --add redis-server
chkconfig redis-server on
service redis-server start
文中用到的文件下载地址:脚本和文件