centos7 安装redis及遇到的问题

来源:互联网 发布:网络相关性 编辑:程序博客网 时间:2024/05/20 17:24

此处仅仅是为了保存处理错误的过程。

[root@leekwen ~]# cat /etc/os-releaseNAME="CentOS Linux"VERSION="7 (Core)"ID="centos"ID_LIKE="rhel fedora"VERSION_ID="7"PRETTY_NAME="CentOS Linux 7 (Core)"ANSI_COLOR="0;31"CPE_NAME="cpe:/o:centos:centos:7"HOME_URL="https://www.centos.org/"BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"CENTOS_MANTISBT_PROJECT_VERSION="7"REDHAT_SUPPORT_PRODUCT="centos"REDHAT_SUPPORT_PRODUCT_VERSION="7"[root@leekwen ~]# wget http://download.redis.io/releases/redis-3.0.0.tar.gz[root@leekwen ~]# tar zxvf redis-3.0.0.tar.gz[root@leekwen ~]# cd redis-3.0.0[root@leekwen redis-3.0.0]# ls00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  testsBUGS             deps     MANIFESTO  runtest          sentinel.conf     utilsCONTRIBUTING     INSTALL  README     runtest-cluster  src[root@leekwen redis-3.0.0]# makecd src && make allmake[1]: Entering directory `/usr/local/nodeclub/redis-3.0.0/src'    CC adlist.oIn file included from adlist.c:34:0:zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory #include <jemalloc/jemalloc.h>                               ^compilation terminated.make[1]: *** [adlist.o] Error 1make[1]: Leaving directory `/usr/local/nodeclub/redis-3.0.0/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[root@leekwen redis-3.0.0]# make MALLOC=libccd src && make allmake[1]: Entering directory `/usr/local/nodeclub/redis-3.0.0/src'    CC adlist.o    CC ae.o    CC anet.o    CC dict.o    CC redis.o    CC sds.o.........    CC latency.o    CC sparkline.o    LINK redis-servercc: error: ../deps/lua/src/liblua.a: No such file or directorymake[1]: *** [redis-server] Error 1make[1]: Leaving directory `/usr/local/nodeclub/redis-3.0.0/src'make: *** [all] Error 2[root@leekwen redis-3.0.0]# cd deps/[root@leekwen deps]# make luaMAKE luacd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL " MYLD                                                                                        FLAGS="" AR="ar rcu"make[1]: Entering directory `/usr/local/nodeclub/redis-3.0.0/deps/lua/src'cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lgc.o lgc.ccc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o llex.o llex.ccc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lmem.o lmem.ccc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lobject.o lobject.c........cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_cmsgpack.o lua_cmsgpack.ccc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_bit.o lua_bit.car rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o # DLL needs all object filesranlib liblua.acc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua.o lua.ccc -o lua  lua.o liblua.a -lmcc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o luac.o luac.ccc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o print.o print.ccc -o luac  luac.o print.o liblua.a -lmmake[1]: Leaving directory `/usr/local/nodeclub/redis-3.0.0/deps/lua/src'[root@leekwen deps]# cd ..[root@leekwen redis-3.0.0]# make MALLOC=libccd src && make allmake[1]: Entering directory `/usr/local/nodeclub/redis-3.0.0/src'    LINK redis-server    INSTALL redis-sentinel    CC redis-cli.o    LINK redis-cli    CC redis-benchmark.o    LINK redis-benchmark    CC redis-check-dump.o    LINK redis-check-dump    CC redis-check-aof.o    LINK redis-check-aofHint: It's a good idea to run 'make test' ;)make[1]: Leaving directory `/usr/local/nodeclub/redis-3.0.0/src'[root@leekwen redis-3.0.0]# make install
[root@leekwen redis-3.0.0]# vim redis.conf [root@leekwen redis-3.0.0]# cat redis.conf |grep -v "#" |grep -v "^$"daemonize yespidfile /var/run/redis.pidport 6379tcp-backlog 511timeout 0tcp-keepalive 0loglevel noticelogfile "/var/log/redis.log"databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir ./slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes[root@leekwen redis-3.0.0]# cd[root@leekwen ~]#  vi /etc/sysctl.conf+ vm.overcommit_memory=1[root@leekwen ~]# sysctl vm.overcommit_memory=1[root@leekwen ~]# vim /etc/init.d/redis[root@leekwen ~]# cat /etc/init.d/redis#!/bin/sh## redis        Startup script for Redis Server## chkconfig: - 90 10# description: Redis is an open source, advanced key-value store.## processname: redis-server# config: /etc/redis.conf# pidfile: /var/run/redis.pidREDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cliPIDFILE=/var/run/redis.pidCONF="/usr/local/redis-3.0.0/redis.conf"case "$1" in    start)        if [ -f $PIDFILE ]        then                echo "$PIDFILE exists, process is already running or crashed"        else                echo "Starting Redis server..."                $EXEC $CONF        fi        if [ "$?"="0" ]        then              echo "Redis is running..."        fi        ;;    stop)        if [ ! -f $PIDFILE ]        then                echo "$PIDFILE does not exist, process is not running"        else                PID=$(cat $PIDFILE)                echo "Stopping ..."                $REDIS_CLI -p $REDISPORT SHUTDOWN                while [ -x ${PIDFILE} ]               do                    echo "Waiting for Redis to shutdown ..."                    sleep 1                done                echo "Redis stopped"        fi        ;;   restart|force-reload)        ${0} stop        ${0} start        ;;  *)    echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2        exit 1esac查看是否存在对应的文件:[root@leekwen ~]# ls /usr/local/redis-3.0.0/redis.conf[root@leekwen ~]# ls -l /usr/local/bin/redis-server[root@leekwen ~]# ls -l /usr/local/bin/redis-cli为脚本增加可执行权限:[root@leekwen ~]# chmod 755 /etc/init.d/redis启动服务:[root@leekwen ~]# /etc/init.d/redis start

其它redis配置问题,可以自行百度,或参阅推荐的博客地址。

推荐博客地址:http://keenwon.com/1335.html

0 0