redis的安装配置使用(一)

来源:互联网 发布:淘宝手机端链接 编辑:程序博客网 时间:2024/06/06 01:37

下载地址:http://redis.io/download

下载文件:redis-2.4.14.tar.gz

官方教程:http://redis.io/topics/quickstart

 

关于redis.conf文件里面信息内容请访问:http://ericer.blog.163.com/blog/static/17385417620119811162774/

 

解压:

root@ubuntu:/usr/local# tar -zxvf redis-2.4.14.tar.gz

 

进行redis-2.4.14进行安装

root@ubuntu:/usr/local# cd redis-2.4.14/

root@ubuntu:/usr/local/redis-2.4.14# make

cd src && make all

make[1]: Entering directory `/usr/local/redis-2.4.14/src'

MAKE hiredis

make[2]: Entering directory `/usr/local/redis-2.4.14/deps/hiredis'

gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c

make[2]: gcc: Command not found

make[2]: *** [net.o] Error 127

make[2]: Leaving directory `/usr/local/redis-2.4.14/deps/hiredis'

make[1]: *** [dependencies] Error 2

make[1]: Leaving directory `/usr/local/redis-2.4.14/src'

make: *** [all] Error 2

未安装gcc编译工具

 

当时出现这个问题 我也在网上搜了很多都未能解决,我最后是在linux里面更新一下软件并安装,然后重启linux服务

然后执行

[root@localhost /]# lsbin   dev  home     lib         media  mnt  opt   redis-1.2.6         redis-2.6.6         root  selinux  sys  usrboot  etc  install  lost+found  misc   net  proc  redis-1.2.6.tar.gz  redis-2.6.6.tar.gz  sbin  srv      tmp  var[root@localhost /]# yum install gccLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.comSetting up Install ProcessResolving DependenciesThere are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.The program yum-complete-transaction is found in the yum-utils package.--> Running transaction check---> Package gcc.i386 0:4.1.2-52.el5_8.1 set to be updated--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc--> Running transaction check---> Package glibc-devel.i386 0:2.5-81.el5_8.7 set to be updated--> Processing Dependency: glibc-headers = 2.5-81.el5_8.7 for package: glibc-devel--> Processing Dependency: glibc-headers for package: glibc-devel--> Running transaction check---> Package glibc-headers.i386 0:2.5-81.el5_8.7 set to be updated--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers--> Processing Dependency: kernel-headers for package: glibc-headers--> Running transaction check---> Package kernel-headers.i386 0:2.6.18-308.20.1.el5 set to be updated--> Finished Dependency ResolutionDependencies Resolved================================================================================================================================================================================= Package                                      Arch                               Version                                             Repository                             Size=================================================================================================================================================================================Installing: gcc                                          i386                               4.1.2-52.el5_8.1                                    updates                               5.2 MInstalling for dependencies: glibc-devel                                  i386                               2.5-81.el5_8.7                                      updates                               2.1 M glibc-headers                                i386                               2.5-81.el5_8.7                                      updates                               607 k kernel-headers                               i386                               2.6.18-308.20.1.el5                                 updates                               1.3 MTransaction Summary=================================================================================================================================================================================Install       4 Package(s)Upgrade       0 Package(s)Total size: 9.2 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction  Installing     : kernel-headers                                                                                                                                            1/4   Installing     : glibc-headers                                                                                                                                             2/4   Installing     : glibc-devel                                                                                                                                               3/4   Installing     : gcc                                                                                                                                                       4/4 Installed:  gcc.i386 0:4.1.2-52.el5_8.1                                                                                                                                                    Dependency Installed:  glibc-devel.i386 0:2.5-81.el5_8.7                      glibc-headers.i386 0:2.5-81.el5_8.7                      kernel-headers.i386 0:2.6.18-308.20.1.el5                     Complete!


这样gcc也可以使用了 然后我就进入我安装的redis-2.4.14 目录

并且安装也成功了,然后也启动了redis的服务。 然后又启动redis的客户端进行测试

