RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Redis4.0如何编译安装

小编给大家分享一下redis4.0如何编译安装,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

东台网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。成都创新互联公司公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

  1. 小程序测试wget http://download.redis.io/releases/redis-4.0.11.tar.gz

  2. 安装编译

  3. 环境centos7 

It is as simple as:

    % make

You can run a 32 bit Redis binary using:

    % make 32bit

After building Redis, it is a good idea to test it using:

    % make test

Fixing build problems with dependencies or cached build options

---------

Redis has some dependencies which are included into the `deps` directory.

`make` does not automatically rebuild dependencies even if something in

the source code of dependencies changes.

When you update the source code with `git pull` or when code inside the

dependencies tree is modified in any other way, make sure to use the following

command in order to really clean everything and rebuild from scratch:

    make distclean

This will clean: jemalloc, lua, hiredis, linenoise.

Also if you force certain build options like 32bit target, no C compiler

optimizations (for debugging purposes), and other similar build time options,

those options are cached indefinitely until you issue a `make distclean`

command.

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

To compile against jemalloc on Mac OS X systems, use:

    % make MALLOC=jemalloc

Verbose build

-------------

Redis will build with a user friendly colorized output by default.

If you want to see a more verbose output use the following:

    % make V=1

Running Redis

-------------

To run Redis with the default configuration just type:

    % cd src

    % ./redis-server

If you want to provide your redis.conf, you have to run it using an additional

parameter (the path of the configuration file):

    % cd src

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

It is possible to alter the Redis configuration by passing parameters directly

as options using the command line. Examples:

    % ./redis-server --port 9999 --slaveof 127.0.0.1 6379

    % ./redis-server /etc/redis/6379.conf --loglevel debug

All the options in redis.conf are also supported as options using the command

line, with exactly the same name.

Playing with Redis

------------------

You can use redis-cli to play with Redis. Start a redis-server instance,

then in another terminal try the following:

    % 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>

You can find the list of all the available commands at http://redis.io/commands.

Installing Redis

-----------------

In order to install Redis binaries into /usr/local/bin just use:

    % make install

You can use `make PREFIX=/some/other/directory install` if you wish to use a

different destination.

Make install will just install binaries in your system, but will not configure

init scripts and configuration files in the appropriate place. This is not

needed if you want just to play a bit with Redis, but if you are installing

it the proper way for a production system, we have a script doing this

for Ubuntu and Debian systems:

    % cd utils

    % ./install_server.sh


4. 采用make PREFIX=/usr/local/redis install

5. 拷贝配置文件mkdir /usr/local/redis/conf

6. cp  redis.conf sentinel.conf  /usr/local/redis/conf

第1个警告(WARNING: The TCP backlog setting of 511 ......)解决办法

方法1: 临时设置生效: sysctl -w net.core.somaxconn = 1024

方法2: 永久生效: 修改/etc/sysctl.conf文件,增加一行

net.core.somaxconn= 1024

然后执行命令

sysctl -p

补充:

net.core.somaxconn是linux中的一个kernel参数,表示socket监听(listen)的backlog上限。

backlog是socket的监听队列,当一个请求(request)尚未被处理或建立时,他会进入backlog。

而socket server可以一次性处理backlog中的所有请求,处理后的请求不再位于监听队列中。

当server处理请求较慢,以至于监听队列被填满后,新来的请求会被拒绝。

所以说net.core.somaxconn限制了接收新 TCP 连接侦听队列的大小。

对于一个经常处理新连接的高负载 web服务环境来说,默认的 128 太小了。大多数环境这个值建议增加到 1024 或者更多。

第2个警告(WARNING overcommit_memory is set to 0! ......)同样也有两个解决办法

方法1: 临时设置生效: sysctl -w vm.overcommit_memory = 1

方法2: 永久生效: 修改/etc/sysctl.conf文件,增加一行

vm.overcommit_memory = 1

然后执行命令

sysctl -p

补充: 

overcommit_memory参数说明:

设置内存分配策略(可选,根据服务器的实际情况进行设置)

/proc/sys/vm/overcommit_memory

可选值:0、1、2。

0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。

1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。

2, 表示内核允许分配超过所有物理内存和交换空间总和的内存

注意:redis在dump数据的时候,会fork出一个子进程,理论上child进程所占用的内存和parent是一样的,比如parent占用的内存为8G,这个时候也要同样分配8G的内存给child,如果内存无法负担,往往会造成redis服务器的down机或者IO负载过高,效率下降。所以这里比较优化的内存分配策略应该设置为 1(表示内核允许分配所有的物理内存,而不管当前的内存状态如何)。

看完了这篇文章,相信你对“Redis4.0如何编译安装”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


分享标题:Redis4.0如何编译安装
转载来于:http://lswzjz.com/article/jodgsp.html