wget http://download.redis.io/releases/redis-3.2.6.tar.gz
tar -zxvf redis-3.2.6.tar.gz
cd redis-3.2.6
make//编译,生成src、redis.conf文件
cd src
cp redis-cli redis-server /usr/local/redis/
cd redis-3.2.6
cp redis.conf /usr/local/redis/
//redis下开启前台服务
./redis-server
//redis下开启后台服务,修改redis.conf 文件,将daemonize no 改为daemonize yes
vi redis.conf
//杀掉rdis进程,然后再次打开redis服务,没有killall命令就yum安装,yum install psmisc -y(centos7下)
killall redis-server
//开启服务
./redis-server redis.conf
//查看开启的服务
pstree
//后台运行成功以后,用redis-cli本地客户端连接redis。如果是连接网络机器 :./redis-cli IP 端口号,IP地址和端口号可以不写,不写的话,默认连接本机redis
./redis-cli
//配置开机自启
mkdir /etc/init.d/redis
vi /etc/init.d/redis
#!/bin/bash
#chkconfig:
# description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=
EXEC=/usr/local/redis/redis-server
REDIS_CLI=/usr/local/redis/redis-cli PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/redis.conf"
AUTH="" case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed."
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep
while [ -x $PIDFILE ]
do
echo "Waiting for Redis to shutdown..."
sleep
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${} stop
${} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&
exit
esac
///etc/init.d/redis下设置权限
chmod 755 redis
//启动测试
/etc/init.d/redis start
//返回,Starting Redis server... Redis is running...
//执行脚本,开机自启,
chkconfig redis on
windows下:
redis安装根目录下,右键打开git bash,执行以下命令:
//使用配置文件启动redis-server(此种启动不是后台启动,既没有形成服务)
./redis-server.exe redis.windows.conf
//安装服务,这样就会在系统服务中出现redis,手动启动即可
./redis-server.exe --service-install redis.windows-service.conf --loglevel verbose