[root@localhost /]# cd usr/local[root@localhost local]# lsbin  games      gcc-4.1.2.tar.gz  gcc-install  lib      redis-1.2.6         redis-2.4.14         redis-2.6.6.tar.gz  shareetc  gcc-4.1.2  gcc-build         include      libexec  redis-1.2.6.tar.gz  redis-2.4.14.tar.gz  sbin                src[root@localhost local]# cd redis-2.4.14[root@localhost redis-2.4.14]# ls00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils[root@localhost redis-2.4.14]# makecd src && make allmake[1]: Entering directory `/usr/local/redis-2.4.14/src'MAKE hiredismake[2]: Entering directory `/usr/local/redis-2.4.14/deps/hiredis'cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.ccc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.ccc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.ccc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.car rcs libhiredis.a net.o hiredis.o sds.o async.omake[2]: Leaving directory `/usr/local/redis-2.4.14/deps/hiredis'MAKE linenoisemake[2]: Entering directory `/usr/local/redis-2.4.14/deps/linenoise'cc  -c -Wall -W -Os -g linenoise.ccc  -c -Wall -W -Os -g example.ccc  -Wall -W -Os -g -o linenoise_example linenoise.o example.omake[2]: Leaving directory `/usr/local/redis-2.4.14/deps/linenoise'MAKE jemallocchecking for xsltproc... /usr/bin/xsltprocchecking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables... checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking whether compiler supports -std=gnu99... yeschecking whether compiler supports -Wall... yeschecking whether compiler supports -pipe... yeschecking whether compiler supports -g3... yeschecking how to run the C preprocessor... gcc -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking size of void *... 4checking size of int... 4checking size of long... 4checking build system type... i686-pc-linux-gnuchecking host system type... i686-pc-linux-gnuchecking whether __asm__ is compilable... yeschecking whether __attribute__ syntax is compilable... yeschecking whether compiler supports -fvisibility=hidden... yeschecking whether mremap(...MREMAP_FIXED...) is compilable... yeschecking for a BSD-compatible install... /usr/bin/install -cchecking for ranlib... ranlibchecking for ar... /usr/bin/archecking for ld... /usr/bin/ldchecking for autoconf... nochecking whether compiler supports -O3... yeschecking whether compiler supports -funroll-loops... yeschecking configured backtracing method... N/Achecking STATIC_PAGE_SHIFT... 12checking pthread.h usability... yeschecking pthread.h presence... yeschecking for pthread.h... yeschecking for pthread_create in -lpthread... yeschecking dlfcn.h usability... yeschecking dlfcn.h presence... yeschecking for dlfcn.h... yeschecking for dlopen in -ldl... yeschecking for TLS... yeschecking for ffsl... yeschecking whether Darwin OSAtomic*() is compilable... nochecking whether Darwin OSSpin*() is compilable... nochecking for memalign... yeschecking for valloc... yeschecking for stdbool.h that conforms to C99... yeschecking for _Bool... yesconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating doc/html.xslconfig.status: creating doc/manpages.xslconfig.status: creating doc/jemalloc.xmlconfig.status: creating include/jemalloc/jemalloc.hconfig.status: creating include/jemalloc/internal/jemalloc_internal.hconfig.status: creating test/jemalloc_test.hconfig.status: creating config.stampconfig.status: creating include/jemalloc/jemalloc_defs.h===============================================================================jemalloc version   : 2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760CC                 : gccCPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANTCFLAGS             : -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loopsLDFLAGS            : LIBS               :  -lpthread -ldlRPATH_EXTRA        : XSLTPROC           : /usr/bin/xsltprocXSLROOT            : /usr/share/xml/docbook/stylesheet/docbook-xslPREFIX             : /usr/localBINDIR             : /usr/local/binINCLUDEDIR         : /usr/local/includeLIBDIR             : /usr/local/libDATADIR            : /usr/local/shareMANDIR             : /usr/local/share/mansrcroot            : abs_srcroot        : /usr/local/redis-2.4.14/deps/jemalloc/objroot            : abs_objroot        : /usr/local/redis-2.4.14/deps/jemalloc/JEMALLOC_PREFIX    : je_JEMALLOC_PRIVATE_NAMESPACE                   : install_suffix     : autogen            : 0cc-silence         : 1debug              : 0stats              : 0prof               : 0prof-libunwind     : 0prof-libgcc        : 0prof-gcc           : 0tiny               : 1tcache             : 1fill               : 0xmalloc            : 0sysv               : 0swap               : 0dss                : 0dynamic_page_shift : 0lazy_lock          : 1tls                : 1===============================================================================make[2]: Entering directory `/usr/local/redis-2.4.14/deps/jemalloc'gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_swap.o src/chunk_swap.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.cgcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.car crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/chunk_swap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/prof.o src/rtree.o src/stats.o src/tcache.omake[2]: Leaving directory `/usr/local/redis-2.4.14/deps/jemalloc'    CC ae.o    CC anet.o    CC redis-benchmark.o    CC sds.o    CC adlist.o    CC zmalloc.oMAKE hiredismake[2]: Entering directory `/usr/local/redis-2.4.14/deps/hiredis'make[2]: Nothing to be done for `static'.make[2]: Leaving directory `/usr/local/redis-2.4.14/deps/hiredis'    LINK redis-benchmark    CC redis-cli.oredis-cli.c: In function ‘pipeMode’:redis-cli.c:898: 警告:隐式声明函数 ‘time’redis-cli.c:932: 警告:提领类型双关的指针将破坏强重叠规则    CC release.o    LINK redis-cli    CC redis-check-dump.o    CC lzf_c.o    CC lzf_d.o    LINK redis-check-dump    CC redis-check-aof.o    LINK redis-check-aof    CC dict.o    CC redis.o    CC pqsort.o    CC zipmap.o    CC sha1.o    CC ziplist.o    CC networking.o    CC util.o    CC object.o    CC db.o    CC replication.o    CC rdb.o    CC t_string.o    CC t_list.o    CC t_set.o    CC t_zset.o    CC t_hash.o    CC config.o    CC aof.o    CC vm.o    CC pubsub.o    CC multi.o    CC debug.o    CC sort.o    CC intset.o    CC syncio.o    CC slowlog.o    CC bio.o    CC memtest.o    LINK redis-serverHint: To run 'make test' is a good idea ;)

 

