ps -ef | grep redis ps -ef是查看所有的進程的 然后用grep篩選出你要的信息,redis是我篩選的信息
1 注冊服務:
2 redis-server --service-install redis.windows.conf --loglevel verbose
3 卸載服務:
4 redis-server --service-uninstall
5 注冊情況下啟動和停止-server-start
6 server-stop
沒注冊情況下啟動和停止-
啟動Redis:
redis-server --service-start
停止Redis:
redis-server --service-stop
1 Redis命令 2 1-- redis-cli的使用之發送命令 3 默認連接:IP 127.0.0.1 端口 6379
4 redis-cli 5 指定IP端口: 6 redis-cli –h 127.0.0.1 –p 6379
7 Redis提供了PING-PONG機制,測試與客戶端和服務器鏈接是否正常 8 redis-cli ping 9 或 10 redis-cli 11 redis 127.0.0.1:6379>ping 12 PONG 13
14 2-- redis-cli的使用之命令返回值 15 狀態回復(最簡單的回復-redis提供的測試命令) 16 redis>PING 17 PONG 18 127.0.0.1:6379>SET test 123
19 OK 20 錯誤回復(以error開頭,后面跟着錯誤信息) 21 127.0.0.1:6379>TEST 22 (error) ERR unknown command 'TEST'
23 整數回復 24 127.0.0.1:6379>INCR test_incr 25 (integer) 1
26 字符串回復(最長久的一種回復,雙引號包裹) 27 127.0.0.1:6379>get test 28 “123” 29 多行字符串回復 30 127.0.0.1:6379>KEYS *
31 1) "test_incr"
32 2) "test"
33
34 3-- 退出 35 127.0.0.1:6379> exit 36
37 4-- 關閉 38 127.0.0.1:6379> shutdown 39
40 5-- 基本命令KEYS GET SET 41 字符串類型是redis中最基本的數據類型,它能存儲任何形式的字符串,包括二進制數據。可以存儲JSON化的對象、字節數組等。一個字符串類型鍵允許存儲的數據最大容量是512MB。 42 賦值與取值: 43 SET key value 44 GET key 45 127.0.0.1:6379> keys *
46 (empty list or set) 47 127.0.0.1:6379> set test 123
48 OK 49 127.0.0.1:6379> set test1 ab 50 OK 51 127.0.0.1:6379> keys *
52 1) "test1"
53 2) "test"
54 127.0.0.1:6379> get test 55 "123"
56 127.0.0.1:6379> get test1 57 "abc"
58 127.0.0.1:6379> get test2 59 (nil) 60 127.0.0.1:6379>
61
62 6-- redis數據庫切換SELECT 63 redis默認支持16個數據庫,對外都是以一個從0開始的遞增數字命名,可以通過參數database來修改默認數據庫個數。客戶端連接redis服務后會自動選擇0號數據庫,可以通過select命令更換數據庫,例如選擇1號數據庫: 64 127.0.0.1:6379>SELECT 1
65 OK 66 127.0.0.1:6379>GET test 67 (nil) 68 說明: 69 Redis不支持自定義數據庫名稱。 70 Redis不支持為每個數據庫設置訪問密碼。 71 Redis的多個數據庫之間不是安全隔離的,FLUSHALL命令會清空所有數據庫的數據。 72
73 7-- redis的基本命令之KEYS 74 獲取符合規則的建名列表。 75 KEYS *
76 keys test[_]*
77 keys t[a-d] 78 說明: 79 ? 匹配一個字符 80 * 匹配任意個(包括0個)字符 81 [] 匹配括號間的任一字符,可以使用“-“表示范圍。如a[a-d]匹配ab/ac/ad 82 \x 匹配字符x,用於轉義符合,如果要匹配“?“就需要使用\?
83
84 8-- redis的基本命令之EXISTS 85 判斷一個鍵是否存在。 86 如果鍵存在則返回整數類型1,否則返回0。 87 127.0.0.1:6379> keys *
88 1) "test_incr"
89 2) "test"
90 127.0.0.1:6379> exists test 91 (integer) 1
92 127.0.0.1:6379> exists test1 93 (integer) 0
94 127.0.0.1:6379>
95
96 9-- redis的基本命令之DEL 97 刪除鍵,可以刪除一個或者多個鍵,多個鍵用空格隔開,返回值是刪除的鍵的個數。 98 127.0.0.1:6379> del test 99 (integer) 1
100 127.0.0.1:6379> del test 101 (integer) 0
102 127.0.0.1:6379> del test test_incr 103 (integer) 1
104 127.0.0.1:6379>
105
106 10-- redis的基本命令之TYPE 107 獲得鍵值的數據類型,返回值可能是string(字符串)、hash(散列類型)、list(列表類型)、set(集合類型)、zset(有序集合類型)。 108 127.0.0.1:6379> keys *
109 1) "test1"
110 2) "test"
111 127.0.0.1:6379> type test 112 string 113 127.0.0.1:6379> type test1 114 string 115
116 11-- redis的基本命令之HELP 117 127.0.0.1:6379> help 118 redis-cli 2.8.19
119 Type: "help @<group>" to get a list of commands in <group>
120 "help <command>" for help on <command>
121 "help <tab>" to get a list of possible help topics 122 "quit" to exit 123 127.0.0.1:6379> help type 124
125 TYPE key 126 summary: Determine the type stored at key 127 since: 1.0.0
128 group: generic 129
130 官網:http://www.redis.io幫助
131
132 12-- redis的基本命令之FLUSHALL 133 清空所有數據庫。 134 127.0.0.1:6379> FLUSHALL 135 OK 136
137 13. redis的基本命令之FLUSHDB 138 清空當前數據庫。 139 127.0.0.1:6379> FLUSHDB 140 OK 141
1)info #查看所有信息
info Replication #只查看Replication片段信息 查看角色
2)CentOS 配置防火牆操作實例(啟、停、開、閉端口):
注:防火牆的基本操作命令:
查詢防火牆狀態:
[root@localhost ~]# service iptables status
停止防火牆:
[root@localhost ~]# service iptables stop
啟動防火牆:
[root@localhost ~]# service iptables start
重啟防火牆:
[root@localhost ~]# service iptables restart
永久關閉防火牆:
[root@localhost ~]# chkconfig iptables off
永久關閉后啟用:
[root@localhost ~]# chkconfig iptables on
3)主從復制配置:
slaveof 192.168.80.21 6379(主上的IP地址) #掛接到主
第一次執行slaveof,會全部內容進行復制。(全量復制)
pwd 查詢當前路徑