码迷,mamicode.com
首页 > 其他好文 > 详细

centos 安装 redis

时间:2017-09-11 18:03:50      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:redis   redis安装   centos安装redis   

                            Centos  安装  redis

redis安装:

1.#下载redies安装包

wget http://download.redis.io/releases/redis-3.2.0.tar.gz  tar -xf redis-3.2.0.tar.gz

2.#编译安装 ,如果出现make报错,就是缺少gccyum install gcc-c++  

cd redis-3.2.0

make

3.#添加相关文件及命令

mkdir /usr/local/redis/bin/ -p

cd src

cp redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server redis-sentinel /usr/local/redis/bin/

cd ..

cp redis.conf /etc/

 

4.#添加启动脚本

echo ‘#chkconfig: 2345 10 90

#description: Start and Stop redis

REDISPORT=6379

EXEC=/usr/local/redis/bin/redis-server

REDIS_CLI=/usr/local/redis/bin/redis-cli 

PIDFILE=/var/run/redis.pid

CONF="/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

if [ "$?"="0" ]

then

echo "Redis is running..."

fi

;;

stop)

if [ ! -f $PIDFILE ]

then

echo "$PIDFILE does not exist, process is not running"

else

PID=$(cat $PIDFILE)

echo "Stopping ..."

$REDIS_CLI -p $REDISPORT SHUTDOWN

while [ -x ${PIDFILE} ]

do

echo "Waiting for Redis to shutdown ..."

sleep 1

done

echo "Redis stopped"

fi

;;

restart|force-reload)

${0} stop

${0} start

;;

*)

echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2

exit 1

esac

‘ > /etc/init.d/redis

添加执行权限:

chmod +x /etc/init.d/redis

5.#设置开机自启动

chkconfig --add redis

chkconfig redis on

6.#创建redis状态日志

mkdir /var/log/redis/

touch /var/log/redis/redis.log

 

6.设置环境变量:

echo “export PATH=$PATH:/usr/local/redis/bin” >> /root/.bash_profile

source /root/.bash_profile

7.启动服务后台运行:

redis-server /etc/redis.conf &


最后注意要进去/etc/redis.conf配置文件修改你的端口,不然会被黑客利用,成为挖矿肉鸡,这种挖矿木马,主要消耗你的cpu资源

 


本文出自 “Linux修仙之路” 博客,请务必保留此出处http://8999a.blog.51cto.com/11385098/1964378

centos 安装 redis

标签:redis   redis安装   centos安装redis   

原文地址:http://8999a.blog.51cto.com/11385098/1964378

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!