Redis下载安装与基本使用(linux)

下载地址:https://redis.io/download

Redis下载安装与基本使用(linux)

 

下载后放置redis目录下并进入该目录(其他目录也可以)

1)解压   tar zxvf redis-3.2.9.tar.gz

Redis下载安装与基本使用(linux)

 

2)进入该目录   cd redis-3.2.9

3)编译   make

4)cd src && make install  

     此步骤需要创建文件夹的权限,使用无权限创建的用户操作会有报错。

接下来移动部分文件到统一目录便于操作:

5)mkdir -p /usr/local/redis/bin

6)mkdir -p /usr/local/redis/etc

7)mv redis/redis-3.2.9/redis.conf  /usr/local/redis/etc/

8)cd redis/redis-3.2.9/src/

9)mv mkreleasehdr.sh redis-benchmark redis-check-rdb redis-sentinel redis-trib.rb redis-check-        aof redis-cli redis-server /usr/local/redis/bin/

启动和停止redis

10)启动前设置为后台运行  vi /usr/local/redis/etc/redis.conf

      daemonize no  找到这句  把 no 改成 yes

      执行/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

      启动是遇到的问题之一:

 [1] WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128

    解决方法:进入etc目录,编辑 sysctl.conf   新增 net.core.somaxconn = 1024  执行 sysctl -p

[2]   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.

      解决方法:执行  echo 1 > /proc/sys/vm/overcommit_memory

[3]     WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

        解决方法:在root用户下 执行  echo never > /sys/kernel/mm/transparent_hugepage/enabled

11)客户端连接 /usr/local/redis/bin/redis-cli

12) 停掉  /usr/local/redis/bin/redis-cli shutdown  或者  pkill redis-server

转载于:https://my.oschina.net/xiaozhiwen/blog/912185