CentOS 7 安装Redis 2.8.7
1、下载软件:
wget wget http://download.redis.io/releases/redis-2.8.7.tar.gz
2、解压软件并编译安装:
tar -zxvf redis-2.8.7.tar.gz
mv redis-2.8.7.tar.gz redis
cd redis
make&&make install
等待编译一端时间即可(如果您的机器上没有c++编译环境,可以通过yum安装 gcc ,命令:yum -y install gcc)
cd src
启动redis-server:./redis-server ../redis.conf
启动会发送警告:
[16403] 12 Dec 21:55:32.830 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
安装提示,解决上述问题。默认的情况下,redis监听6379端口。
3、测试使用redis #使用 telnet
[likehua@localhost local]$ telnet localhost 6379 Trying ::1... Connected to localhost. Escape character is '^]'. set likehua likehua +OK get likehua $7 likehua
4、使用redis-benchmark对redis可以进行简单的性能测试。
1 [likehua@localhost src]$ ./redis-benchmark -h localhost -p 6379 -c 1000 -n 100000 2 ====== PING_INLINE ====== 3 100000 requests completed in 2.03 seconds 4 1000 parallel clients 5 3 bytes payload 6 keep alive: 1 7 8 0.00% <= 8 milliseconds 9 0.04% <= 9 milliseconds 10 66.42% <= 10 milliseconds 11 88.10% <= 11 milliseconds 12 91.29% <= 12 milliseconds 13 93.57% <= 13 milliseconds 14 96.30% <= 14 milliseconds 15 98.13% <= 15 milliseconds 16 98.78% <= 16 milliseconds 17 99.37% <= 17 milliseconds 18 99.77% <= 18 milliseconds 19 99.93% <= 19 milliseconds 20 99.97% <= 20 milliseconds 21 100.00% <= 20 milliseconds 22 49333.99 requests per second 23 24 ====== PING_BULK ====== 25 100000 requests completed in 1.98 seconds 26 1000 parallel clients 27 3 bytes payload 28 keep alive: 1 29 30 0.00% <= 6 milliseconds 31 0.01% <= 7 milliseconds 32 0.15% <= 8 milliseconds 33 15.79% <= 9 milliseconds 34 58.19% <= 10 milliseconds 35 92.03% <= 11 milliseconds 36 96.30% <= 12 milliseconds 37 98.24% <= 13 milliseconds 38 98.90% <= 14 milliseconds 39 99.30% <= 15 milliseconds 40 99.63% <= 16 milliseconds 41 99.99% <= 17 milliseconds 42 100.00% <= 17 milliseconds 43 50581.69 requests per second 44 45 ====== SET ====== 46 100000 requests completed in 2.00 seconds 47 1000 parallel clients 48 3 bytes payload 49 keep alive: 1 50 51 0.00% <= 7 milliseconds 52 0.24% <= 8 milliseconds 53 6.78% <= 9 milliseconds 54 62.14% <= 10 milliseconds 55 88.33% <= 11 milliseconds 56 93.36% <= 12 milliseconds 57 96.28% <= 13 milliseconds 58 97.19% <= 14 milliseconds 59 98.11% <= 15 milliseconds 60 98.58% <= 16 milliseconds 61 98.91% <= 17 milliseconds 62 99.49% <= 18 milliseconds 63 99.84% <= 19 milliseconds 64 100.00% <= 19 milliseconds 65 49900.20 requests per second 66 67 ====== GET ====== 68 100000 requests completed in 1.97 seconds 69 1000 parallel clients 70 3 bytes payload 71 keep alive: 1 72 73 0.00% <= 5 milliseconds 74 0.01% <= 6 milliseconds 75 0.24% <= 7 milliseconds 76 9.30% <= 8 milliseconds 77 35.68% <= 9 milliseconds 78 53.22% <= 10 milliseconds 79 80.98% <= 11 milliseconds 80 95.27% <= 12 milliseconds 81 97.05% <= 13 milliseconds 82 98.47% <= 14 milliseconds 83 99.40% <= 15 milliseconds 84 99.76% <= 16 milliseconds 85 99.94% <= 17 milliseconds 86 100.00% <= 17 milliseconds 87 50813.01 requests per second 88 89 ====== INCR ====== 90 100000 requests completed in 2.01 seconds 91 1000 parallel clients 92 3 bytes payload 93 keep alive: 1 94 95 0.00% <= 6 milliseconds 96 0.03% <= 7 milliseconds 97 0.26% <= 8 milliseconds 98 10.85% <= 9 milliseconds 99 51.33% <= 10 milliseconds 100 86.53% <= 11 milliseconds 101 91.05% <= 12 milliseconds 102 93.84% <= 13 milliseconds 103 97.30% <= 14 milliseconds 104 99.09% <= 15 milliseconds 105 99.78% <= 16 milliseconds 106 99.93% <= 17 milliseconds 107 100.00% <= 17 milliseconds 108 49825.61 requests per second 109 110 ====== LPUSH ====== 111 100000 requests completed in 1.98 seconds 112 1000 parallel clients 113 3 bytes payload 114 keep alive: 1 115 116 0.00% <= 6 milliseconds 117 0.77% <= 7 milliseconds 118 2.36% <= 8 milliseconds 119 11.40% <= 9 milliseconds 120 53.46% <= 10 milliseconds 121 90.92% <= 11 milliseconds 122 96.49% <= 12 milliseconds 123 98.51% <= 13 milliseconds 124 99.33% <= 14 milliseconds 125 99.82% <= 15 milliseconds 126 99.91% <= 16 milliseconds 127 100.00% <= 17 milliseconds 128 100.00% <= 17 milliseconds 129 50479.56 requests per second 130 131 ====== LPOP ====== 132 100000 requests completed in 1.97 seconds 133 1000 parallel clients 134 3 bytes payload 135 keep alive: 1 136 137 0.00% <= 6 milliseconds 138 1.08% <= 7 milliseconds 139 8.16% <= 8 milliseconds 140 22.76% <= 9 milliseconds 141 54.23% <= 10 milliseconds 142 86.55% <= 11 milliseconds 143 96.52% <= 12 milliseconds 144 98.67% <= 13 milliseconds 145 99.56% <= 14 milliseconds 146 99.83% <= 15 milliseconds 147 99.92% <= 16 milliseconds 148 100.00% <= 16 milliseconds 149 50735.67 requests per second 150 151 ====== SADD ====== 152 100000 requests completed in 2.01 seconds 153 1000 parallel clients 154 3 bytes payload 155 keep alive: 1 156 157 0.00% <= 6 milliseconds 158 0.00% <= 7 milliseconds 159 0.20% <= 8 milliseconds 160 3.06% <= 9 milliseconds 161 74.43% <= 10 milliseconds 162 91.78% <= 11 milliseconds 163 95.16% <= 12 milliseconds 164 96.61% <= 13 milliseconds 165 97.22% <= 14 milliseconds 166 98.35% <= 15 milliseconds 167 99.45% <= 16 milliseconds 168 100.00% <= 16 milliseconds 169 49751.24 requests per second 170 171 ====== SPOP ====== 172 100000 requests completed in 1.98 seconds 173 1000 parallel clients 174 3 bytes payload 175 keep alive: 1 176 177 0.00% <= 6 milliseconds 178 0.25% <= 7 milliseconds 179 9.22% <= 8 milliseconds 180 27.89% <= 9 milliseconds 181 51.53% <= 10 milliseconds 182 83.58% <= 11 milliseconds 183 95.62% <= 12 milliseconds 184 98.06% <= 13 milliseconds 185 99.22% <= 14 milliseconds 186 99.83% <= 15 milliseconds 187 99.86% <= 16 milliseconds 188 99.90% <= 17 milliseconds 189 99.93% <= 18 milliseconds 190 99.97% <= 19 milliseconds 191 100.00% <= 19 milliseconds 192 50530.57 requests per second 193 194 ====== LPUSH (needed to benchmark LRANGE) ====== 195 100000 requests completed in 2.01 seconds 196 1000 parallel clients 197 3 bytes payload 198 keep alive: 1 199 200 0.00% <= 6 milliseconds 201 0.08% <= 7 milliseconds 202 0.32% <= 8 milliseconds 203 5.15% <= 9 milliseconds 204 51.92% <= 10 milliseconds 205 91.54% <= 11 milliseconds 206 94.53% <= 12 milliseconds 207 96.95% <= 13 milliseconds 208 98.08% <= 14 milliseconds 209 98.76% <= 15 milliseconds 210 99.68% <= 16 milliseconds 211 100.00% <= 16 milliseconds 212 49652.43 requests per second 213 214 ====== LRANGE_100 (first 100 elements) ====== 215 100000 requests completed in 4.00 seconds 216 1000 parallel clients 217 3 bytes payload 218 keep alive: 1 219 220 0.00% <= 14 milliseconds 221 4.44% <= 15 milliseconds 222 23.32% <= 16 milliseconds 223 26.30% <= 17 milliseconds 224 27.43% <= 18 milliseconds 225 28.36% <= 19 milliseconds 226 28.98% <= 20 milliseconds 227 32.42% <= 21 milliseconds 228 74.49% <= 22 milliseconds 229 89.15% <= 23 milliseconds 230 95.46% <= 24 milliseconds 231 95.91% <= 25 milliseconds 232 96.45% <= 26 milliseconds 233 97.53% <= 27 milliseconds 234 98.42% <= 28 milliseconds 235 98.79% <= 29 milliseconds 236 98.95% <= 30 milliseconds 237 99.15% <= 31 milliseconds 238 99.30% <= 32 milliseconds 239 99.42% <= 33 milliseconds 240 99.53% <= 34 milliseconds 241 99.60% <= 35 milliseconds 242 99.67% <= 36 milliseconds 243 99.77% <= 37 milliseconds 244 99.94% <= 38 milliseconds 245 100.00% <= 38 milliseconds 246 25006.25 requests per second 247 248 ====== LRANGE_300 (first 300 elements) ====== 249 100000 requests completed in 6.69 seconds 250 1000 parallel clients 251 3 bytes payload 252 keep alive: 1 253 254 0.00% <= 16 milliseconds 255 0.01% <= 17 milliseconds 256 0.04% <= 18 milliseconds 257 0.08% <= 19 milliseconds 258 0.11% <= 20 milliseconds 259 0.15% <= 21 milliseconds 260 0.18% <= 22 milliseconds 261 0.22% <= 23 milliseconds 262 0.24% <= 24 milliseconds 263 0.26% <= 25 milliseconds 264 0.29% <= 26 milliseconds 265 2.09% <= 27 milliseconds 266 8.86% <= 28 milliseconds 267 21.91% <= 29 milliseconds 268 32.42% <= 30 milliseconds 269 47.12% <= 31 milliseconds 270 57.70% <= 32 milliseconds 271 64.38% <= 33 milliseconds 272 68.73% <= 34 milliseconds 273 71.52% <= 35 milliseconds 274 73.66% <= 36 milliseconds 275 75.44% <= 37 milliseconds 276 77.48% <= 38 milliseconds 277 79.79% <= 39 milliseconds 278 81.49% <= 40 milliseconds 279 83.05% <= 41 milliseconds 280 84.96% <= 42 milliseconds 281 86.70% <= 43 milliseconds 282 88.68% <= 44 milliseconds 283 93.08% <= 45 milliseconds 284 95.99% <= 46 milliseconds 285 99.41% <= 47 milliseconds 286 99.47% <= 48 milliseconds 287 99.54% <= 49 milliseconds 288 99.59% <= 50 milliseconds 289 99.65% <= 51 milliseconds 290 99.72% <= 52 milliseconds 291 99.78% <= 53 milliseconds 292 99.84% <= 54 milliseconds 293 99.88% <= 55 milliseconds 294 99.90% <= 56 milliseconds 295 99.93% <= 57 milliseconds 296 99.96% <= 58 milliseconds 297 99.99% <= 59 milliseconds 298 100.00% <= 59 milliseconds 299 14949.92 requests per second 300 301 ====== LRANGE_500 (first 450 elements) ====== 302 100000 requests completed in 8.71 seconds 303 1000 parallel clients 304 3 bytes payload 305 keep alive: 1 306 307 0.00% <= 20 milliseconds 308 0.02% <= 21 milliseconds 309 0.07% <= 22 milliseconds 310 0.10% <= 23 milliseconds 311 0.13% <= 24 milliseconds 312 0.16% <= 25 milliseconds 313 0.17% <= 26 milliseconds 314 0.18% <= 27 milliseconds 315 0.20% <= 28 milliseconds 316 0.21% <= 29 milliseconds 317 0.22% <= 30 milliseconds 318 0.23% <= 31 milliseconds 319 0.26% <= 32 milliseconds 320 0.34% <= 33 milliseconds 321 0.63% <= 34 milliseconds 322 3.99% <= 35 milliseconds 323 7.57% <= 36 milliseconds 324 10.77% <= 37 milliseconds 325 13.87% <= 38 milliseconds 326 16.86% <= 39 milliseconds 327 24.72% <= 40 milliseconds 328 40.82% <= 41 milliseconds 329 49.31% <= 42 milliseconds 330 54.46% <= 43 milliseconds 331 60.03% <= 44 milliseconds 332 65.25% <= 45 milliseconds 333 70.38% <= 46 milliseconds 334 74.43% <= 47 milliseconds 335 78.07% <= 48 milliseconds 336 81.36% <= 49 milliseconds 337 84.61% <= 50 milliseconds 338 87.36% <= 51 milliseconds 339 89.99% <= 52 milliseconds 340 92.09% <= 53 milliseconds 341 94.16% <= 54 milliseconds 342 95.79% <= 55 milliseconds 343 96.93% <= 56 milliseconds 344 97.84% <= 57 milliseconds 345 98.52% <= 58 milliseconds 346 98.91% <= 59 milliseconds 347 99.26% <= 60 milliseconds 348 99.47% <= 61 milliseconds 349 99.51% <= 62 milliseconds 350 99.53% <= 63 milliseconds 351 99.55% <= 64 milliseconds 352 99.57% <= 65 milliseconds 353 99.61% <= 66 milliseconds 354 99.65% <= 67 milliseconds 355 99.69% <= 68 milliseconds 356 99.73% <= 69 milliseconds 357 99.78% <= 70 milliseconds 358 99.83% <= 71 milliseconds 359 99.86% <= 72 milliseconds 360 99.89% <= 73 milliseconds 361 99.91% <= 74 milliseconds 362 99.93% <= 75 milliseconds 363 99.95% <= 76 milliseconds 364 99.96% <= 77 milliseconds 365 99.98% <= 78 milliseconds 366 100.00% <= 78 milliseconds 367 11479.74 requests per second 368 369 ====== LRANGE_600 (first 600 elements) ====== 370 100000 requests completed in 11.03 seconds 371 1000 parallel clients 372 3 bytes payload 373 keep alive: 1 374 375 0.00% <= 19 milliseconds 376 0.01% <= 20 milliseconds 377 0.03% <= 21 milliseconds 378 0.04% <= 22 milliseconds 379 0.05% <= 23 milliseconds 380 0.07% <= 24 milliseconds 381 0.08% <= 25 milliseconds 382 0.09% <= 26 milliseconds 383 0.10% <= 27 milliseconds 384 0.12% <= 28 milliseconds 385 0.12% <= 29 milliseconds 386 0.14% <= 30 milliseconds 387 0.16% <= 31 milliseconds 388 0.20% <= 32 milliseconds 389 0.23% <= 33 milliseconds 390 0.27% <= 34 milliseconds 391 0.29% <= 35 milliseconds 392 0.32% <= 36 milliseconds 393 0.36% <= 37 milliseconds 394 0.39% <= 38 milliseconds 395 0.43% <= 39 milliseconds 396 0.47% <= 40 milliseconds 397 0.50% <= 41 milliseconds 398 0.53% <= 42 milliseconds 399 0.58% <= 43 milliseconds 400 0.74% <= 44 milliseconds 401 1.40% <= 45 milliseconds 402 4.51% <= 46 milliseconds 403 8.98% <= 47 milliseconds 404 13.34% <= 48 milliseconds 405 18.11% <= 49 milliseconds 406 23.27% <= 50 milliseconds 407 29.19% <= 51 milliseconds 408 34.92% <= 52 milliseconds 409 41.34% <= 53 milliseconds 410 48.28% <= 54 milliseconds 411 55.34% <= 55 milliseconds 412 62.15% <= 56 milliseconds 413 67.49% <= 57 milliseconds 414 71.73% <= 58 milliseconds 415 75.33% <= 59 milliseconds 416 78.47% <= 60 milliseconds 417 81.46% <= 61 milliseconds 418 84.14% <= 62 milliseconds 419 86.82% <= 63 milliseconds 420 89.05% <= 64 milliseconds 421 91.05% <= 65 milliseconds 422 93.09% <= 66 milliseconds 423 94.56% <= 67 milliseconds 424 95.60% <= 68 milliseconds 425 96.47% <= 69 milliseconds 426 97.07% <= 70 milliseconds 427 97.55% <= 71 milliseconds 428 97.98% <= 72 milliseconds 429 98.32% <= 73 milliseconds 430 98.57% <= 74 milliseconds 431 98.68% <= 75 milliseconds 432 98.82% <= 76 milliseconds 433 98.91% <= 77 milliseconds 434 99.02% <= 78 milliseconds 435 99.04% <= 79 milliseconds 436 99.05% <= 80 milliseconds 437 99.07% <= 81 milliseconds 438 99.09% <= 82 milliseconds 439 99.10% <= 83 milliseconds 440 99.10% <= 84 milliseconds 441 99.11% <= 85 milliseconds 442 99.12% <= 86 milliseconds 443 99.13% <= 87 milliseconds 444 99.14% <= 88 milliseconds 445 99.16% <= 89 milliseconds 446 99.17% <= 90 milliseconds 447 99.18% <= 91 milliseconds 448 99.20% <= 92 milliseconds 449 99.21% <= 93 milliseconds 450 99.23% <= 94 milliseconds 451 99.25% <= 95 milliseconds 452 99.27% <= 96 milliseconds 453 99.29% <= 97 milliseconds 454 99.30% <= 98 milliseconds 455 99.33% <= 99 milliseconds 456 99.36% <= 100 milliseconds 457 99.39% <= 101 milliseconds 458 99.41% <= 102 milliseconds 459 99.43% <= 103 milliseconds 460 99.46% <= 104 milliseconds 461 99.49% <= 105 milliseconds 462 99.51% <= 106 milliseconds 463 99.54% <= 107 milliseconds 464 99.56% <= 108 milliseconds 465 99.58% <= 109 milliseconds 466 99.61% <= 110 milliseconds 467 99.64% <= 111 milliseconds 468 99.66% <= 112 milliseconds 469 99.68% <= 113 milliseconds 470 99.71% <= 114 milliseconds 471 99.73% <= 115 milliseconds 472 99.76% <= 116 milliseconds 473 99.78% <= 117 milliseconds 474 99.79% <= 118 milliseconds 475 99.80% <= 119 milliseconds 476 99.81% <= 120 milliseconds 477 99.82% <= 121 milliseconds 478 99.83% <= 122 milliseconds 479 99.85% <= 123 milliseconds 480 99.86% <= 124 milliseconds 481 99.87% <= 125 milliseconds 482 99.88% <= 126 milliseconds 483 99.90% <= 127 milliseconds 484 99.92% <= 128 milliseconds 485 99.93% <= 129 milliseconds 486 99.94% <= 130 milliseconds 487 99.94% <= 131 milliseconds 488 99.94% <= 132 milliseconds 489 99.95% <= 133 milliseconds 490 99.95% <= 134 milliseconds 491 99.95% <= 135 milliseconds 492 99.95% <= 136 milliseconds 493 99.95% <= 137 milliseconds 494 99.96% <= 138 milliseconds 495 99.96% <= 139 milliseconds 496 99.96% <= 140 milliseconds 497 99.96% <= 141 milliseconds 498 99.96% <= 142 milliseconds 499 99.97% <= 143 milliseconds 500 99.97% <= 144 milliseconds 501 99.97% <= 145 milliseconds 502 99.99% <= 146 milliseconds 503 100.00% <= 146 milliseconds 504 9067.83 requests per second 505 506 ====== MSET (10 keys) ====== 507 100000 requests completed in 2.31 seconds 508 1000 parallel clients 509 3 bytes payload 510 keep alive: 1 511 512 0.00% <= 9 milliseconds 513 0.16% <= 10 milliseconds 514 0.33% <= 11 milliseconds 515 0.58% <= 12 milliseconds 516 1.01% <= 13 milliseconds 517 1.33% <= 14 milliseconds 518 2.03% <= 15 milliseconds 519 2.50% <= 16 milliseconds 520 3.43% <= 17 milliseconds 521 4.79% <= 18 milliseconds 522 6.51% <= 19 milliseconds 523 20.35% <= 20 milliseconds 524 58.54% <= 21 milliseconds 525 69.83% <= 22 milliseconds 526 76.45% <= 23 milliseconds 527 80.71% <= 24 milliseconds 528 84.42% <= 25 milliseconds 529 88.26% <= 26 milliseconds 530 91.26% <= 27 milliseconds 531 92.21% <= 28 milliseconds 532 93.89% <= 29 milliseconds 533 95.65% <= 30 milliseconds 534 96.55% <= 31 milliseconds 535 96.96% <= 32 milliseconds 536 97.36% <= 33 milliseconds 537 97.61% <= 34 milliseconds 538 98.07% <= 35 milliseconds 539 98.18% <= 36 milliseconds 540 98.47% <= 37 milliseconds 541 98.84% <= 38 milliseconds 542 99.02% <= 39 milliseconds 543 99.45% <= 40 milliseconds 544 99.63% <= 41 milliseconds 545 99.83% <= 42 milliseconds 546 99.94% <= 47 milliseconds 547 99.97% <= 63 milliseconds 548 100.00% <= 63 milliseconds 549 43215.21 requests per second
如果不知道怎么使用redis-benchmark就使用redis-benchmark -help命令,它会告诉你它所有的本领!通过,上面的简单性能测试,你会发现redis简直是性能怪兽!这个数字可是在我的一台普通PC机器上测试的!貌似,比公司的数字大很多,具体原因以后分析。