Centos7 安裝Redis,報錯[adlist.o] Error jemalloc/jemalloc.h: No such file or directory


redis官網

https://redis.io/download

安裝

$ wget http://download.redis.io/releases/redis-5.0.4.tar.gz
$ tar xzf redis-5.0.4.tar.gz
$ cd redis-5.0.4
$ make

啟動

src/redis-server

make時候可能報錯

xx command not found

CentOS7默認沒有安裝gcc,這會導致我們無法make成功。使用yum安裝:

yum -y install gcc

error: jemalloc/jemalloc.h: No such file or directory

原因是jemalloc重載了Linux下的ANSI C的malloc和free函數。解決辦法:make時添加參數。

make MALLOC=libc

make之后,會出現一句Hint提示

Hint: To run 'make test' is a good idea ;)
但是不測試,通常是可以使用的。若我們運行make test ,會有如下提示

$ make test
You need tcl 8.5 or newer in order to run the Redis test
make: ***[test] Error_1

解決辦法是用yum安裝tcl8.5(或去tcl的官方網站http://www.tcl.tk/下載8.5版本,並參考官網介紹進行安裝)

yum install tcl

安裝完之后再次執行測試

$ make test
.......
\o/ All tests passed without errors!

Cleanup: may take some time... OK
make[1]: Leaving directory `/usr/local/redis-5.0.4/src'

redis設置密碼

臨時生效

# ./redis-cli 
127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379> 

永久生效

需更改redis.conf配置文件
requirepass passwoord
重啟redis后生效


免責聲明!

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



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