leng 发表于 2013-10-31 09:28:26

Redis 介绍安装

一、Redis简介
Redis(Remote Dictionary Server:远程字典服务)是ANSI C 语言编写的一款开源,遵循BSD协议,支持网络、可基于内存亦可持久化的日志型、高级key-value存储系统,可以在所有POSIX系统上运行;因为其键(keys)可以是字符串(strings)、哈希(hashes)、列表(lists)、集合(sets)和有序集合(sortedsets),它通常被称作数据结构服务.
你可以对这些数据类型进行原子操作,比如push/pop,add/remove,取交集并集和差集等。
二、安装
1.下载

#wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
2.编译安装redis


#tar xvf redis-2.6.14.tar.gz
#sed -i.bak '/^PREFIX/s@/usr/local@/opt/redis@g'redis-2.6.14/src/Makefile #指定redis安装路径为/opt/redis
#make
#make install
3.为redis设置PATH


#vi /etc/profile #添加下行内容
PATH=$PATH:/opt/redis/bin
#source /etc/profile
4.配置


#cp redis.conf /etc/
#vi /etc/sysctl.conf #添加vm.overcommit_memory=1,否则出现如下警告
# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
#redis-server /etc/redis.conf #默认情况下redis前端运行,并把日志输出到屏幕上
#vi /etc/redis.conf#对应行修改为下面内容
daemonize yes
logfile /var/log/redis.log
#netstat -tnlp |grep 379
5.编写服务管理脚本


#vi /etc/init.d/redis
#!/bin/bash
#redis - this script can start|stop the redis service.
#chkconfig:    -8911
#description:    redis is a presistent key-value store Database
# processname:redis-server
# config: /etc/redis.conf
# config: /opt/redis/bin/redis-server
# pidfile: /var/run/redis.pid
# source function library.
. /etc/rc.d/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
# check that networking is up.
[ "$NETWORKING" = "no"] && exit 0
REDIS=/opt/redis/bin/redis-server
PROG=$(basename $REDIS)
CONFIG=/etc/redis.conf
PIDFILE=/var/run/redis.pid
LOCKFILE=/var/lock/subsys/redis
start() {
    [ -x $REDIS ] || exit 3
    [ -f $CONFIG ] || exit 4
    echo -n $"Starting $PROG: "
    daemon $REDIS $CONFIG
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $LOCKFILE
    return $RETVAL
}
stop() {
    echo -n $"Stopping $REDIS: "
    killproc $PROG -QUIT
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
    return $RETVAL
}
restart() {
    stop
    start
}
reload() {
    echo -n $"Reloading $PROG: "
    killproc $REDIS -HUP
    RETVAL=$?
    echo
}
status() {
    status$PROG
    RETVAL=$?
    echo
}
case "$1" in
    start)
         start
         ;;
    stop)
      stop
      ;;
    restart)
      restart
      ;;
    status)
      status
      ;;
    reload)
      reload
      ;;
    *)
      echo $"Useage: $PROG {start|stop|status|reload|restart}"
      RETVAL=2
esac
exit $RETVAL
#chmod +x /etc/init.d/redis
6.设置开机启动


#chkconfig --add redis
#chkconfig --level 35 redis on
#chkconfig --list redis
7.web 管理工具phpRedisAdmin安装


//参考资料: https://github.com/ErikDubbelboer/phpRedisAdmin
# yum install git httpd -y //安装git,httpd
#cd /var/www/html
#git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
#cd phpRedisAdmin
#git submodule init
#git submodule update
#/etc/init.d/httpd start
http://yourip/phpRedisAdmin


xq8995209 发表于 2013-12-2 09:38:52

你突然的不爱,我还没来得及接受意外

arongsoft 发表于 2013-12-7 06:57:18

你的真心、让我懂的怎么样去爱一个人。

QQ叫紫珊 发表于 2013-12-11 07:05:03

我 們 有 太 多 的 無 奈 ,可 我 已 經 無 力 訴 說 。

dopost 发表于 2013-12-14 19:59:41

我不说,你不懂,这便是距离。

xuyaxiu 发表于 2013-12-17 18:33:23

幻想你每天都陪在我身边.睡梦中都因你而笑

阿牛 发表于 2013-12-20 10:41:11

我们两个人之间、是永远不可能相交的平行线
页: [1]
查看完整版本: Redis 介绍安装