redis3.2安装过程分享

转载自我要求索网 redis3.2安装过程分享html

去 redis官网  下载对应的版本。下载地址:https://redis.io/downloadgit

centos安装redis

[root@localhost application]# tar -zvxf redis-3.2.5.tar.gzgithub

......redis

[root@localhost application]# cd redis-3.2.5windows

  • 在解压目录运行make编译

[root@localhost redis-3.2.5]# make
cd src && make all
make[1]: Entering directory `/application/redis-3.2.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/application/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/application/redis-3.2.5/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .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 -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb   -I../deps/geohash-int -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 geohash-int jemalloc)
make[2]: Entering directory `/application/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/application/redis-3.2.5/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: gcc:命令未找到
make[3]: *** [net.o] 错误 127
make[3]: Leaving directory `/application/redis-3.2.5/deps/hiredis'
make[2]: *** [hiredis] 错误 2
make[2]: Leaving directory `/application/redis-3.2.5/deps'
make[1]: [persist-settings] 错误 2 (忽略)
CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] 错误 127
make[1]: Leaving directory `/application/redis-3.2.5/src'
make: *** [all] 错误 2centos

发现报错了因为我未安装gcc,下一步安装gccapp

[root@localhost redis-3.2.5]# yum install gcc -yide

...............测试

因为输出太多 省略部分输出ui

Installed:
gcc.x86_64 0:4.4.7-17.el6

Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-17.el6 glibc-devel.x86_64 0:2.12-1.192.el6 glibc-headers.x86_64 0:2.12-1.192.el6 kernel-headers.x86_64 0:2.6.32-642.11.1.el6
libgomp.x86_64 0:4.4.7-17.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6

Dependency Updated:
glibc.x86_64 0:2.12-1.192.el6 glibc-common.x86_64 0:2.12-1.192.el6 libgcc.x86_64 0:4.4.7-17.el6 tzdata.noarch 0:2016j-1.el6

Complete!

安装完成以后,继续运行make,运行以后又发现了错误

[root@localhost redis-3.2.5]# make
cd src && make all
make[1]: Entering directory `/application/redis-3.2.5/src'
CC adlist.o
在包含自 adlist.c:34 的文件中:
zmalloc.h:50:31: 错误:jemalloc/jemalloc.h:没有那个文件或目录
zmalloc.h:55:2: 错误:#error "Newer version of jemalloc required"
make[1]: *** [adlist.o] 错误 1
make[1]: Leaving directory `/application/redis-3.2.5/src'
make: *** [all] 错误 2

查找资料后发现,解决这个问题只须要运行make MALLOC=libc 

[root@localhost redis-3.2.5]# make MALLOC=libc
cd src && make all
make[1]: Entering directory `/application/redis-3.2.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
........................
Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/application/redis-3.2.5/src'

 

  • 测试安装是否成功

启动redis服务

[root@localhost redis-3.2.5]# src/redis-server
6169:C 14 Dec 20:27:27.807 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
6169:M 14 Dec 20:27:27.809 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-``    `.  `_.  ''-._           Redis 3.2.5 (00000000/0) 64 bit
.-`` .-```.  ```\/    _.,_ ''-._
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 6169
`-._    `-._  `-./  _.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |           http://redis.io
`-._    `-._`-.__.-'_.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |
`-._    `-._`-.__.-'_.-'    _.-'
`-._    `-.__.-'    _.-'
`-._        _.-'
`-.__.-'

6169:M 14 Dec 20:27:27.812 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
6169:M 14 Dec 20:27:27.812 # Server started, Redis version 3.2.5
6169:M 14 Dec 20:27:27.812 # 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.
6169:M 14 Dec 20:27:27.812 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
6169:M 14 Dec 20:27:27.813 * The server is now ready to accept connections on port 6379

使用内置的客户端命令redis-cli进行使用:

[root@localhost redis-3.2.5]# src/redis-cli
127.0.0.1:6379> set key value
OK
127.0.0.1:6379> get key
"value"
127.0.0.1:6379>

至此,centOS安装redis成功,为了之后运行命令没必要每次进入安装目录,也能够把src绝对目录加入到PATH环境变量。

windows安装redis

Redis 没有官方的Windows版本,可是微软开源技术团队(Microsoft Open Tech group)开发和维护着这个 Win64 的版本。

window发布版本列表地址

https://github.com/MSOpenTech/redis/releases

下载Redis-x64-3.2.100.msi

双击msi文件安装,点击next勾选赞成协议,再点击next,选择自定义安装目录,也能够勾选上吧安装目录添加到PATH环境变量,

而后一路下一步,其中还包含有修改默认端口,设置内存最大 限制等可自定义。最后点击install安装。

打开cmd命令行进入安装目录运行redis-server.exe redis.windows.conf

C:\Program Files\Redis>redis-server.exe redis.windows.conf
_._
_.-``__ ''-._
_.-``    `.  `_.  ''-._           Redis 3.2.100 (00000000/0) 64 bit
.-`` .-```.  ```\/    _.,_ ''-._
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 4292
`-._    `-._  `-./  _.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |           http://redis.io
`-._    `-._`-.__.-'_.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |
`-._    `-._`-.__.-'_.-'    _.-'
`-._    `-.__.-'    _.-'
`-._        _.-'
`-.__.-'

[4292] 26 Dec 17:28:35.496 # Server started, Redis version 3.2.100
[4292] 26 Dec 17:28:35.496 * The server is now ready to accept connections on port 6379

打开另外一个cmd命令

C:\Program Files\Redis>redis-cli.exe
127.0.0.1:6379> set key value
OK
127.0.0.1:6379> get key
"value"
127.0.0.1:6379>

至此,window安装redis成功。

相关文章
相关标签/搜索