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成功。

相關文章
相關標籤/搜索