本文摘自PHP中文网,作者藏色散人,侵删。
下面由Redis教程栏目给大家介绍单机Redis环境搭建方法,希望对需要的朋友有所帮助!
序言
在实际开发项目过程中, 如果说要用到缓存, 那么第一个想到的一定是Redis, 但是为什么选Redis大多数人都不会去了解, 也不会去思考, 只知道它能当缓存使用, 比数据库快一点, 恰巧我也是这样的一个人;所以, 当我想写一篇关于Redis介绍的时候, 我竟然无从说起; 这也是对于Redis以及主流内存数据库不熟的原因; 不过, 在以后的日子里, 一定增加自己对于框架的思考与深入, 让自己在后面的技术道路上有所沉淀, 希望以后有人让我简要介绍Redis的时候, 我不会无从说起;这或许就是我想写Redis系列博客的目的所在吧!
一、Redis环境搭建
下载redis稳定版
1 | curl -o redis.tar.gz http:
|
解压redis包
tar -zxvf redis-stable.tar.gz -C ./ // 该命令表示解压tar.gz包到当前目录
编译安装redis
进入到解压的Redis的目录下, 使用如下命令编译安装Redis
1 | sudo make && make install PREFIX=/usr/local/redis
|
编辑配置Redis配置文件
1 | sudo cp redis.conf /usr/local/redis/conf/
|
启动Redis服务
1 | ./redis-server ../conf/redis.conf &
|
启动输出日志:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 45894:C 02 Nov 2018 22:11:19.922 # Redis version=5.0.0, bits=64, commit=00000000, modified=0, pid=45894, just started
45894:C 02 Nov 2018 22:11:19.922 # Configuration loaded
45894:M 02 Nov 2018 22:11:19.924 * Increased maximum number of open files to 10032 (it was originally set to 256).
_._
_.-``__ '' -._
_.-`` `. `_. '' -._ Redis 5.0.0 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ '' -._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._| '` _.-' | Port: 6379
| `-._ `._ / _.-' | PID: 45894
`-._ `-._ `-./ _.- ' _.-'
|`-._`-._ `-.__.- ' _.-' _.-'|
| `-._`-._ _.- '_.-' | http:
`-._ `-._`-.__.- '_.-' _.-'
|`-._`-._ `-.__.- ' _.-' _.-'|
| `-._`-._ _.- '_.-' |
`-._ `-._`-.__.- '_.-' _.-'
`-._ `-.__.- ' _.-'
`-._ _.-'
`-.__.-'
45894:M 02 Nov 2018 22:11:19.933 # Server initialized
45894:M 02 Nov 2018 22:11:19.933 * Ready to accept connections
|
验证Redis服务
使用网络工具telnet验证
1 2 3 4 | terrydeMacBook-Air:bin terrylmay$ telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]' .
|
使用系统进程ps 验证
1 2 3 | terrydeMacBook-Air:bin terrylmay$ ps -ef | grep redis
501 45894 44430 0 10:11下午 ttys000 0:00.04 ./redis-server 127.0.0.1:6379
501 45897 44430 0 10:11下午 ttys000 0:00.00 grep redis
|
到这里, 一个单机版的Redis服务就搭建完成了!
二、使用Redis存储数据
Redis CLI连接Redis服务
1 2 3 4 5 6 7 | terrydeMacBook-Air:bin terrylmay$ ./redis-cli
127.0.0.1:6379>
127.0.0.1:6379> set name terrylmay
OK
127.0.0.1:6379> get name
"terrylmay"
127.0.0.1:6379>
|
到此, 我们可以使用Redis系统来存储数据字符串数据了.
以上就是单机Redis环境搭建方法的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
Redis分区实现原理介绍
?Redis的安装与使用
Redis内存满了会怎么样
使用Redis完成抽奖功能
Redis是什么语言开发的
Redis命令如何使用
Redis配置文件Redis.conf超详细的解析
Redis及Redis扩展在linux平台的安装
Redis怎么做mysql缓存
ubuntu中Redis集群的安装
更多相关阅读请进入《Redis》频道 >>
机械工业出版社
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。
转载请注明出处:木庄网络博客 » 单机Redis环境搭建方法