1. 安装
yum -y install gcc
wget http://download.redis.io/releases/redis-3.2.2.tar.gz
tar zxf redis-3.2.2.tar.gz
cd redis-3.2.2
make
make install
cd ..
cd utils
./install_server.sh 接着下面一路回车
#2. 配置
mkdir -p /usr/local/redis/bin
mkdir -p /usr/local/redis/etc
cp redis.conf /usr/local/redis/etc
cp src/mkreleasehdr.sh /usr/local/redis/bin/
cp src/redis-benchmark /usr/local/redis/bin/
cp src/redis-check-aof /usr/local/redis/bin/
cp src/redis-cli /usr/local/redis/bin/
cp src/redis-server /usr/local/redis/bin/
mkdir -p /usr/local/redis/pid
vi /usr/local/redis/etc/redis.conf
daemonize yes 这样就可以默认启动就后台运行
pidfile /usr/local/redis/pid/6379.pid
启动 redis
usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 启动 redis
检查
ps aux |grep redis
netstat -ntpl | grep 6379
#关闭 redis
pkill redis-server
或
/usr/local/redis/bin/redis-cli shutdown
#启动客户端
[root@zzx ~]# cd /usr/local/redis/bin/redis-cli
127.0.0.1:6379> 说明客户端启动成功
监控状态
[root@zzx conf]# /usr/local/redis/bin/redis-cli -p 6379 monitor
+++++++++++++++++++++++
开启自启动服务
++++++++++++++++++++++++
- 编辑文件 /etc/init.d/redis
vi /etc/init.d/redis
#!/bin/sh
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/usr/local/redis/pid/redis.pid
CONF="/usr/local/redis/etc/redis.conf"
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
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=(cat PIDFILE)
echo "Stopping ..."
CLIEXEC -p REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
`
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于