天天看點

Centos7安裝Redis3.0.5過程記錄

  • 先更新一下系統。
[[email protected] ~]$ sudo yum update
[sudo] password for janl:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
No packages marked for update
           
  • 沒有wget,先安裝wget.
[[email protected] ~]$ sudo yum install wget
           
  • 下載下傳Redis 3.0.5 源碼壓縮包。
[[email protected] ~]$ wget http://download.redis.io/releases/redis-3.0.5.tar.gz
--2015-11-17 23:01:06--  http://download.redis.io/releases/redis-3.0.5.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1366160 (1.3M) [application/x-gzip]
Saving to: ‘redis-3.0.5.tar.gz’
100%[======================================================================================================>] 1,366,160   14.2KB/s   in 55s
2015-11-17 23:02:04 (24.3 KB/s) - ‘redis-3.0.5.tar.gz’ saved [1366160/1366160]
[[email protected] ~]$ ls
redis-3.0.5.tar.gz
           
  • 解壓源碼包。
[[email protected] ~]$ tar xvzf redis-3.0.5.tar.gz
           
  • 編譯
[[email protected] ~]$ ll
total 1340
drwxrwxr-x. 6 janl janl    4096 Oct 15 09:44 redis-3.0.5
-rw-rw-r--. 1 janl janl 1366160 Oct 15 09:48 redis-3.0.5.tar.gz
[[email protected] ~]$ cd redis-3.0.5
[[email protected] redis-3.0.5]$ ls
00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README      runtest          runtest-sentinel  src    utils
BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
[[email protected] redis-3.0.5]$ make
           
  •  排錯,沒有gcc,安裝gcc-c++ 
cd src && make all
make[1]: Entering directory `/home/janl/redis-3.0.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/home/janl/redis-3.0.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/home/janl/redis-3.0.5/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -W -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory `/home/janl/redis-3.0.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/home/janl/redis-3.0.5/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 `/home/janl/redis-3.0.5/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/home/janl/redis-3.0.5/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 `/home/janl/redis-3.0.5/src'
make: *** [all] Error 2
           
[[email protected] redis-3.0.5]$ sudo yum install gcc-c++
......
Installed:
  gcc-c++.x86_64 0:4.8.3-9.el7
Dependency Installed:
  cpp.x86_64 0:4.8.3-9.el7                      gcc.x86_64 0:4.8.3-9.el7                             glibc-devel.x86_64 0:2.17-78.el7
  glibc-headers.x86_64 0:2.17-78.el7            kernel-headers.x86_64 0:3.10.0-229.20.1.el7          libmpc.x86_64 0:1.0.1-3.el7
  libstdc++-devel.x86_64 0:4.8.3-9.el7          mpfr.x86_64 0:3.1.1-4.el7
Complete!
           
  • 排錯,清理編譯臨時檔案。
[[email protected] redis-3.0.5]$ make test
cd src && make test
make[1]: Entering directory `/home/janl/redis-3.0.5/src'
    CC adlist.o
In 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 1
make[1]: Leaving directory `/home/janl/redis-3.0.5/src'
make: *** [test] Error 2
           
[[email protected] redis-3.0.5]$ make distclean
cd src && make distclean
make[1]: Entering directory `/home/janl/redis-3.0.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/home/janl/redis-3.0.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/home/janl/redis-3.0.5/deps'
(rm -f .make-*)
make[1]: Leaving directory `/home/janl/redis-3.0.5/src'
           
  • 排錯,安裝tcl 
[[email protected] src]$ make test
......
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
           
[[email protected] src]$ sudo yum install tcl
[sudo] password for janl:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package tcl.x86_64 1:8.5.13-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================
 Package                       Arch                             Version                                    Repository                      Size
================================================================================================================================================
Installing:
 tcl                           x86_64                           1:8.5.13-4.el7                             base                           1.9 M
Transaction Summary
================================================================================================================================================
Install  1 Package
Total download size: 1.9 M
Installed size: 4.4 M
Is this ok [y/d/N]: y
Downloading packages:
tcl-8.5.13-4.el7.x86_64.rpm                                                                                              | 1.9 MB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:tcl-8.5.13-4.el7.x86_64                                                                                                    1/1
  Verifying  : 1:tcl-8.5.13-4.el7.x86_64                                                                                                    1/1
Installed:
  tcl.x86_64 1:8.5.13-4.el7
Complete!
           
[[email protected] src]$ make distclean
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[1]: Entering directory `/home/janl/redis-3.0.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[1]: Leaving directory `/home/janl/redis-3.0.5/deps'
(rm -f .make-*)
[[email protected] src]$ make
......
    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-aof
    
Hint: It's a good idea to run 'make test' ;)
           
  • 複制編譯好的檔案
[[email protected] src]$ sudo cp redis-benchmark /usr/local/bin/
[sudo] password for janl:
[[email protected] src]$ sudo cp redis-check-dump /usr/local/bin/
[[email protected] src]$ sudo cp redis-sentinel /usr/local/bin/
[[email protected] src]$ sudo cp redis-trib.rb /usr/local/bin/
[[email protected] src]$ sudo cp redis-check-aof /usr/local/bin/
[[email protected] src]$ sudo cp redis-cli /usr/local/bin/
[[email protected] src]$ sudo cp redis-server /usr/local/bin/
           
  • 建立工作目錄
[[email protected] src]$ sudo mkdir /etc/redis
[sudo] password for janl:
[[email protected] src]$ sudo mkdir /var/redis
[[email protected] src]$ sudo mkdir /var/redis/log
[[email protected] src]$ sudo mkdir /var/redis/run
[[email protected] src]$ sudo mkdir /var/redis/6379
           
  • 複制修改配置檔案
[[email protected] redis-3.0.5]$ sudo cp redis.conf /etc/redis/6379.conf
[sudo] password for janl:
[[email protected] redis-3.0.5]$ sudo vim /etc/redis/6379.conf
           
daemonize yes  介個是設定服務在背景運作
pidfile /var/redis/run/redis_6379.pid
logfile /var/redis/log/redis_6379.log
dir /var/redis/6379
           
  • 運作redis-server
[janl@svr1 ~]$ sudo /usr/local/bin/redis-server /etc/redis/6379.conf
           
  • 添加防火牆端口
[[email protected] bin]$ sudo firewall-cmd --zone=public --add-port=6379/tcp --permanent
[sudo] password for janl:
success
[[email protected] bin]$ firewall-cmd --reload
Authorization failed.
Make sure polkit agent is running or run the application as superuser.
[[email protected] bin]$ sudo firewall-cmd --reload
success
           

如果一切順利,此時redis資料庫已經可以正常工作了。

版權聲明:本文為CSDN部落客「weixin_34004750」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。

原文連結:https://blog.csdn.net/weixin_34004750/article/details/91597614