zoukankan      html  css  js  c++  java
  • redis安装【三】

    目录介绍:

    0.Windows下下载安装包:

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

    1.上传到linux服务器

      将文件上传到192.168.2.128主机的usr/local目录下:

    C:UsersliDesktop>scp ./redis-4.0.2.tar.gz root@192.168.2.128:/usr/local
    root@192.168.2.128's password:
    redis-4.0.2.tar.gz                            100% 1674KB   3.7MB/s   00:00
    
    C:UsersliDesktop>

      SSH远程登录到linux服务器:

    C:Usersli>SSH root@192.168.2.128
    root@192.168.2.128's password:
    Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-12-generic i686)
    
     * Documentation:  https://help.ubuntu.com/
    
    0 packages can be updated.
    0 updates are security updates.
    
    Last login: Sat Nov  4 03:14:54 2017 from 192.168.2.1
    root@test:~#

      进入/usr/local目录查看文件:

    root@test:/usr/local# ll | grep redis-4.0.2.tar.gz
    -rw-r--r--  1 root root 1713990 Nov  4 03:13 redis-4.0.2.tar.gz

    2.解压安装

    解压:

    root@test:/usr/local# tar xzf redis-4.0.2.tar.gz 

    进入目录编译(因为是C语言写的,所以需要对源语言进行编译)

    root@test:/usr/local# ls
    bin  games    lib  redis-4.0.2         sbin   src
    etc  include  man  redis-4.0.2.tar.gz  share
    root@test:/usr/local# cd redis-4.0.2
    root@test:/usr/local/redis-4.0.2# make

    编译成功的标志:

    Hint: It's a good idea to run 'make test' ;)

    3.安装到指定目录,如 /usr/local/redis

    make PREFIX=/usr/local/redis install

     进入安装目录查看文件:

    root@test:/usr/local/redis-4.0.2# cd /usr/local/redis
    root@test:/usr/local/redis# ls
    bin
    root@test:/usr/local/redis# cd bin
    root@test:/usr/local/redis/bin# ls
    redis-benchmark  redis-check-rdb  redis-sentinel
    redis-check-aof  redis-cli        redis-server

    4.进入源码文件夹将配置文件拷贝到安装目录下

    root@test:/usr/local# cd redis-4.0.2
    root@test:/usr/local/redis-4.0.2# ls
    00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
    BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
    CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
    root@test:/usr/local/redis-4.0.2# cp redis.conf  /usr/local/redis
    root@test:/usr/local/redis-4.0.2# pwd
    /usr/local/redis-4.0.2
    root@test:/usr/local/redis-4.0.2# cd ../redis
    root@test:/usr/local/redis# ls
    bin  redis.conf

    5.启动redis服务:

    root@test:/usr/local/redis# ./bin/redis-server redis.conf 
    出现以下信息证明启动成功:
    8325:C 04 Nov 03:37:27.757 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    8325:C 04 Nov 03:37:27.762 # Redis version=4.0.2, bits=32, commit=00000000, modified=0, pid=8325, just started
    8325:C 04 Nov 03:37:27.763 # Configuration loaded
    8325:M 04 Nov 03:37:27.766 * Increased maximum number of open files to 10032 (it was originally set to 1024).
    8325:M 04 Nov 03:37:27.874 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 4.0.2 (00000000/0) 32 bit
      .-`` .-```.  ```/    _.,_ ''-._                                   
     (    '      ,       .-`  | `,    )     Running in standalone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 8325
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    8325:M 04 Nov 03:37:27.882 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    8325:M 04 Nov 03:37:27.882 # Server initialized
    8325:M 04 Nov 03:37:27.883 # 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.
    8325:M 04 Nov 03:37:27.970 # 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.
    8325:M 04 Nov 03:37:27.971 * Ready to accept connections
    ^C8325:signal-handler (1509781062) Received SIGINT scheduling shutdown...
    8325:M 04 Nov 03:37:42.403 # User requested shutdown...
    8325:M 04 Nov 03:37:42.404 * Saving the final RDB snapshot before exiting.
    8325:M 04 Nov 03:37:42.410 * DB saved on disk
    8325:M 04 Nov 03:37:42.410 * Removing the pid file.
    8325:M 04 Nov 03:37:42.410 # Redis is now ready to exit, bye bye...

    注意:启动成功之后新开一SSH连接窗口,上面的窗口不能动。

    6.新开SSH连接窗口并测试:

    查看进程证明启动成功:

    qiaozhi@test:~$ ps -ef | grep  redis
    root      8505  4668  0 03:55 pts/0    00:00:01 ./bin/redis-server 127.0.0.1:6379
    qiaozhi   8523  8397  0 04:13 pts/1    00:00:00 grep --color=auto redis

    客户端进行连接:

    qiaozhi@test:~$ cd /usr/local/redis
    qiaozhi@test:/usr/local/redis$ ./bin/redis-cli
    127.0.0.1:6379> 

    7.存储数据进行测试:

    键值对存储数据:

    127.0.0.1:6379> set a hello
    OK
    127.0.0.1:6379> get a
    "hello"

    注意:安装成功之后需要开放6379端口便于在Java中操作:(远程连接)

    /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
    /etc/rc.d/init.d/iptables save
    

      如果上面第二个命令不是一个目录或文件可以替换为:

    iptables-save
    

      

  • 相关阅读:
    laydate 显示结束时间不小于开始时间
    [Draft]iOS.ObjC.Pattern.Builder-Pattern
    [Draft]iOS.Architecture.16.Truth-information-flow-and-clear-responsibilities-immutability
    iOS.ObjC.__attribute__.1-all-_attribute_-directives
    Security.ssl-pinning
    iOS.mach_msg_trap()
    iOS.redefinition-of-struct-x
    Swift.Operator-and-Items-in-Swift(1)
    iOS.Animation.Math-behind-CATransform3D
    Security.website-that-focus-on-mobile-app-security
  • 原文地址:https://www.cnblogs.com/qlqwjy/p/7783683.html
Copyright © 2011-2022 走看看