Redis安装步骤

本文详细介绍Redis的安装步骤。

安装环境

操作系统: Centos 6.4 ( cat /etc/redhat-release)
Redis: 3.0.7

下载编译

从Redis官网下载:

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

解压:

tar -zxvf redis-3.0.7.tar.gz

cd redis-3.0.7

编译:

make

如果出现找不到gcc编译器错误

yum install -y gcc

编译过程出错,找到redis README中的说明:

Allocator
Selecting a non-default memory allocator when building Redis is done by setting the MALLOC environment variable. Redis is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc

To force compiling against libc malloc, use:
% make MALLOC=libc
To compile against jemalloc on Mac OS X systems, use:
% make MALLOC=jemalloc

因此,由于找不到jemalloc导致出错,make的时候指定MALLOC为libc

make  MALLOC=libc

做个链接:

ln -s redis-3.0.7/src/ bin

启动使用

启动redis

nohup bin/redis-server  > log.out &

这里写图片描述

启动交互客户端:

bin/redis-cli

info命令查看redis的一些基本信息:

这里写图片描述

试用命令:
set命令设置值,get获取值:

这里写图片描述

详细命令参考:http://redis.io/commands

Redis配置

从redis发行包目录下拷贝一份默认的redis配置到/etc目录下:

cp redis-3.0.7/redis.conf /etc/redis/

启动的时候指定配置文件:

redis-server /etc/redis/redis.conf

设置密码:

requirepass youpassword

配置数据保存路径:

dir /opt/data/redis/

停止redis:
在客户端命令行:

shutdown

使用自定义配置重启:

nohup bin/redis-server /etc/redis/redis.conf >>  log/redis.out &
cat log/redis.out

此时使用redis-cli登录客户端之后,需要首先授权:

127.0.0.1:6279> auth youpassword

在客户端调用save命令后,数据将被保存在/opt/data/redis/dump.rdb

127.0.0.1:6279> save
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值