Linux-CentOS下redis安装

Linux-CentOS下redis安装

1.下载

[root@localhost test]# wget http://download.redis.io/releases/redis-2.8.17.tar.gz
--2016-05-16 17:58:57-- http://download.redis.io/releases/redis-2.8.17.tar.gz
Resolving download.redis.io... 109.74.203.151
Connecting to download.redis.io|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1234543 (1.2M) [application/x-gzip]
Saving to: “redis-2.8.17.tar.gz”

100%[======================================>] 1,234,543 205K/s in 5.9s

2016-05-16 17:59:04 (204 KB/s) - “redis-2.8.17.tar.gz” saved [1234543/1234543]

2.解压

[root@localhost test]# tar xzf redis-2.8.17.tar.gz

3.移到要安装的目录下(这里是local)
[root@localhost test]# mv redis-2.8.17 /usr/local/redis

4.到local目录下

[root@localhost /]# cd usr/local

5.安装

[root@localhost redis]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
...

6.到src目录下

[root@localhost redis]# cd src

7.启动服务

[root@localhost src]# ./redis-server
[6072] 16 May 18:04:21.158 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[6072] 16 May 18:04:21.160 * Increased maximum number of open files to 10032 (it was originally set to 1024).

[6072] 16 May 18:04:21.194 # Server started, Redis version 2.8.17
[6072] 16 May 18:04:21.195 # 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.
[6072] 16 May 18:04:21.195 * The server is now ready to accept connections on port 6379

8.到src目录下,测试客户端程序redis-cli和redis服务交互。

[test@localhost src]$ ./redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>

原文地址:https://www.cnblogs.com/zhangtingzu/p/5500283.html