linux下redis安装之HelloWorld

1.下载redis
网址:https://redis.io/download,我这里用的是redis-3.2.11.tar.gz

这里写图片描述

2.将下载的安装文件放到opt目录下

这里写图片描述

3.使用命令解压tar.gz文件

[root@localhost opt]# tar -xzvf redis-3.2.11.tar.gz 

4.cd到redis-3.2.11目录,在当前目录下执行make命令

[root@localhost opt]# cd redis-3.2.11
[root@localhost redis-3.2.11]# ls
00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README.md   runtest          runtest-sentinel  src    utils
BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
[root@localhost redis-3.2.11]# make

5.上一步完成后,继续执行make install命令

[root@localhost redis-3.2.11]# make install

6.查看默认安装目录

[root@localhost bin]# cd /usr/local/bin
[root@localhost bin]# ll
total 38396
-rwxr-xr-x. 1 root root     101 Aug 28 18:51 2to3
-rwxr-xr-x. 1 root root   10881 Aug 28 19:30 curve_keygen
-rwxr-xr-x. 1 root root      99 Aug 28 18:51 idle
-rwxr-xr-x. 1 root root      84 Aug 28 18:51 pydoc
-rwxr-xr-x. 2 root root 6139490 Aug 28 18:51 python
-rwxr-xr-x. 2 root root 6139490 Aug 28 18:51 python2.7
-rwxr-xr-x. 1 root root    1624 Aug 28 18:53 python2.7-config
lrwxrwxrwx. 1 root root      16 Aug 28 18:53 python-config -> python2.7-config
-rwxr-xr-x  1 root root 5580551 Oct 10 07:17 redis-benchmark
-rwxr-xr-x  1 root root   22177 Oct 10 07:17 redis-check-aof
-rwxr-xr-x  1 root root 7833305 Oct 10 07:17 redis-check-rdb
-rwxr-xr-x  1 root root 5709379 Oct 10 07:17 redis-cli
lrwxrwxrwx  1 root root      12 Oct 10 07:17 redis-sentinel -> redis-server
-rwxr-xr-x  1 root root 7833305 Oct 10 07:17 redis-server
-rwxr-xr-x. 1 root root   18547 Aug 28 18:51 smtpd.py

7.在根目录创建一个目录,用来存放redis.conf

[root@localhost redis-3.2.11]# cd /
[root@localhost /]# mkdir myredis
[root@localhost /]# cp /opt/redis-3.2.11/redis.conf /myredis
[root@localhost /]# cd /myredis
[root@localhost myredis]# ls
redis.conf

8.cd到默认安装目录,启动redis

[root@localhost myredis]# cd /usr/local/bin
[root@localhost bin]# ls
2to3          idle   python     python2.7-config  redis-benchmark  redis-check-rdb  redis-sentinel  smtpd.py
curve_keygen  pydoc  python2.7  python-config     redis-check-aof  redis-cli        redis-server
[root@localhost bin]# redis-server /myredis/redis.conf 
6772:M 10 Oct 07:28:43.541 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.11 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6772
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'      

9.至此redis启动成功,开启另一个命令窗口

查看redis进程
[root@localhost ~]# ps -ef|grep redis
root      6772  3119  0 07:28 pts/1    00:00:00 redis-server 127.0.0.1:6379     
root      6808  6790  0 07:31 pts/2    00:00:00 grep redis

开启客户端
[root@localhost ~]# cd /usr/local/bin
[root@localhost bin]# ls
2to3          idle   python     python2.7-config  redis-benchmark  redis-check-rdb  redis-sentinel  smtpd.py
curve_keygen  pydoc  python2.7  python-config     redis-check-aof  redis-cli        redis-server
[root@localhost bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379> 

10.退出客户端

127.0.0.1:6379> shutdown
not connected> exit
[root@localhost bin]# 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值