linux下redis安装之HelloWorld

来源:互联网 发布:css与js实现的小游戏 编辑:程序博客网 时间:2024/06/07 03:05

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]# ls00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README.md   runtest          runtest-sentinel  src    utilsBUGS             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]# lltotal 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-configlrwxrwxrwx. 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-clilrwxrwxrwx  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]# lsredis.conf

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

[root@localhost myredis]# cd /usr/local/bin[root@localhost bin]# ls2to3          idle   python     python2.7-config  redis-benchmark  redis-check-rdb  redis-sentinel  smtpd.pycurve_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 redisroot      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]# ls2to3          idle   python     python2.7-config  redis-benchmark  redis-check-rdb  redis-sentinel  smtpd.pycurve_keygen  pydoc  python2.7  python-config     redis-check-aof  redis-cli        redis-server[root@localhost bin]# redis-cli -p 6379127.0.0.1:6379> pingPONG127.0.0.1:6379> set hello worldOK127.0.0.1:6379> get hello"world"127.0.0.1:6379> 

10.退出客户端

127.0.0.1:6379> shutdownnot connected> exit[root@localhost bin]# 
原创粉丝点击