tcl8.6.1html
$wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
$tar xzvf tcl8.6.1-src.tar.gz
$cd tcl8.6.1/unix/
$ ./configure
$ make
$ make installredis
注意:yum install tcl 更方便數據庫
redis-3.0.7
數組
$ wget http://download.redis.io/releases/redis-3.0.7.tar.gz
$ tar xzf redis-3.0.7.tar.gz
$ cd redis-3.0.7
$ make
$ make test安全
Run redis-3.0.7服務器
[root@host_0 src]# ./redis-server /root/redis-3.0.7/redis.conf
31143:M 22 Feb 10:18:22.487 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 31143
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' yii
31143:M 22 Feb 10:18:22.489 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
31143:M 22 Feb 10:18:22.489 # Server started, Redis version 3.0.7
31143:M 22 Feb 10:18:22.489 # 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.
31143:M 22 Feb 10:18:22.489 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
31143:M 22 Feb 10:18:22.489 * The server is now ready to accept connections on port 6379異步
Check redis-3.0.7 Porttcp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 31143/./redis-serveui
Running redis-3.0.7 Cli
[root@host_0 src]# ./redis-cli
127.0.0.1:6379>
在執行命令以前須要密碼驗證:
檢查密碼是否設置:
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass" 2) ""
默認狀況下,此屬性爲空,表示沒有設置密碼,此實例。您能夠經過執行如下命令來更改這個屬性
127.0.0.1:6379> CONFIG set requirepass "baxk" :要輸入密碼baxk才能執行命令
OK 127.0.0.1:6379> CONFIG get requirepass 1) "requirepass" 2) "baxk"
鏈接到了redis後須要使用AUTH命令來身份驗證:
的基本語法以下所示:
127.0.0.1:6379> AUTH 「baxk」 :這樣才能成功的執行命令
127.0.0.1:6379> AUTH "baxk"
OK 127.0.0.1:6379> SET mykey "Test value" OK 127.0.0.1:6379> GET mykey "Test value"
Redis客戶端的基本語法以下:
遠程服務器上運行命令
要在Redis遠程服務器上運行的命令,須要經過同一個客戶端redis-cli 鏈接到服務器
語法
$ redis-cli -h host -p port -a password
例如
下面的示例演示瞭如何鏈接到Redis主機:127.0.0.1,端口:6379 上的遠程服務器,並加上驗證密碼爲:mypass。
$redis-cli -h 127.0.0.1 -p 6379 -a "mypass"
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> PING
PONG
Redis服務器命令基本上都用於管理Redis服務器
S.N. | 命令和說明 |
---|---|
1 | BGREWRITEAOF 異步改寫僅追加文件 |
2 | BGSAVE 異步保存數據集到磁盤 |
3 | CLIENT KILL [ip:port] [ID client-id] 殺死一個客戶端的鏈接 |
4 | CLIENT LIST 獲取客戶端鏈接到服務器的鏈接列表 |
5 | CLIENT GETNAME 獲取當前鏈接的名稱 |
6 | CLIENT PAUSE timeout 中止指定的時間處理來自客戶端的命令 |
7 | CLIENT SETNAME connection-name 設置當前鏈接名稱 |
8 | CLUSTER SLOTS 獲取集羣插槽數組節點的映射 |
9 | COMMAND 獲取Redis的命令的詳細信息數組 |
10 | COMMAND COUNT 獲得的Redis命令的總數 |
11 | COMMAND GETKEYS 給予充分的Redis命令提取鍵 |
12 | BGSAVE 異步保存數據集到磁盤 |
13 | COMMAND INFO command-name [command-name ...] 獲取具體的Redis命令的詳細信息數組 |
14 | CONFIG GET parameter 獲取配置參數的值 |
15 | CONFIG REWRITE 重寫的存儲器配置的配置文件 |
16 | CONFIG SET parameter value 配置參數設置爲給定值 |
17 | CONFIG RESETSTAT 復位信息返回的統計 |
18 | DBSIZE 返回所選數據庫中的鍵的數目 |
19 | DEBUG OBJECT key 獲取有關的一個關鍵的調試信息 |
20 | DEBUG SEGFAULT 使服務器崩潰 |
21 | FLUSHALL 從全部數據庫中刪除全部項 |
22 | FLUSHDB 從當前數據庫中刪除全部項 |
23 | INFO [section] 獲取有關服務器的信息和統計數據 |
24 | LASTSAVE 得到最後成功的UNIX時間時間戳保存到磁盤 |
25 | MONITOR 監聽由實時服務器接收到的全部請求 |
26 | ROLE 返回在複製的狀況下實例的角色 |
27 | SAVE 同步保存數據集到磁盤 |
28 | SHUTDOWN [NOSAVE] [SAVE] 同步的數據集保存到磁盤,而後關閉服務器 |
29 | SLAVEOF host port 使服務器爲另外一個實例的從站或者促進其做爲主 |
30 | SLOWLOG subcommand [argument] 管理Redis的慢查詢日誌 |
31 | SYNC 命令用於複製 |
32 | TIME 返回當前服務器時間 |