Centos7安裝redis

  1. 進(jìn)入redis官網(wǎng)下載要安裝的redis壓縮包并上傳到linux服務(wù)器
  2. 解壓redis壓縮包
    tar -zxvf redis-3.2.11.tar.gz
  3. 進(jìn)入解壓縮后的文件
[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. 執(zhí)行make命令
    [root@centos-linux redis-3.2.11]# make
  2. 開(kāi)始安裝redis
    PREFIX就是指定要安裝到哪個(gè)位置,這里我就直接安裝到redis解壓縮后的文件夾下了。
    安裝完之后執(zhí)行l(wèi)l命令會(huì)發(fā)現(xiàn)這個(gè)文件夾中多了一個(gè)bin文件夾。
[root@centos-linux redis-3.2.11]# make PREFIX=/home/demo/redis-3.2.11 install
cd src && make install
make[1]: 進(jìn)入目錄“/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]: 離開(kāi)目錄“/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. 進(jìn)入bin文件夾下會(huì)發(fā)現(xiàn)這里都是一些可執(zhí)行文件
[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. 指定使用我們拷貝的配置文件來(lái)啟動(dòng)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啟動(dòng)成功

  1. 接下來(lái)我們進(jìn)行一下測(cè)試
    我們復(fù)制一個(gè)窗口
[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> 
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容