1. 依賴包安裝c++
yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make gcc-c++ libstdc++-devel tcl
2. 安裝包準備redis
能夠從官網 https://redis.io下載最新版redisvim
wget http://download.redis.io/releases/redis-4.0.14.tar.gz tar -zxvf redis-4.0.14.tar.gz
3. 編譯、安裝微信
cd redis-4.0.14 make
make install
4. 建立目錄、修改配置文件、啓動redisui
建議建立單獨的redis目錄lua
# 建立目錄 mkdir -p /data/redis/redis6379 # 拷貝配置文件 cp redis.conf /data/redis/redis6379/ # 修改配置文件 vim redis.conf 修改以下部分 bind 0.0.0.0 能夠指定全部地址都可訪問,若指定對應網段或IP 修改此處便可 daemonize yes 放在後臺執行,建議修改成yes pidfile /data/redis/redis6379/redis_6379.pid 指定pid文件目錄及文件名 logfile "/data/redis/redis6379/redis6379.log" 指定log文件目錄及文件名
# 其餘參數在生產環境中可適當調整
# 啓動redis
redis-server redis.conf
注:spa
a) 若是未安裝依賴包,將有以下錯誤prototype
MAKE hiredis cd hiredis && make static make[3]: Entering directory `/usr/local/redis-4.0.14/deps/hiredis' gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c make[3]: gcc: Command not found make[3]: *** [net.o] Error 127 make[3]: Leaving directory `/usr/local/redis-4.0.14/deps/hiredis' make[2]: *** [hiredis] Error 2 make[2]: Leaving directory `/usr/local/redis-4.0.14/deps' make[1]: [persist-settings] Error 2 (ignored) CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/usr/local/redis-4.0.14/src' make: *** [all] Error 2
處理方法即按第一步 安裝依賴包便可code
2) make過程當中出現以下錯誤時server
cd src && make all make[1]: Entering directory `/usr/local/redis-4.0.14/src' CC Makefile.dep make[1]: Leaving directory `/usr/local/redis-4.0.14/src' make[1]: Entering directory `/usr/local/redis-4.0.14/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.14/src' make: *** [all] Error 2
處理方法:
cd deps/ make hiredis jemalloc linenoise lua geohash-int
以後再進行make && make install 便可
c) 重要提示
因redis一般不設密碼,且出現過經過6379端口突破主機後被挖礦等或進行惡意攻擊等狀況,因此不建議使用root帳號啓動redis
所以 建議建立redis單獨的帳號 並用該普通帳號啓動redis
耿小廚已開通我的微信公衆號,想進一步溝通或想了解其餘文章的同窗能夠關注我