redis是開源,BSD許可,高級的key-value存儲系統.
能夠用來存儲字符串,哈希結構,鏈表,集合經常使用來提供數據結構服務.redis
redis和memcached相比,的獨特之處:
1: redis能夠用來作存儲, 而memccached是用來作緩存,這個特色主要由於其有」持久化」的功能.
2: 存儲的數據有」結構」,對於memcached來講,存儲的數據,只有1種類型字符串
而redis則能夠存儲字符串,鏈表,哈希結構,集合,有序集合等緩存
公司使用redis好久了,一直沒有拿起心來認認真真的學習掌握。今天試着寫一下,互相交流。
redis官網是https://redis.io
咱們的生產環境使用redis-3.2.13版本,就以此來初識並給你們展現安裝過程;
在有外網權限的系統上直接就能夠作,能夠從官網中獲取安裝的信息如:https://redis.io/download數據結構
1,wget http://download.redis.io/releases/redis-3.2.13.tar.gz
2,直接解壓
tar -zvxf redis-3.2.13.tar.gz
3,進入安裝目錄make
4,回彈使用make test進行測試命令語法等有效性
66 seconds - unit/dump
69 seconds - unit/type/list-2
72 seconds - integration/replication-3
74 seconds - integration/replication-4
44 seconds - unit/hyperloglog
58 seconds - unit/obuf-limits
53 seconds - unit/geo
99 seconds - unit/type/list-3
112 seconds - integration/replication-psyncide
\o/ All tests passed without errors!memcached
Cleanup: may take some time... OK
make[1]: Leaving directory `/laoyang/redis-3.2.13/src'
[root@test-laoyangtest redis-3.2.13]#工具
5,若是咱們想更改安裝的目錄,咱們能夠這樣安裝
[root@test-laoyangtest redis-3.2.13]# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory `/src/redis-3.2.13/src'性能
Hint: It's a good idea to run 'make test' ;)學習
INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install
make[1]: Leaving directory `/laoyang/redis-3.2.13/src'
[root@test-laoyangtest redis-3.2.13]#
並複製一份配置文件到安裝的目錄
[root@test-laoyangtest local]# cd /usr/local/redis/bin/
[root@test-laoyangtest local]# cd ..測試
[root@test-laoyangtest redis]# cp /src/redis-3.2.13/redis.conf ./idea
6,解釋說明一下Redis目錄
[root@test-laoyangtest bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
redis-benchmark 性能測試工具
redis-check-aof 日誌文件檢測工(好比斷電形成日誌損壞,能夠檢測並修復)
redis-check-dump 快照文件檢測工具,效果類上
redis-cli 客戶端
redis-server 服務端
7,啓動Redis---非後臺進程開啓
[root@test-laoyangtest redis]# ./bin/redis-server ./redis.conf
.
_.-__ ''-._ <br/>_.-
.
. ''-. Redis 3.2.13 (00000000/0) 64 bit
.-.-```. ```\/ _.,_ ''-._ <br/>( ' , .-` | `, ) Running in standalone mode<br/>|`-._`-...-` __...-.
-.|'` .-'| Port: 6379
| -._
. / .-' | PID: 10994-._
-. `-./ .-' .-'
|`-.-._
-..-' .-'.-'|
| -._
-. .-'.-' | http://redis.io
`-. -._
-..-'.-' .-'
|-._
-._ -.__.-' _.-'_.-'| <br/>|
-.`-. .-'.-' | -._
-._-.__.-'_.-' _.-' <br/>
-._ -.__.-' _.-' <br/>
-. .-'
`-.__.-'
10994:M 09 May 21:14:48.408 # Server started, Redis version 3.2.13
10994:M 09 May 21:14:48.408 * The server is now ready to accept connections on port 6379
8,嘗試查詢,並測試
[root@test-laoyangtest redis]# ./bin/redis-cli
127.0.0.1:6379> info replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6379> set What laoyang
OK
127.0.0.1:6379> get What
"laoyang"
9,更改redis讓其後臺執行,在配置文件中改爲
daemonize yes