redis 基础
来源:互联网 发布:域名和url的区别 编辑:程序博客网 时间:2024/05/22 13:33
官网:http://redis.soredis是Remote Dictionary Server的缩写,Redis是一个开源,基于c语言,基于内存亦可持久化的高性能NoSQL的键值对数据库。存储结构丰富: 字符串类型 散列类型 列表类型 集合类型 有序集合类型内存存储与持久化 1秒内读写10万个键值 异步写入硬盘功能丰富: 用作数据库 缓存系统 队列简单稳定: 使用命令来读写数据,Redis命令比SQL语言简单的多: SQL:SELECT title FROM post WHERE id=1 LIMIT 1 Redis: HGET post:1 titleRedis缓存介绍: Redis本质上是一个key/value数据库,与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解决了服务重启后数据不丢失的问题,他的值可以是string(字符串),list(列表),sets(集合)或者是ordered sets(被排序的集合),所有的数据类型都具有push/pop,add/remove,执行服务端的并集,交集,两个sets集中的差别等等操作,这些操作都具有原子姓的,Redis还支持各种不同的排序能力. 1.在Linux系统上安装redis 在ftp服务器(222.68.17.226)上已经安装好redis 可以用ps aux | grep redis查看一下,启动的配置文件在/etc/redis/redis.conf,日志保存在/var/log/redis/redis.log,数据保存在/usr/local/redis。1.1下载源代码并解压 下载路径http://redis.so/download cd /usr/local/src sudo wget http://download.redis.io/releases/redis-3.0.3.tar.gz sudo tar -xzvf redis-3.0.3.tar.gz1.2编译并建立软连接 cd redis-3.0.3 ubuntu系统sudo makecentos系统sudo make MALLOC=libc可能make失败,需要安装make和gcc(ubuntu是sudo apt-get install,centos是sudo yum install) sudo make PREFIX=/usr/local/redis-3.0.3 install sudo ln -s redis-3.0.3 /usr/local/redis1.3配置环境变量Ubuntu下echo 'export PATH=/usr/local/redis/bin:$PATH' >> ~/.bashrc(centos下是.bash_profile)source ~/.bashrc centos下echo 'export PATH=/usr/local/redis/bin:$PATH' >> ~/.bash_profilesource ~/.bash_profile1.4配置配置文件redis.confmkdir /var/log/redis/mkdir /etc/redissudo cp /usr/local/src/redis-3.0.3/redis.conf /etc/redis/修改三个属性sudo vim /etc/redis/redis.confdaemonize yeslogfile /var/log/redis/redis.logdir /usr/local/redis/ 注意(不要配成/usr/local/redis,否则运行一段时间后可能会报出Error moving temp DB file on the final destination: Is a directory) 1.5启动redis服务(6375端口)和redis客户端启动redis服务器:redis-server /etc/redis/redis.conf停止redis服务器:killall redis-server显示redis服务器版本:redis-server -v启动redis客户端:redis-cli 127.0.0.1:6379>keys * 127.0.0.1:6379>set pine "apple" 127.0.0.1:6379>get pine 127.0.0.1:6379>quit 退出登录 1.6redis的配置文件简要说明 配置文件redis.confRedis的配置项看起来比较复R杂,分析之下,其实可以分为几大类: 基本配置 持久化(Persistence)相关配置 Replication配置 Security配置 Limit配置 ShowLog配置 Advanced配置 INCLUDES配置基本配置项: daemonize如果需要在后台运行,把该项改为yes pidfile配置多个pid的地址,默认在/var/run/redis.pid bind 绑定ip,设置后只接受来自该ip的请求 port监听端口,默认为6379 timeout设置客户端连接时的超时时间,单位为s loglevel分为4级,debug verbose notice warning logfile 配置log文件地址持久化配置: databases设置数据库的个数,默认使用的数据库为0 save设置redis进行数据库镜像的频率 rdbcompression在进行镜像备份时,是否进行压缩 dbfilename镜像备份文件的文件名 dir数据库镜像备份的文件放置路径Limit配置项: maxclients客户端的并发连接数,默认是10000 maxmemory配置Redis Server可占用的最大内存值
0 0
- Redis基础
- Redis基础
- redis基础
- Redis基础
- redis基础
- redis 基础
- redis基础
- Redis基础
- redis基础
- Redis基础
- Redis基础
- Redis 基础
- redis基础
- Redis基础
- Redis基础
- redis基础
- Redis基础
- redis基础
- 多线程下载资源
- Spring Boot基础|使用nohup运行jar文件
- MediaTek_ApSoC_SDK_4320_20150414编译问题
- 开始学习Unity
- java基础篇
- redis 基础
- 使用OpenGL在Unity中画一个框
- iOS中UIImageView 添加UITapGestureRecognizer后传参
- kafka centos 单点配置
- jstring 和char* 之间的转换方法
- 《Monkey Android》第11课Button和ImageButton
- [反重力与飞行]需要精确计算力场的数值
- 最大公约数
- 模仿360安全卫士项目笔记8