1.連線
redis-cli.exe -h 127.0.0.1 -p 6379
2.驗證密碼
λ redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> auth 密碼
3. redis key值獲取
keys * 獲取當前資料下所有KEY值
get key
select 2 切換到第二個資料庫
127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> keys * 1) "1234" 2) "2234" 127.0.0.1:6379> get 1234 "1234" 127.0.0.1:6379> select 2 OK
4. info命令
redis Info 命令基本語法如下:
redis 127.0.0.1:6379> INFO [section]
127.0.0.1:6379[2]> INFO # Server redis_version:3.0.501 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:ba05b51e58eb9205 redis_mode:standalone os:Windows arch_bits:64 multiplexing_api:WinSock_IOCP process_id:7436 run_id:fac1a3e90e49c55b4709ed5f772a9831ef112f36 tcp_port:6379 uptime_in_seconds:2256 uptime_in_days:0 hz:10 lru_clock:15351291 config_file: # Clients connected_clients:2 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:712936 used_memory_human:696.23K used_memory_rss:675288 used_memory_peak:566399016 used_memory_peak_human:540.16M used_memory_lua:36864 mem_fragmentation_ratio:0.95 mem_allocator:jemalloc-3.6.0 # Persistence loading:0 rdb_changes_since_last_save:5 rdb_bgsave_in_progress:0 rdb_last_save_time:1542075691 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 aof_enabled:0 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:ok aof_last_write_status:ok # Stats total_connections_received:29836 total_commands_processed:99662 instantaneous_ops_per_sec:0 total_net_input_bytes:600911 total_net_output_bytes:783597 instantaneous_input_kbps:0.00 instantaneous_output_kbps:0.00 rejected_connections:20002 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:1 evicted_keys:0 keyspace_hits:27 keyspace_misses:2 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 migrate_cached_sockets:0 # 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 # CPU used_cpu_sys:4.75 used_cpu_user:3.69 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 # Cluster cluster_enabled:0 # Keyspace db0:keys=2,expires=0,avg_ttl=0
5. slowlog get 10 慢查詢語句, 在上一個節中有講過
參照 http://www.cnblogs.com/huamei2008/p/8850047.html
10.0.0.80:6380> slowlog get 10 1) 1) (integer) 1017859 2) (integer) 1542078045 3) (integer) 15600 4) 1) "HMSET" 2) "CME_6E1812_1_20181113" 3) "\x00>\xabKWI\xd6\b" 4) "\x00>\xabKWI\xd6\b\xf6\xb7\x01\x00\xec\xb7\x01\x00\xf6\xb7\x01\x00\xec\xb7\x01\x00\x1d\x00\x00\x00y\xf03\x01" 2) 1) (integer) 1017858 2) (integer) 1542078044 3) (integer) 15600 4) 1) "HMSET" 2) "CFFEX_ZJ-IH1812_1_20181113" 3) "\x00>\xabKWI\xd6\b" 4) "\x00>\xabKWI\xd6\b\xe4^\x00\x00\xda^\x00\x00\xe2^\x00\x00\xe2^\x00\x00\b\x00\x00\x00y\xf03\x01" 3) 1) (integer) 1017857 2) (integer) 1542078016 3) (integer) 15600 4) 1) "HMSET" 2) "DCE_DS-j1901_1_20181113" 3) "\x00>\xabKWI\xd6\b" 4) "\x00>\xabKWI\xd6\b\x05Z\x00\x00\xe7Y\x00\x00\xfbY\x00\x00\xe7Y\x00\x00f\x04\x00\x00y\xf03\x01"
6. Redis自身效能壓測:
命令:
redis-benchmark -p 6379 -c 20000 -n 50000
-h 表示IP
-p 表示埠
-c 表示連線數
-n表示請求數
-t 後面跟請求方式, 如get
參考資料:http://www.runoob.com/redis/redis-data-types.html
https://www.cnblogs.com/huamei2008/p/8850165.html
http://www.cnblogs.com/huamei2008/p/8850047.html