Linux Centos6.8 安装配置Readis3.2.8

1:下载

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


2:解压

tar zxvf redis-3.2.8.tar.gz


3:编译并指定安装目录

make PREFIX=/usr/local/redis-3.2.8 install


4: 添加修改配置文件

cp redis.conf /etc/redis.conf
vim /etc/redis.conf

将  daemonize no  改为 daemonize yes

说明:将Redis设置为后台进程


5:创建redis用户

useradd -r -s /sbin/nologin -M redis


6:创建编辑启动脚本

vim /etc/init.d/redis
配置内容

#!/bin/sh
#
# redis        init file for starting up the redis daemon
#
# chkconfig:  - 20 80
# description: Starts and stops the redis daemon.
 
# Source function library.
#!/bin/sh
#
# redis        init file for starting up the redis daemon
#
# chkconfig:  - 20 80
# description: Starts and stops the redis daemon.
 
# Source function library.
. /etc/rc.d/init.d/functions

name="redis-server"
# this is install catalog
exec="/usr/local/redis-3.2.8/bin/$name"
pidfile="/var/run/redis/redis.pid"
# this is configureFile
REDIS_CONFIG="/etc/redis.conf"
 
[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis
 
lockfile=/var/lock/subsys/redis
 
start() {
    [ -f $REDIS_CONFIG ] || exit 6
    [ -x $exec ] || exit 5
    echo -n $"Starting $name: "
    daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $name: "
    killproc -p $pidfile $name
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    stop
    start
}
 
reload() {
    false
}
 
rh_status() {
    status -p $pidfile $name
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
        exit 2
esac
exit $?


7:修改文件权限

chmod 755 /etc/init.d/redis


8:设置开机启动

chkconfig --add redis
chkconfig redis on


9:启动redis

service redis start


10:进入redis

/usr/local/redis-3.2.8/bin/redis-cli -h 127.0.0.1 -p 6379


说明:

如果你需要配置密码

vim /etc/redis.conf
去掉requirepass前边的注释  更改自己的密码 requirepass password
再次进入redis 则为

/usr/local/redis-3.2.8/bin/redis-cli -h 127.0.0.1 -p 6379 -a password


一些基础命令

set k v  创建kv值
key *    查看所有键
get k    根据K返回V


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值