Centos7安装redis

  1. 进入redis官网下载要安装的redis压缩包并上传到linux服务器
  2. 解压redis压缩包
    tar -zxvf redis-3.2.11.tar.gz
  3. 进入解压缩后的文件
[root@centos-linux redis-3.2.11]# ll
总用量 212
-rw-rw-r--.  1 root root 92766 9月  21 2017 00-RELEASENOTES
-rw-rw-r--.  1 root root    53 9月  21 2017 BUGS
-rw-rw-r--.  1 root root  1805 9月  21 2017 CONTRIBUTING
-rw-rw-r--.  1 root root  1487 9月  21 2017 COPYING
drwxrwxr-x.  7 root root  4096 9月  21 2017 deps
-rw-rw-r--.  1 root root    11 9月  21 2017 INSTALL
-rw-rw-r--.  1 root root   151 9月  21 2017 Makefile
-rw-rw-r--.  1 root root  4223 9月  21 2017 MANIFESTO
-rw-rw-r--.  1 root root  6834 9月  21 2017 README.md
-rw-rw-r--.  1 root root 46695 9月  21 2017 redis.conf
-rwxrwxr-x.  1 root root   271 9月  21 2017 runtest
-rwxrwxr-x.  1 root root   280 9月  21 2017 runtest-cluster
-rwxrwxr-x.  1 root root   281 9月  21 2017 runtest-sentinel
-rw-rw-r--.  1 root root  7606 9月  21 2017 sentinel.conf
drwxrwxr-x.  2 root root  4096 9月  21 2017 src
drwxrwxr-x. 10 root root  4096 9月  21 2017 tests
drwxrwxr-x.  7 root root  4096 9月  21 2017 utils
  1. 执行make命令
    [root@centos-linux redis-3.2.11]# make
  2. 开始安装redis
    PREFIX就是指定要安装到哪个位置,这里我就直接安装到redis解压缩后的文件夹下了。
    安装完之后执行ll命令会发现这个文件夹中多了一个bin文件夹。
[root@centos-linux redis-3.2.11]# make PREFIX=/home/demo/redis-3.2.11 install
cd src && make install
make[1]: 进入目录“/home/demo/redis-3.2.11/src”

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: 离开目录“/home/demo/redis-3.2.11/src”
[root@centos-linux redis-3.2.11]# ll
总用量 216
-rw-rw-r--.  1 root root 92766 9月  21 2017 00-RELEASENOTES
drwxr-xr-x.  2 root root  4096 6月   4 11:57 bin
-rw-rw-r--.  1 root root    53 9月  21 2017 BUGS
-rw-rw-r--.  1 root root  1805 9月  21 2017 CONTRIBUTING
-rw-rw-r--.  1 root root  1487 9月  21 2017 COPYING
drwxrwxr-x.  7 root root  4096 6月   4 11:51 deps
-rw-rw-r--.  1 root root    11 9月  21 2017 INSTALL
-rw-rw-r--.  1 root root   151 9月  21 2017 Makefile
-rw-rw-r--.  1 root root  4223 9月  21 2017 MANIFESTO
-rw-rw-r--.  1 root root  6834 9月  21 2017 README.md
-rw-rw-r--.  1 root root 46695 9月  21 2017 redis.conf
-rwxrwxr-x.  1 root root   271 9月  21 2017 runtest
-rwxrwxr-x.  1 root root   280 9月  21 2017 runtest-cluster
-rwxrwxr-x.  1 root root   281 9月  21 2017 runtest-sentinel
-rw-rw-r--.  1 root root  7606 9月  21 2017 sentinel.conf
drwxrwxr-x.  2 root root  4096 6月   4 11:52 src
drwxrwxr-x. 10 root root  4096 9月  21 2017 tests
drwxrwxr-x.  7 root root  4096 9月  21 2017 utils
[root@centos-linux redis-3.2.11]# 
  1. 进入bin文件夹下会发现这里都是一些可执行文件
[root@centos-linux redis-3.2.11]# cd bin
[root@centos-linux bin]# ll
总用量 15076
-rwxr-xr-x. 1 root root 2432160 6月   4 11:57 redis-benchmark
-rwxr-xr-x. 1 root root   25080 6月   4 11:57 redis-check-aof
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-check-rdb
-rwxr-xr-x. 1 root root 2584960 6月   4 11:57 redis-cli
lrwxrwxrwx. 1 root root      12 6月   4 11:57 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-server
[root@centos-linux bin]# 
  1. 我们可以找到redis的配置文件并拷贝一份到我们的bin文件夹下
[root@centos-linux bin]# cp /home/demo/redis-3.2.11/redis.conf /home/demo/redis-3.2.11/bin/
[root@centos-linux bin]# ll
总用量 15124
-rwxr-xr-x. 1 root root 2432160 6月   4 11:57 redis-benchmark
-rwxr-xr-x. 1 root root   25080 6月   4 11:57 redis-check-aof
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-check-rdb
-rwxr-xr-x. 1 root root 2584960 6月   4 11:57 redis-cli
-rw-r--r--. 1 root root   46695 6月   4 12:09 redis.conf
lrwxrwxrwx. 1 root root      12 6月   4 11:57 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-server
[root@centos-linux bin]#
  1. 指定使用我们拷贝的配置文件来启动redis
[root@centos-linux bin]# ./redis-server ./redis.conf
8164:M 04 Jun 12:11:38.259 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.11 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 8164
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

8164:M 04 Jun 12:11:38.262 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8164:M 04 Jun 12:11:38.262 # Server started, Redis version 3.2.11
8164:M 04 Jun 12:11:38.262 # 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.
8164:M 04 Jun 12:11:38.262 # 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.
8164:M 04 Jun 12:11:38.262 * The server is now ready to accept connections on port 6379

ok启动成功

  1. 接下来我们进行一下测试
    我们复制一个窗口
[root@centos-linux /]# cd /home/demo/redis-3.2.11/bin
[root@centos-linux bin]# ll
总用量 15124
-rwxr-xr-x. 1 root root 2432160 6月   4 11:57 redis-benchmark
-rwxr-xr-x. 1 root root   25080 6月   4 11:57 redis-check-aof
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-check-rdb
-rwxr-xr-x. 1 root root 2584960 6月   4 11:57 redis-cli
-rw-r--r--. 1 root root   46695 6月   4 12:09 redis.conf
lrwxrwxrwx. 1 root root      12 6月   4 11:57 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5189792 6月   4 11:57 redis-server
[root@centos-linux bin]# ./redis-cli 
127.0.0.1:6379> set key1 hello
OK
127.0.0.1:6379> get key1
"hello"
127.0.0.1:6379> 

你可能感兴趣的:(Centos7安装redis)