1.依赖包安装 yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make gcc-c++ libstdc++-devel tcl 2.安装包准备 官网https://redis.io下载最新版redis wget http://download.redis.io/releases/redis-4.0.14.tar.gz tar -zxvf redis-5.0.14.tar.gz 3.编译安装 mv redis-5.0.14 redis cd redis make make install 如遇到:zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory make MALLOC=libc make install 4.创建目录,修改配置文件,启动redis 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文件目录及文件名 requirepass aytxtt589 修改redis密码 其他参数在生产环境中可适当调整 5.启动redis,在redis6379目录下 redis-server redis.conf 登录 redis-cli -h 127.0.0.1 -c -p 6379 验证密码 auth shimujiuxia 注: 1)如果未安装依赖包,将有如下错误 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 处理方法即按第一步,安装依赖包即可 2)make过程中出现如下错误时 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 即可 3)重要提示 因redis通常不设密码,且出现过通过6379端口突破主机后被挖矿等或进行恶意攻击等情况,所以不建议使用root账号启动redis 因此,建议创建redis单独的账号,并用该普通账号启动redis 原文地址:https://www.cnblogs.com/gjc592/p/11098047.html
标签:14,redis5,local,make,redis,62,directory,安装,4.0 From: https://www.cnblogs.com/leiuk/p/17807062.html