标签:mysq db2 tar reconnect net tomat 内存分配 end emc
Overview of RedisAbout Redis
"Redis is an open source, BSD licensed, advanced key-value cache and store. It is oftenreferred to as a data structure server since keys can contain strings, hashs, lists, sets, sorted sets, bitmaps and hyperloglogs."
Redis:
KV cache and store
in-memory
持久化
主从(借助于sentinel实现一定意义上的HA)
Clustering(分布式)
数据结构服务器:
String, List, Hash, Set, Sorted Set, Bitmap, HyperLoglog
Redis
Redis is an in-memory but persistent on disk database
1 Million small key --> String value pairs use ~ 100MB of memory
Single threaded - but CPU should not be the bottleneck
Average Linux system can deliver even 500k requests per second
Limit is likely the available memory in your system
max. 232 keys
Persistence
Snapshotting
Data is asynchronously thransferred from memory to disk
AOF(Append Only File)
Each medifying operation is written to a file
Can recreate data store by replaying operations
Without interrupting service, will rebuild AOF as the shortest sequence of commands neded to rebuild the current dataset in memory
Replication
Redis supports master-slave replication
Master-slave replication can be chained
Be careful:
Slaves are writeable!
Potential for data inconsistency
Fully compatible with Pub/Sub features
Differences to Memcached
Memcached is a "distributed memory object caching system"
Redis persists data to disk eventually
Memcached is an LRU cache
Redis has different data types and more features
Memcached is multithreaded
Similar speed
Redis的优势
丰富的(资料形态)操作
Hashs, Lists, Sets, Sorted Sets, HyperLoglog等
内建replication及cluster
就地更新(in-place update)操作
支持持久化(磁盘)
避免雪崩效应
Memcached的优势
多线程
善用多核CPU
更少的阻塞操作
更少的内存开销
更少的内存分配压力
可能有更少的内存碎片
Prominent Adopters
Twitter
Pinterest
Tumblr
GitHub
Stack Overflow
digg
Blizard
flickr
WeiBo
... ...
Redis 3.0
2015年4月1日正式推出
Redis Cluster
新的"embedded string"
LRU演算法的改进
预设随机取5个样本,插入并排序至一个pool,移除最佳者,如此反复,直到内存用量小于maxmemory的设定
样本5比先前的3多
从局部最优趋向全局最优
Redis特性
BDBMS
Oracle, DB2, PostgreSQL, MySQL, SQL Server, ...
NoSQL
Cassandra, HBase, Memcached, MongoDB, Redis, ...
NewSQL
Aerospike, FoundationDB, RethinkDB, ...
存储系统有三类:
RDBMS:关系型数据库
NoSQL:非关系型数据库
KV NoSQL:redis
Colum Family NoSQL:HBase
Documention NoSQL:MongoDB
Graph NoSQL:Neo4j
NewSQL:分布式关系型数据库
Redis特性
Key-value NoSQL
Memcached, Redis, ...
Column family NoSQL
Cassandra, HBase, ...
Documen NoSQL
MongoDB, ...
Graph NoSQL
Neo4j, ...
Commands
Redis-server
redis-cli
Command line interface
Redis-benchmark
Benchmarking utility
redis-check-dump & redis-check-aof
Corrupted RDB/AOF files utilities
Redis的组件:
redis.io
Overview
Family of fundamental data structures
Strings and string containers
Accessed / indexed by key
Directly exposed -- No abstraction layers
Rich set of atomic operations over the structures
Detailed reference using big-O notation for complexities
Basic publish / subscribe infrastructure
官方站点:www.redis.io
Redis守护进程:
监听端口:6379/tcp
Keys
Arbitrary ASCII strings
Define some format convention and adhere to it
Key length matters!
Multiple name spaces are available
Separate DBs indexed by an integer value
SELECT command
Multiples DBs vs. Single DB + key prefixes
Keys can expire automatically
Data structures
Strings
Caching, counters, realtime metrice...
Hashes
"Object" storage...
Lists
Logs, queues, message passing...
Sets
Membership, tracking...
Ordered sets
Leaderboards, activity feeds...
Strings
help @string
SET
GET
EXISTS
Integers
DECR
INCR
实验环境:
系统版本:Centos6.5
内核版本:2.6.32-504.el6.x86_64
网卡1:VMnet0 172.16.100.6
网卡2:VMnet8 NAT DHCP
[root@CentOS6 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
[root@CentOS6 ~]# yum info redis
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
172.16.100.6:6379> help @STRING
172.16.100.6:6379> HELP APPEND
172.16.100.6:6379> CLIENT LIST #查看连接客户端
id=2 addr=172.16.100.6:59420 fd=6 name= age=228 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
172.16.100.6:6379> SELECT 1 #打开1号数据库,默认16个数据库
172.16.100.6:6379[1]> SELECT 0 #默认为0号数据库
172.16.100.6:6379> HELP SET
SET key value [EX seconds] [PX milliseconds] [NX|XX]
summary: Set the string value of a key
since: 1.0.0
group: string
172.16.100.6:6379> SET disto fedora
OK
172.16.100.6:6379> GET disto
"fedora"
172.16.100.6:6379> SET disto centos
OK
172.16.100.6:6379> append disto slackware
(integer) 15
172.16.100.6:6379> GET disto
"centosslackware"
标签:mysq db2 tar reconnect net tomat 内存分配 end emc
原文地址:https://blog.51cto.com/smoke520/2422603