Redis安装

Redis安装

1)在Redis官网下载安装包后,在Linux系统下进行解压,这里解压在.redis目录下

root@lejian:/.redis# ls
redis-3.2.5.tar.gz
root@lejian:/.redis# tar -zxf redis-3.2.5.tar.gz 
root@lejian:/.redis# ls
redis-3.2.5  redis-3.2.5.tar.gz


2)进入解压后的redis-3.2.5文件进行编译

root@lejian:/.redis# cd redis-3.2.5/
root@lejian:/.redis/redis-3.2.5# make
cd src && make all
make[1]: Entering directory `/.redis/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 `/.redis/redis-3.2.5/deps'
…………


3)编译完后查看目录下文件,src目录和redis.conf稍后会用到

root@lejian:/.redis/redis-3.2.5# ll
total 212
drwxrwxr-x  6 root root  4096 Oct 26 15:17 ./
drwxr-xr-x  3 root root  4096 Nov 11 21:01 ../
-rw-rw-r--  1 root root 78892 Oct 26 15:17 00-RELEASENOTES
-rw-rw-r--  1 root root    53 Oct 26 15:17 BUGS
-rw-rw-r--  1 root root  1805 Oct 26 15:17 CONTRIBUTING
-rw-rw-r--  1 root root  1487 Oct 26 15:17 COPYING
drwxrwxr-x  7 root root  4096 Nov 11 21:02 deps/
-rw-rw-r--  1 root root   363 Oct 26 15:17 .gitignore
-rw-rw-r--  1 root root    11 Oct 26 15:17 INSTALL
-rw-rw-r--  1 root root   151 Oct 26 15:17 Makefile
-rw-rw-r--  1 root root  4223 Oct 26 15:17 MANIFESTO
-rw-rw-r--  1 root root  6834 Oct 26 15:17 README.md
-rw-rw-r--  1 root root 46695 Oct 26 15:17 redis.conf
-rwxrwxr-x  1 root root   271 Oct 26 15:17 runtest*
-rwxrwxr-x  1 root root   280 Oct 26 15:17 runtest-cluster*
-rwxrwxr-x  1 root root   281 Oct 26 15:17 runtest-sentinel*
-rw-rw-r--  1 root root  7606 Oct 26 15:17 sentinel.conf
drwxrwxr-x  2 root root  4096 Nov 11 21:03 src/
drwxrwxr-x 10 root root  4096 Oct 26 15:17 tests/
drwxrwxr-x  7 root root  4096 Oct 26 15:17 utils/

4)编译成功后,进入src文件夹,执行make install进行Redis安装

root@lejian:/.redis/redis-3.2.5# cd src/
root@lejian:/.redis/redis-3.2.5/src# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install


5)在.redis目录下建立bin和etc目录,方便等等Redis的安装和部署,将redis-3.2.5目录下的redis.conf 文件拷贝到etc目录下,将redis-3.2.5目录下的src目录中的所有文件拷贝到bin目录下

root@lejian:/.redis# mkdir etc bin
root@lejian:/.redis# ls
bin  etc  redis-3.2.5  redis-3.2.5.tar.gz
root@lejian:/.redis# cp ./redis-3.2.5/redis.conf /.redis/etc/
root@lejian:/.redis# ls -l etc/
total 48
-rw-r--r-- 1 root root 46695 Nov 11 21:15 redis.conf
root@lejian:/.redis# cp -r /.redis/redis-3.2.5/src/* /.redis/bin/
root@lejian:/.redis# ll /bin/
total 9844
drwxr-xr-x  2 root root    4096 Apr 22  2016 ./
drwxr-xr-x 28 root root    4096 Nov 11 20:08 ../
-rwxr-xr-x  1 root root 1021112 Oct  8  2014 bash*
-rwxr-xr-x  3 root root   31152 Oct 21  2013 bunzip2*
-rwxr-xr-x  1 root root 1918032 Nov 15  2013 busybox*
-rwxr-xr-x  3 root root   31152 Oct 21  2013 bzcat*
lrwxrwxrwx  1 root root       6 Oct 21  2013 bzcmp -> bzdiff*
-rwxr-xr-x  1 root root    2140 Oct 21  2013 bzdiff*
lrwxrwxrwx  1 root root       6 Oct 21  2013 bzegrep -> bzgrep*



6)执行./redis-server 启动Redis服务

root@lejian:/.redis/bin# ./redis-server 
10557:C 11 Nov 21:23:11.328 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10557
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10557:M 11 Nov 21:23:11.330 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10557:M 11 Nov 21:23:11.330 # Server started, Redis version 3.2.5
10557:M 11 Nov 21:23:11.330 # 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.
10557:M 11 Nov 21:23:11.330 # 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.
10557:M 11 Nov 21:23:11.330 * The server is now ready to accept connections on port 6379


7)编辑etc下的redis.conf文件,将daemonize属性改为 yes,表明进程需要在后台运行

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes


8)再次启动redis服务,并指定启动服务配置文件,执行redis-cli启动Redis 客户端,查看端口号

root@lejian:/.redis/bin# ./redis-server /.redis/etc/redis.conf 
root@lejian:/.redis/bin# ./redis-cli 
127.0.0.1:6379> 

最后,Redis安装成功



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值