1.下載redis3.0.2redis
[root@Moxiaokai ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz ide
[root@Moxiaokai ~]# ll this
redis-3.0.2.tar.gzspa
2.解壓並編譯安裝.net
[root@Moxiaokai ~]# tar -xzf redis-3.0.2.tar.gz unix
[root@Moxiaokai ~]# ll rest
redis-3.0.2 redis-3.0.2.tar.gzserver
[root@Moxiaokai ~]# cd redis-3.0.2 blog
[root@Moxiaokai redis-3.0.2]# make進程
檢查redis是否有異常
[root@Moxiaokai redis-3.0.2]# make test
[root@Moxiaokai redis-3.0.2]# make install
在 make test時redis-3.0.2的時候可能提示錯誤:
[root@Moxiaokai redis-3.0.2]# make test
make:cc:Command not found ,make: *** [adlist.o] Error 127
這裏是因爲新安裝的Linux系統沒有安裝gcc環境,須要安裝gcc,爲了方便選擇用yum進行安裝。
[root@Moxiaokai redis-3.0.2]# yum -y install gcc
make: *** [test] Error 1
[root@Moxiaokai redis-3.0.2]# make test
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
root@Moxiaokai redis-3.0.2]#wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
root@Moxiaokai redis-3.0.2]#tar -xzvf tcl8.6.1-src.tar.gz -C /usr/local/
root@Moxiaokai redis-3.0.2]#cd /usr/local/tcl8.6.1/unix/
root@Moxiaokai redis-3.0.2]# ./configure
root@Moxiaokai redis-3.0.2]# make
root@Moxiaokai redis-3.0.2]# make install
3.運行redis
i)開啓Server進程
[root@Moxiaokai redis-3.0.2]# ./src/redis-server
24841:C 08 Nov 07:20:33.378 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
24841:M 08 Nov 07:20:33.379 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.2 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 24841
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
24841:M 08 Nov 07:20:33.381 # Server started, Redis version 3.0.2
24841:M 08 Nov 07:20:33.383 # 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.
24841:M 08 Nov 07:20:33.383 # 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.
24841:M 08 Nov 07:20:33.384 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
24841:M 08 Nov 07:20:33.384 * The server is now ready to accept connections on port 6379
ii)關閉Server進程
[root@Moxiaokai redis-3.0.2]#./redis-cli shutdown
登入客戶端進行關閉:
[root@Moxiaokai redis-3.0.2]#./redis-cli
127.0.0.1:6379> shutdown
not connected>
4.程序驗證:
[root@vstar75 src]# ./redis-cli
127.0.0.1:6379> set MyName 'Moxiaokia'
OK
127.0.0.1:6379> get MyName
"Moxiaokia"
127.0.0.1:6379>
5.啓動參數方式啓動Serverredis.conf
[root@Moxiaokai redis-3.0.2]# ./src/redis-server redis.conf
6.將 Redis 做爲 Linux 服務隨機啓動
[root@Moxiaokai redis-3.0.2]#vi /etc/rc.local
加入:
/root/install/redis-3.0.2/src/redis-server