centos7安裝redis

來源:互聯網
上載者:User

標籤:

方法一:使用命令安裝(前提是已經安裝了EPEL)。
 
安裝redis:
 
yum -y install redis
 
啟動/停止/重啟 Redis
 啟動服務:
 1
 systemctl start redis.service
 停止服務:
 
systemctl stop redis.service
 
重啟服務:
 

systemctl restart redis.service
 
檢查狀態:
 

[[email protected] ~]# systemctl status redis.service
 redis.service - Redis persistent key-value database
    Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled)
    Active: active (running) since 二 2014-10-21 21:37:22 EDT; 5h 26min ago
  Main PID: 30413 (redis-server)
    CGroup: /system.slice/redis.service
            └─30413 /usr/bin/redis-server 127.0.0.1:6379
 
 10月 21 21:37:22 idoseek.com systemd[1]: Started Redis persistent key-value database.
 
隨系統啟動服務:
 

[[email protected] ~]# systemctl enable redis.service
 ln -s ‘/usr/lib/systemd/system/redis.service‘ ‘/etc/systemd/system/multi-user.target.wants/redis.service‘
 
關閉隨機啟動:
 

[[email protected] ~]# systemctl disable redis.service
 rm ‘/etc/systemd/system/mult(www.111cn.net)i-user.target.wants/redis.service‘
 
方法二:編譯安裝
 
下載安裝編譯:
 

# wget http://download.redis.io/releases/redis-2.8.17.tar.gz
 # tar xzf redis-2.8.17.tar.gz
 # cd redis-2.8.17
 # make
 # make install
 
設定設定檔路徑:
 

# mkdir -p /etc/redis && cp redis.conf /etc/redis
 
修改設定檔:
 

# vim /etc/redis/redis.conf
 修改為: daemonize yes
 啟動Redis:
 

# /usr/local/bin/redis-server /etc/redis/redis.conf
 #關閉服務
 

redis-cli shutdown
 
或者在cli中執行shutdown
 

redis 127.0.0.1:6379> shutdown
 
清除緩衝
 

redis-cli flushall
 
更多文檔請參考軟體包內的“README”檔案。
 查看狀態 :
 
# ss -nlp|grep redis
 
或者
 
# ps -ef | grep redis
 
下面介紹為PHP添加redis外掛程式。
 
從官網下載最新的拓展,地址:http://pecl.php.net/package/redis或者https://github.com/phpredis/phpredis
 
#wget http://pecl.php.net/get/redis-2.2.5.tgz
 #phpize
 #./configure --prefix=/opt/redis --enable-redis --with-php-config=/opt/php/bin/php-config
 #make && make install
 
把拓展添加至php.ini,重啟php-fpm:
 
service php-fpm restart
from:http://www.111cn.net/sys/CentOS/85292.htm

 

 

錯誤描述

安裝Redis 2.8.18時報錯:

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src‘
make: *** [all] Error 2

原因分析

在README 有這個一段話。

Allocator  
---------  

Selecting a non-default memory allocator when building Redis is done by setting  
the `MALLOC` environment variable. Redis is compiled and linked against libc  
malloc by default, with the exception of jemalloc being the default on Linux  
systems. This default was picked because jemalloc has proven to have fewer  
fragmentation problems than libc malloc.  

To force compiling against libc malloc, use:  

% make MALLOC=libc  

To compile against jemalloc on Mac OS X systems, use:  

% make MALLOC=jemalloc


說關於分配器allocator, 如果有MALLOC  這個 環境變數, 會有用這個環境變數的 去建立Redis。

而且libc 並不是預設的 分配器, 預設的是 jemalloc, 因為 jemalloc 被證明 有更少的 fragmentation problems 比libc。

但是如果你又沒有jemalloc 而只有 libc 當然 make 出錯。 所以加這麼一個參數。

解決辦法

make MALLOC=libc

centos7安裝redis

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.