linux redis-4.0.11安裝記錄

一,下載及安裝

   redis 官網下載地址 https://redis.io/download

我的redis安裝目錄是/data/program/redis-4.0.11
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
安裝過程可能出現的問題:
  1. linux 中沒有安裝gcc包,通過下面命令安裝: 
  $ yum -y install gcc
  
  2.make時報如下錯誤:
    zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
    原因是jemalloc重載了Linux下的ANSI C的malloc和free函數。解決辦法:make時添加參數。
  $ make MALLOC=libc

啓動服務

[root@localhost src]# ./redis-server 
10558:C 15 Oct 14:10:40.927 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10558:C 15 Oct 14:10:40.927 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=10558, just started
10558:C 15 Oct 14:10:40.927 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
10558:M 15 Oct 14:10:40.931 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.11 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10558
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10558:M 15 Oct 14:10:40.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10558:M 15 Oct 14:10:40.935 # Server initialized
10558:M 15 Oct 14:10:40.935 # 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.
10558:M 15 Oct 14:10:40.936 * Ready to accept connections
 

二,修改配置

表示安裝成功. redis 的進程id爲 10558,端口爲 6379.
但是這樣啓動不是很方便,啓動服務端的窗口不能關閉,一旦關閉服務自動停止...
修改 reids.conf 文件
將daemonize參數的值由no改爲yes,系統默認是no.保存退出,指定配置文件啓動

$  ./redis-server redis.conf

三,配置全局命令

創建redis的命令目錄
$ mkdir /data/program/redis-4.0.11/bin
將腳本目錄複製到命令目錄中
$ cp redis-cli redis-server redis-sentinel redis-check-aof redis-benchmark /data/program/redis-4.0.11/bin/
配置環境變量
$ vim /etc/profile (在文件末尾加入)
export PATH=$PATH:/data/program/redis-4.0.11/bin

$ source /etc/profile   (使環境變量生效)

$ redis-server  (任意目錄下都可以使用該命令啓動)

 

 

   

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章