redis服务启动部分:

make[1]: Leaving directory `/usr/local/redis-2.4.14/src'[root@localhost redis-2.4.14]# ls00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils[root@localhost redis-2.4.14]# ./redis-server redis.conf-bash: ./redis-server: 没有那个文件或目录[root@localhost redis-2.4.14]# [root@localhost redis-2.4.14]# ./redis.conf-bash: ./redis.conf: 权限不够[root@localhost redis-2.4.14]# ls00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils[root@localhost redis-2.4.14]#  ./src/redis-server[5219] 05 Dec 08:59:23 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'[5219] 05 Dec 08:59:23 # Warning: 32 bit instance detected but no memory limit set. Setting 3.5 GB maxmemory limit with 'noeviction' policy now.[5219] 05 Dec 08:59:23 * Server started, Redis version 2.4.14[5219] 05 Dec 08:59:23 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.[5219] 05 Dec 08:59:23 * The server is now ready to accept connections on port 6379[5219] 05 Dec 08:59:24 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:29 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:34 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:39 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:44 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:49 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:54 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 08:59:59 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:04 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:09 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:14 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:19 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:24 - 0 clients connected (0 slaves), 547464 bytes in use[5219] 05 Dec 09:00:30 - 0 clients connected (0 slaves), 547464 bytes in use


 

 


redis客户端测试部分:

Last login: Wed Dec  5 08:43:28 2012 from 192.168.0.137[root@localhost ~]# lsanaconda-ks.cfg  Desktop  install.log  install.log.syslog[root@localhost ~]# cd /usr/local[root@localhost local]# lsbin  games      gcc-4.1.2.tar.gz  gcc-install  lib      redis-1.2.6         redis-2.4.14         redis-2.6.6.tar.gz  shareetc  gcc-4.1.2  gcc-build         include      libexec  redis-1.2.6.tar.gz  redis-2.4.14.tar.gz  sbin                src[root@localhost local]# cd redis-2.4.14[root@localhost redis-2.4.14]# ls00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils[root@localhost redis-2.4.14]# ./src/redis-cliredis 127.0.0.1:6379> set too barOKredis 127.0.0.1:6379> get too"bar"redis 127.0.0.1:6379> shutdownredis 127.0.0.1:6379> quit[root@localhost redis-2.4.14]# ls00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  dump.rdb  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils[root@localhost redis-2.4.14]# ./src/redis-cliCould not connect to Redis at 127.0.0.1:6379: Connection refusednot connected> 


到此 基本已结束,下一章将采用jedis来连接redis。