centos 7 上安装redis

安装redis

官网下载redis压缩包
https://redis.io/
直接点击下载即可
配置较低的可能会报错,百度一下调整一下参数就行

解压
tar xvf redis-5.0.5.tar.gz -C /software ## -C + path 意思是解压到指定位置
cd /software/redis-5.0.5/
make  ##(如果你系统是32位make 32bit)
make test 
make install ##这一步根据自己的实际情况来定是否执行,执行会生成二进制文件并将二进制文件加入到/usr/local/bin,我自己没有执行
make perfix=/usr/loca/redis install ##安装到/usr/local/redis下
###make install redis 已经提供了安装脚本
    % cd utils
    % ./install_server.sh
配置redis
略,redis.conf文件件中写的很详细
启动redis
##启动命令
    % cd src
    % ./redis-server ##前台运行
    nohup ./redis-server /var/log/redis/redis.log 2&>1 & ##后台运行 这里2表示标准错误流,1表示标准输出流,0表示标准输入流
redis readme

This README is just a fast quick start document. You can find more detailed documentation at redis.io.

What is Redis?

Redis is often referred as a data structures server. What this means is that Redis provides access to mutable data structures via a set of commands, which are sent using a server-client model with TCP sockets and a simple protocol. So different processes can query a
nd modify the same data structures in a shared way.
Data structures implemented into Redis have a few special properties:

  • Redis cares to store them on disk, even if they are always served and modified into the server memory. This means that Redis is fast, but that is also non-volatile.
  • Implementation of data structures stress on memory efficiency, so data structures inside Redis will likely use less memory compared to the same data structure modeled using an high level programming language.
  • Redis offers a number of features that are natural to find in a database, like replication, tunable levels of durability, cluster, high availability.

Another good example is to think of Redis as a more complex version of memcached, where the operations are not just SETs and GETs, but operations to work with complex data types like Lists, Sets, ordered data structures, and so forth.

If you want to know more, this is a list of selected starting points:

  • Introduction to Redis data types. http://redis.io/topics/data-types-intro
  • Try Redis directly inside your browser. http://try.redis.io
  • The full list of Redis commands. http://redis.io/commands
  • There is much more inside the Redis official documentation. http://redis.io/documentation

Building Redis

Redis可以编译和使用在Linux, OSX, OpenBSD, NetBSD, FreeBSD。我们支持大端和小端架构,都是32位64位系统

它可以在Solaris衍生系统(例如SmartOS)上编译,但是我们的支持这个平台是最好的努力和Redis不保证
可以在Linux、OSX和*BSD中工作。

最简单的方式

% make

您可以运行一个32位的Redis二进制使用

% make 32bit

在构建Redis之后,最好使用它进行测试

% make test

修复依赖项或缓存的构建选项的构建问题

Redis有一些包含在’ deps ‘目录中的依赖项。’ make '不会自动重建依赖关系,即使在依赖项的源代码更改。

当您使用“git pull”更新源代码时,或者当代码在以任何其他方式修改依赖项树,请确保使用以下内容
命令,以真正清洁一切和重建从零开始:

make distclean

这将清洁:jemalloc, lua, hiredis, linenoise。

此外,如果您强制某些构建选项,如32位目标,没有C编译器优化(用于调试)和其他类似的构建时选项,
这些选项将被无限缓存,直到您发出“make distclean”
命令。

Fixing problems building 32 bit binaries

If after building Redis with a 32 bit target you need to rebuild it
with a 64 bit target, or the other way around, you need to perform a
make distclean in the root directory of the Redis distribution.

In case of build errors when trying to build a 32 bit binary of Redis, try
the following steps:

  • Install the packages libc6-dev-i386 (also try g+±multilib).
  • Try using the following command line instead of make 32bit:
    make CFLAGS="-m32 -march=native" LDFLAGS="-m32"

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

要在Mac OS X系统上编译jemalloc,请使用:

% make MALLOC=jemalloc

详细的构建

默认情况下,Redis将构建一个用户友好的彩色输出。如果你想看到更详细的输出使用以下:

% make V=1

运行 Redis

要用默认配置运行Redis,只需输入

% cd src
% ./redis-server ##前台运行
nohup ./redis-server /var/log/redis/redis.log 2&>1 & ##后台运行 这里2表示标准错误流,1表示标准输出流,0表示标准输入流

若果你先用你自己写的redis.conf,你必须使用一个附加的参数(配置文件的路径):

% cd src
% ./redis-server /path/to/redis.conf

可以通过直接传递参数来更改Redis配置
作为选项使用命令行。例子:

% ./redis-server --port 9999 --replicaof 127.0.0.1 6379
% ./redis-server /etc/redis/6379.conf --loglevel debug

conf中的所有选项也都支持使用该命令作为选项行,名字完全一样。
操作 Redis

你可以使用Redis -cli操作Redis。启动一个redis-server实例,然后在另一个终端尝试以下操作:

% cd src
% ./redis-cli
redis> ping
PONG
redis> set foo bar
OK
redis> get foo
"bar"
redis> incr mycounter
(integer) 1
redis> incr mycounter
(integer) 2
redis>

命令清单: http://redis.io/commands.

Installing Redis

为了安装Redis二进制文件到/usr/local/bin只需使用:

% make install

如果您希望使用,可以使用“make PREFIX=/some/other/directory install”
不同的目的地。

Make install将只在系统中安装二进制文件,而不进行配置
init脚本和配置文件放在适当的位置。这不是
需要,如果你只是想玩一点与Redis,但如果你正在安装
这是生产系统的正确方式,我们有一个这样做的脚本
Ubuntu和Debian系统:

% cd utils
% ./install_server.sh

脚本将询问您几个问题并设置您需要的所有内容
要正确运行Redis作为后台守护进程,将重启系统。

You’ll be able to stop and start Redis using the script named
/etc/init.d/redis_<portnumber>, for instance /etc/init.d/redis_6379.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值