首页 > 代码库 > centos 安装redis2.8.9
centos 安装redis2.8.9
1没有安装gcc
yum install gcc-c++
2. 安装tcl
yum install -y tcl
3.安装redis
$ wget http://download.redis.io/releases/redis-2.8.9.tar.gz
$ tar xzf redis-2.8.9.tar.gz
$ cd redis-2.8.9
$ make
$ make test
$ make install
4.编辑redis.conf文件
把 daemonize no 改成 yes。(redis以守护进程的方式运行
)
然后把redis.cong复制到/etx
cp redis.conf /etc
5.编写一个自启动脚本(网上摘抄)
###########################PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pidCONF="/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 1esac##############################
把这段保存成redis,放到/etc/init.d/下面
chmod +x /etc/init.d/redis (修改权限)
sudo chkconfig redis on
6.启动和停止
service redis start #或者 /etc/init.d/redis start
service redis stop #或者 /etc/init.d/redis stop
7.测试
redis-cli
redis 127.0.0.1:6379> set name fu
OK
redis 127.0.0.1:6379> get name
"fu"
redis 127.0.0.1:6379> exit
8.哦了,继续学习,加油!
centos 安装redis2.8.9
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。