您的位置:首页 > 数据库 > Redis

redis的安装配置使用(一)

2012-12-05 09:06 507 查看
下载地址: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 /]# ls
bin   dev  home     lib         media  mnt  opt   redis-1.2.6         redis-2.6.6         root  selinux  sys  usr
boot  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 gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
There 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 Resolution

Dependencies Resolved

=================================================================================================================================================================================
Package                                      Arch                               Version                                             Repository                             Size
=================================================================================================================================================================================
Installing:
gcc                                          i386                               4.1.2-52.el5_8.1                                    updates                               5.2 M
Installing 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 M

Transaction Summary
=================================================================================================================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total size: 9.2 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running 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]# ls
bin  games      gcc-4.1.2.tar.gz  gcc-install  lib      redis-1.2.6         redis-2.4.14         redis-2.6.6.tar.gz  share
etc  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]# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Linux_gcc的安装.txt  Makefile  README  redis.conf  runtest  src  tests  utils
[root@localhost 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'
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
make[2]: Leaving directory `/usr/local/redis-2.4.14/deps/hiredis'
MAKE linenoise
make[2]: Entering directory `/usr/local/redis-2.4.14/deps/linenoise'
cc  -c -Wall -W -Os -g linenoise.c
cc  -c -Wall -W -Os -g example.c
cc  -Wall -W -Os -g -o linenoise_example linenoise.o example.o
make[2]: Leaving directory `/usr/local/redis-2.4.14/deps/linenoise'
MAKE jemalloc
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether compiler supports -std=gnu99... yes
checking whether compiler supports -Wall... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking size of void *... 4
checking size of int... 4
checking size of long... 4
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether __asm__ is compilable... yes
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether mremap(...MREMAP_FIXED...) is compilable... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ar... /usr/bin/ar
checking for ld... /usr/bin/ld
checking for autoconf... no
checking whether compiler supports -O3... yes
checking whether compiler supports -funroll-loops... yes
checking configured backtracing method... N/A
checking STATIC_PAGE_SHIFT... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for dlopen in -ldl... yes
checking for TLS... yes
checking for ffsl... yes
checking whether Darwin OSAtomic*() is compilable... no
checking whether Darwin OSSpin*() is compilable... no
checking for memalign... yes
checking for valloc... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc.h
config.status: creating include/jemalloc/internal/jemalloc_internal.h
config.status: creating test/jemalloc_test.h
config.status: creating config.stamp
config.status: creating include/jemalloc/jemalloc_defs.h
===============================================================================
jemalloc version   : 2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760

CC                 : gcc
CPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANT
CFLAGS             : -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops
LDFLAGS            :
LIBS               :  -lpthread -ldl
RPATH_EXTRA        :

XSLTPROC           : /usr/bin/xsltproc
XSLROOT            : /usr/share/xml/docbook/stylesheet/docbook-xsl

PREFIX             : /usr/local
BINDIR             : /usr/local/bin
INCLUDEDIR         : /usr/local/include
LIBDIR             : /usr/local/lib
DATADIR            : /usr/local/share
MANDIR             : /usr/local/share/man

srcroot            :
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            : 0
cc-silence         : 1
debug              : 0
stats              : 0
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
tiny               : 1
tcache             : 1
fill               : 0
xmalloc            : 0
sysv               : 0
swap               : 0
dss                : 0
dynamic_page_shift : 0
lazy_lock          : 1
tls                : 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.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
gcc -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.c
gcc -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.c
gcc -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.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
gcc -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
ar 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.o
make[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.o
MAKE hiredis
make[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.o
redis-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-server

Hint: 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]# ls
00-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]# ls
00-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 ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog
[root@localhost ~]# cd /usr/local
[root@localhost local]# ls
bin  games      gcc-4.1.2.tar.gz  gcc-install  lib      redis-1.2.6         redis-2.4.14         redis-2.6.6.tar.gz  share
etc  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]# ls
00-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-cli

redis 127.0.0.1:6379> set too bar
OK
redis 127.0.0.1:6379> get too
"bar"
redis 127.0.0.1:6379> shutdown
redis 127.0.0.1:6379> quit
[root@localhost redis-2.4.14]# ls
00-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-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

到此 基本已结束,下一章将采用jedis来连接redis。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: