CentOS7下安裝Redis5.0.2


1、下載redis 地址 http://download.redis.io/releases/redis-5.0.2.tar.gz

2、解壓tar -zxf redis-5.0.2.tar.gz

3、缺少gcc環境需要yum install gcc -y

3.1 make編譯

3.2 報錯:

[root@lang redis-5.0.2]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis-4.0.10/src'
    CC adlist.o
In file included from adlist.c:34:
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 `/usr/local/redis-4.0.10/src'
make: *** [all] Error 2

redis解壓目錄下有個README.md文件中有如下一段話:

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

4、編譯加上MALLOC=libc 即可

   #make MALLOC=libc

5、運行redis

 

修改配置文件 redis.conf

daemonize no 改為 yes 后台運行:

protected-mode yes 改為no 可以不用輸入密碼登陸

daemonize yes 改為no

requirepass "xiaoqi@Redis" 這里可以設置自己想要設置的密碼/默認是加#的,去掉即可

bind 127.0.0.1  表示只可以本機訪問,要是遠程訪問需要注釋掉(前面加#號即可)

6、帶配置文件后台啟動

[root@lang redis-5.0.2]# src/redis-server redis.conf 
7897:C 06 Dec 2018 06:25:57.484 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
7897:C 06 Dec 2018 06:25:57.484 # Redis version=5.0.2, bits=64, commit=00000000, modified=0, pid=7897, just started
7897:C 06 Dec 2018 06:25:57.484 # Configuration loaded
[root@lang redis-5.0.2]# ps -ef | grep redis
root       7898      1  4 06:25 ?        00:00:00 src/redis-server *:6379    
root       7903   2880  0 06:25 pts/1    00:00:00 grep redis
[root@lang redis-5.0.2]#src/redis-clt 127.0.0.1 #可以測試是否可以本地進入redis


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM