README_CN.md 6.2 KB
Newer Older
K
KernelMaker 已提交
1
# Pika
S
SongZhao 已提交
2
## 简介 [English](https://github.com/Qihoo360/pika/blob/master/README.md)
S
SongZhao 已提交
3
Pika是一个可持久化的大容量redis存储服务,兼容string、hash、list、zset、set的绝大接口([兼容详情](https://github.com/Qihoo360/pika/wiki/pika-支持的redis接口及兼容情况)),解决redis由于存储数据量巨大而导致内存不够用的容量瓶颈,并且可以像redis一样,通过slaveof命令进行主从备份,支持全同步和部分同步,pika还可以用在twemproxy或者codis中来实现静态数据分片(pika已经可以支持codis的动态迁移slot功能,目前在合并到master分支,欢迎使用,感谢作者[left2right](https://github.com/left2right)同学提交pr)
L
Leviathan 已提交
4 5

## Pika用户
S
SongZhao 已提交
6

G
Gao Dunqiao 已提交
7 8 9
<table>
<tr>
<td height = "100" width = "150"><img src="http://i.imgur.com/dcHpCm4.png" alt="Qihoo"></td>
L
Leviathan 已提交
10
<td height = "100" width = "150"><img src="http://i.imgur.com/ktPV3JU.jpg?2" alt="360game"></td>
G
Gao Dunqiao 已提交
11 12 13 14
<td height = "100" width = "150"><img src="http://i.imgur.com/jjZczkN.png" alt="Weibo"></td>
<td height = "100" width = "150"><img src="http://i.imgur.com/zoel46r.gif" alt="Garena"></td>
</tr>
<tr>
L
Leviathan 已提交
15
<td height = "100" width = "150"><img src="http://i.imgur.com/kHqACbn.png" alt="Apus"></td>
G
Gao Dunqiao 已提交
16 17 18 19 20
<td height = "100" width = "150"><img src="http://i.imgur.com/2c57z8U.png" alt="Ffan"></td>
<td height = "100" width = "150"><img src="http://i.imgur.com/rUiO5VU.png" alt="Meituan"></td>
<td height = "100" width = "150"><img src="http://i.imgur.com/px5mEuW.png" alt="XES"></td>
</tr>
<tr>
L
Leviathan 已提交
21
<td height = "100" width = "150"><img src="http://imgur.com/yJe4FP8.png" alt="HX"></td>
G
Gao Dunqiao 已提交
22 23 24 25 26
<td height = "100" width = "150"><img src="http://i.imgur.com/o8ZDXCH.png" alt="XL"></td>
<td height = "100" width = "150"><img src="http://imgur.com/w3qNQ9T.png" alt="GWD"></td>
<td height = "100" width = "150"><img src="http://i.imgur.com/Ll6SifR.png" alt="DYD"></td>
</tr>
<tr>
L
Leviathan 已提交
27
<td height = "100" width = "150"><img src="http://i.imgur.com/vJbAfri.png" alt="YM"></td>
G
Gao Dunqiao 已提交
28 29
<td height = "100" width = "150"><img src="http://i.imgur.com/aNxzwsY.png" alt="XM"></td>
<td height = "100" width = "150"><img src="http://i.imgur.com/mrWxwkF.png" alt="XL"></td>
L
Leviathan 已提交
30
<td height = "100" width = "150"><img src="http://i.imgur.com/DX6Ey4p.jpg" alt="LB"></td>
G
Gao Dunqiao 已提交
31
</tr>
S
SongZhao 已提交
32 33 34
<tr>
<td height = "100" width = "150"><img src="http://imgur.com/0oaVKlk.png" alt="YM"></td>
</tr>
G
Gao Dunqiao 已提交
35
</table>
S
SongZhao 已提交
36

S
SongZhao 已提交
37 38 39

[更多](https://github.com/Qihoo360/pika/blob/master/USERS.md)

K
KernelMaker 已提交
40 41 42 43
## 特点
* 容量大,支持百G数据量的存储
* 兼容redis,不用修改代码即可平滑从redis迁移到pika
* 支持主从(slaveof)
S
SongZhao 已提交
44
* 完善的[运维](https://github.com/Qihoo360/pika/wiki/pika的一些管理命令方式说明)命令
K
KernelMaker 已提交
45

B
baotiao 已提交
46 47 48 49 50

## 快速试用
  如果想快速试用pika,目前提供了Centos5,Centos6的binary版本,可以在[release页面](https://github.com/Qihoo360/pika/releases)看到,具体文件是pikaX.Y.Z_centosK_bin.tar.gz。

```
S
SongZhao 已提交
51
# 1. 解压文件
B
baotiao 已提交
52
tar zxf pikaX.Y.Z_centosK_bin.tar.gz
S
SongZhao 已提交
53
# 2. 切到output目录(rpath是./lib)
B
baotiao 已提交
54
cd output
S
SongZhao 已提交
55
# 3. 运行pika:
B
baotiao 已提交
56 57 58
./bin/pika -c conf/pika.conf
```

K
KernelMaker 已提交
59
## 编译安装
W
wuxiaofei-xy 已提交
60

K
KernelMaker 已提交
61
1.在编译机上安装snappy protobuf, CentOS系统可以用yum安装,Ubuntu可以用apt-get安装。如是CentOS系统,执行如下命令:
W
wuxiaofei-xy 已提交
62 63

```
K
KernelMaker 已提交
64
    yum install snappy-devel protobuf-devel
W
wuxiaofei-xy 已提交
65 66 67 68
```

2.安装g++(若没有安装), 在CentOS上执行如下命令:

K
KernelMaker 已提交
69
```
W
wuxiaofei-xy 已提交
70
    yum install gcc-c++
K
KernelMaker 已提交
71 72
```

S
SongZhao 已提交
73
3.把gcc版本临时切换到4.8(若已是,则忽略), 在CentOs上执行如下命令:
W
wuxiaofei-xy 已提交
74 75

```
S
SongZhao 已提交
76 77 78
	a. sudo wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
	b. sudo yum install -y devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
	c. scl enable devtoolset-2 bash
W
wuxiaofei-xy 已提交
79 80 81 82
```
4.获取源代码

```
K
KernelMaker 已提交
83
	git clone git@github.com:Qihoo360/pika.git && cd pika
W
wuxiaofei-xy 已提交
84
```
S
SongZhao 已提交
85
5.切换到最新release版本
W
wuxiaofei-xy 已提交
86

S
SongZhao 已提交
87
```
K
KernelMaker 已提交
88 89
	a. 执行 git tag 查看最新的release tag,(如 v2.2.4)
	b. 执行 git checkout TAG切换到最新版本,(如 git checkout v2.2.4)
S
SongZhao 已提交
90 91 92
```

6.编译
W
wuxiaofei-xy 已提交
93 94

```
K
KernelMaker 已提交
95
	make
W
wuxiaofei-xy 已提交
96
```
K
KernelMaker 已提交
97

W
wuxiaofei-xy 已提交
98 99
若编译过程中,提示有依赖的库没有安装,则有提示安装后再重新编译

S
SongZhao 已提交
100 101
**注:我们推荐使用TCMalloc来进行内存管理**

K
KernelMaker 已提交
102 103
## 使用
```
J
JacketWoo 已提交
104
	./output/bin/pika -c ./conf/pika.conf
K
KernelMaker 已提交
105
```
K
KernelMaker 已提交
106 107

##.清空编译
W
wuxiaofei-xy 已提交
108 109

```
K
KernelMaker 已提交
110
  如果需要清空编译内容,视不同情况使用一下两种方法其一:
K
KernelMaker 已提交
111

K
KernelMaker 已提交
112 113 114
  1. 执行make clean来清空pika的编译内容
  2. 执行make distclean来清空pika及所有依赖的编译内容(一般用于彻底重新编译)
```
Z
zhaoanan 已提交
115

K
KernelMaker 已提交
116
## 性能
S
SongZhao 已提交
117

L
Leviathan 已提交
118
### 测试环境:
K
KernelMaker 已提交
119
```
S
SongZhao 已提交
120
	相同配置服务端、客户机各一台:
K
KernelMaker 已提交
121 122 123 124 125
	处理器:24核 Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz
	内存:165157944 kB
	操作系统:CentOS release 6.2 (Final)
	网卡:Intel Corporation I350 Gigabit Network Connection
```
L
Leviathan 已提交
126
### 测试接口:
S
SongZhao 已提交
127 128 129 130
```
	Set、Get
```

L
Leviathan 已提交
131
### 测试方法:
S
SongZhao 已提交
132 133 134 135 136
```
	pika配16个worker,客户机执行 ./redis-benchmark -h ... -p ... -n 1000000000 -t set,get -r 10000000000 -c 120 -d 200
	通过set和get接口对pika进行10亿次写入+10亿次读取
```

L
Leviathan 已提交
137
### 测试结果:
S
SongZhao 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
```
    Set
    1000000000 requests completed in 11890.80 seconds
    18.09% <= 1 milliseconds
    93.32% <= 2 milliseconds
    99.71% <= 3 milliseconds
    99.86% <= 4 milliseconds
    99.92% <= 5 milliseconds
    99.94% <= 6 milliseconds
    99.96% <= 7 milliseconds
    99.97% <= 8 milliseconds
    99.97% <= 9 milliseconds
    99.98% <= 10 milliseconds
    99.98% <= 11 milliseconds
    99.99% <= 12 milliseconds
    ...
    100.00% <= 19 milliseconds
    ...
    100.00% <= 137 milliseconds

    84098.66 requests per second
```

```
    Get
    1000000000 requests completed in 9063.05 seconds
    84.97% <= 1 milliseconds
    99.76% <= 2 milliseconds
    99.99% <= 3 milliseconds
    100.00% <= 4 milliseconds
    ...
    100.00% <= 33 milliseconds

    110338.10 requests per second
```

L
Leviathan 已提交
174
### 与SSDB性能对比([详情](https://github.com/Qihoo360/pika/wiki/pika-vs-ssdb))
S
SongZhao 已提交
175 176
<img src="http://imgur.com/rGMZmpD.png" height = "400" width = "480" alt="1">
<img src="http://imgur.com/gnwMDof.png" height = "400" width = "480" alt="10">
S
SongZhao 已提交
177

L
Leviathan 已提交
178
### 与Redis性能对比
S
SongZhao 已提交
179 180
<img src="http://imgur.com/k99VyFN.png" height = "400" width = "600" alt="2">

K
KernelMaker 已提交
181
## 文档
S
SongZhao 已提交
182
1. [Wiki] (https://github.com/Qihoo360/pika/wiki)
K
KernelMaker 已提交
183 184

## 联系方式
Z
Zongzhi Chen 已提交
185
邮箱:g-infra-bada@360.cn
S
SongZhao 已提交
186 187

QQ群:294254078