redis的简介和简单安装

redis简介

redis的简介和简单安装_第1张图片

redis的简介和简单安装_第2张图片

redis的简介和简单安装_第3张图片

redis使用场景

redis的简介和简单安装_第4张图片

在新浪微博Redis的部署场景很多,大概分为如下两种:
1应用程序直接访问redis服务器。

redis的简介和简单安装_第5张图片

2 应用程序直接先访问redis,只有当redis访问失败时才会去访问MySQL。

redis的简介和简单安装_第6张图片

redis集群和mysql集群是同步的

redis的简介和简单安装_第7张图片

redis的安装

下载,解压,编译:

redis中文网下载

    $ wget http://download.redis.io/releases/redis-3.0.6.tar.gz
    $ tar xzf redis-3.0.6.tar.gz
    $ cd redis-3.0.6
    $ make    $ wget http://download.redis.io/releases/redis-3.0.6.tar.gz
    $ tar xzf redis-3.0.6.tar.gz
    $ cd redis-3.0.6
    $ make

二进制文件是编译完成后在src目录下. 运行如下:

$ src/redis-server

例如:

root@ubuntu:/home/ysy/redis-3.2.3# src/redis-server
7790:C 24 Sep 11:40:22.443 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
7790:M 24 Sep 11:40:22.444 * Increased maximum number of open files to 10032 (it was originally set to 1024).
7790:M 24 Sep 11:40:22.446 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.3 (00000000/0) 32 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 7790
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

7790:M 24 Sep 11:40:22.489 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
7790:M 24 Sep 11:40:22.490 # Server started, Redis version 3.2.3
7790:M 24 Sep 11:40:22.490 # 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.
7790:M 24 Sep 11:40:22.490 # 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.
7790:M 24 Sep 11:40:22.490 * DB loaded from disk: 0.000 seconds
7790:M 24 Sep 11:40:22.490 * The server is now ready to accept connections on port 6379

此时无法进行其他操作,会占用窗口

如果需要后台启动,则需要将redis.conf中的daemonize 改为yes,并且启动时指明配置文件,例如:

root@ubuntu:/home/ysy/redis-3.2.3# src/redis-server redis.conf 
root@ubuntu:/home/ysy/redis-3.2.3# 

查看有没有启动成功

root@ubuntu:/home/ysy/redis-3.2.3# ps -ef | grep redis
root      5251     1  0 10:38 ?        00:00:02 src/redis-server 127.0.0.1:6379
root      6317  5023  0 10:57 pts/1    00:00:00 grep --color=auto redis

查看6379端口

root@ubuntu:/home/ysy/redis-3.2.3# netstat -tunpl | grep 6379
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      5251/redis-server 1

如何关闭redis服务

root@ubuntu:/home/ysy/redis-3.2.3# pkill redis-server 

或者

root@ubuntu:/home/ysy/redis-3.2.3# src/redis-cli 
127.0.0.1:6379> shutdown
not connected> quit

redis的配置

redis的简介和简单安装_第8张图片

redis的简介和简单安装_第9张图片

redis的简介和简单安装_第10张图片

你可能感兴趣的:(redis)