redis安装

1. 下载Redis源码(tar.gz),并上传到Linux
官网地址:http://redis.io/
官网下载地址:http://redis.io/download
2. 解压缩包:tar zxvf redis-2.8.17.tar.gz
3. 进入解压缩后的文件夹:cd redis-2.8.17
4. 编译源码:make
(1)若出现如下提示,则说明未安装gcc,使用命令安装gcc:yum install gcc
[root@localhost redis- 2.8 . 17 ]# make
cd src && make all
make [ 1 ]: Entering directory `/root/redis- 2.8 . 17 /src
CC adlist.o
/bin/ sh : cc : command not found
make [ 1 ]: *** [adlist.o] Error 127 make [ 1 ]: Leaving directory `/root/redis- 2.8 . 17 /src
make : *** [all] Error 2
(2)若出现如下提示,则将make改为make MALLOC=libc,推测是因为编译库的问题。
[root@localhost redis- 2.8 . 17 ]# make
cd src && make all
make [ 1 ]: Entering directory `/root/redis- 2.8 . 17 /src
CC adlist.o
In file included from adlist.c: 34 :
zmalloc.h: 50 : 31 : error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h: 55 : 2 : error: #error "Newer version of jemalloc required"
make [ 1 ]: *** [adlist.o] Error 1 make [ 1 ]: Leaving directory `/root/redis- 2.8 . 17 /src
make : *** [all] Error 2
(3)在编译redis3.2.9时,若出现如下提示,则在deps目录中执行 make geohash-int hiredis jemalloc linenoise lua
cc: ../deps/hiredis/libhiredis.a: No such file or directory
cc: ../deps/lua/src/liblua.a: No such file or directory
cc: ../deps/geohash-int/geohash.o: No such file or directory
cc: ../deps/geohash-int/geohash_helper.o: No such file or directory
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/usr/local/src/redis-3.2.9/src'
make: *** [all] Error 2
(3)再进行make,成功如下:
[root@node5 redis-3.2.9]# make
cd src && make all
make[1]: 进入目录“/usr/redis/redis-3.2.9/src”
Hint: It's a good idea to run 'make test' ;)
make[1]: 离开目录“/usr/redis/redis-3.2.9/src”
[root@node5 redis-3.2.9]
5. 安装编译后的文件:make install,redis可执行文件将被复制到/usr/local/bin/,但没有配置,手动复制配置:cp redis.conf /usr/local/bin
[root@node5 redis-3.2.9]# make install
cd src && make install
make[1]: 进入目录“/usr/redis/redis-3.2.9/src”
Hint: It's a good idea to run 'make test' ;)
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: 离开目录“/usr/redis/redis-3.2.9/src”
6. 设置Redis密码,编辑刚刚复制的配置文件:vi redis.conf,解除requirepass参数的注释,并设置值,例如:requirepass ljx520
7. 使用配置文件启动Redis数据库:./redis-server redis.conf
如果看到如下的界面,那么恭喜你,Redis已安装成功
[root@node5 redis-3.2.9]# cd src/
[root@node5 src]# ./redis-server
40970:C 14 Apr 23:40:17.618 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
40970:M 14 Apr 23:40:17.619 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 40970
  `-._    `-._  `-./  _.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |            http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

40970:M 14 Apr 23:40:17.622 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
40970:M 14 Apr 23:40:17.622 # Server started, Redis version 3.2.9
40970:M 14 Apr 23:40:17.623 # 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.
40970:M 14 Apr 23:40:17.623 # 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.
40970:M 14 Apr 23:40:17.623 * The server is now ready to accept connections on port 6379
8.redis/src目录下执行./redis-cli -h 127.0.0.1 -p 6379,客户端连接redis服务
测试
set和get方法,将数据存储和获取redis数据

127.0.0.1:6379> set name lilei
OK
127.0.0.1:6379> get name
"lilei"
127.0.0.1:6379>
CONFIG GET是查询配置文件配置参数值

127.0.0.1:6379> CONFIG GET loglevel
1) "loglevel"
2) "notice"
127.0.0.1:6379>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值