"Redis uses full resolution" common operations

Source: Internet
Author: User
Tags redis cluster

Gnuhpc
Source: http://www.cnblogs.com/gnuhpc/

1.1 Start 1.1.1 Start Redis

$ redis-server redis.conf

Common options:

./redis-server (Run the server with default conf)

./redis-server/etc/redis/6379.conf

./redis-server--port 7777

./redis-server--port 7777--slaveof 127.0.0.1 8888

./redis-server/etc/myredis.conf--loglevel Verbose

1.1.2 Start Redis-sentinel

./redis-server/etc/sentinel.conf–sentinel

./redis-sentinel/etc/sentinel.conf

After deployment, you can use Sstart to pull up Redis and Sentinel and use Sctl for Supervisorctl control. (two alias)

1.2 Stop

REDIS-CLI shutdown

Sentinel method, just need to execute Sentinel's connection port

1.3 Whether the probe service is available

127.0.0.1:6379> Ping

Return Pong Description Normal

1.4 Monitoring Redis Request execution information

Monitor is executed under CLI and production environment is used with caution.

1.5 View Redis Database statistics

Executing info under the CLI

Related meanings:

mrds:6379> Info

# Server

redis_version:2.8.19 # # #redis版本号

redis_git_sha1:00000000 # # #git SHA1

redis_git_dirty:0 # # #git Dirty Flag

Redis_build_id:78796c63e58b72dc

Redis_mode:standalone # # #redis运行模式

Os:linux 2.6.32-431.el6.x86_64 x86_64 # # #os版本号

ARCH_BITS:64 # # #64位架构

Multiplexing_api:epoll # # #调用epoll算法

gcc_version:4.4.7 # # #gcc版本号

process_id:25899 # # #服务器进程PID

RUN_ID:EAE356AC1098C13B68F2B00FD7E1C9F93B1C6A2C # # #Redis的随机标识符 (for Sentinel and Cluster)

tcp_port:6379 # # #Redis监听的端口号

uptime_in_seconds:6419 # #Redis运行时长 (s)

uptime_in_days:0 # # #Redis运行时长 (per day)

Hz:10

lru_clock:10737922 # # #以分钟为单位的自增时钟 for LRU Management

config_file:/etc/redis/redis.conf # # #redis配置文件

# clients

Connected_clients:1 # # #已连接客户端的数量 (excluding clients connected through a secondary server)

client_longest_output_list:0 # # #当前连接的客户端中最长的输出列表

client_biggest_input_buf:0 # # #当前连接的客户端中最大的输出缓存

blocked_clients:0 # # #正在等待阻塞命令 (Blpop, Brpop, Brpoplpush) The number of clients to be monitored

# Memory

used_memory:2281560 # # #由 The total amount of memory allocated by the Redis allocator in bytes (byte)

used_memory_human:2.18m # # #以更友好的格式输出redis占用的内存

used_memory_rss:2699264 # # #从操作系统的角度 Returns the total amount of memory that Redis has allocated (commonly known as the resident set size). This value is consistent with the output of commands such as top and PS

used_memory_peak:22141272 # # # # Redis memory consumption spikes (in bytes)

USED_MEMORY_PEAK_HUMAN:21.12M # # #以更友好的格式输出redis峰值内存占用

used_memory_lua:35840 # # #LUA引擎所使用的内存大小

mem_fragmentation_ratio:1.18 # # # of ratios between #used_memory_rss and Used_memory

mem_allocator:jemalloc-3.6.0

# # # #在理想情况下, the value of Used_memory_rss should be only slightly higher than used_memory. When RSS > used, and the values of the two differ significantly, there is a memory fragment (internal or external). The rate of memory fragmentation can be seen through the Mem_fragmentation_ratio value.

When used > rss, some of the memory of Redis is swapped out to swap space by the operating system, in which case the operation can have a noticeable delay.

# persistence

loading:0 # # #记录服务器是否正在载入持久化文件

rdb_changes_since_last_save:0 # # #距离最近一次成功创建持久化文件之后, how many seconds have elapsed

rdb_bgsave_in_progress:0 # # #记录了服务器是否正在创建 RDB file

rdb_last_save_time:1420023749 # # #最近一次成功创建 The UNIX timestamp for the RDB file

Rdb_last_bgsave_status:ok # # #最近一次创建 The result of an RDB file is success or failure

rdb_last_bgsave_time_sec:0 # # #最近一次创建 The number of seconds spent in an RDB file

Rdb_current_bgsave_time_sec:-1 # # #如果服务器正在创建 RDB file, then this field records the number of seconds that the current creation operation has taken

Aof_enabled:1 # # #AOF is open

aof_rewrite_in_progress:0 # # #服务器是否正在创建 aof file

aof_rewrite_scheduled:0 # # # # # # # # # # # # # # # # # # # # #RDB the aof rewrite

Aof_last_rewrite_time_sec:-1 # # #最近一次创建 aof file time-consuming

Aof_current_rewrite_time_sec:-1 # # #如果服务器正在创建 aof file, then this field records the number of seconds that the current creation operation has taken

Aof_last_bgrewrite_status:ok # # # #最近一次创建 The result of the AoF file is success or failure

Aof_last_write_status:ok

aof_current_size:176265 # # #AOF The current size of the file

aof_base_size:176265 # # #服务器启动时或者 AOF overrides the size of the AoF file after the most recent execution

aof_pending_rewrite:0 # # #是否有 AoF rewrite operation is performed after an RDB file is created

aof_buffer_length:0 # # #AOF the size of the buffer

aof_rewrite_buffer_length:0 # # #AOF the size of the rewrite buffer

aof_pending_bio_fsync:0 # # #后台 The number of Fsync calls waiting to be executed inside the I/O queue

aof_delayed_fsync:0 # # #被延迟的 number of Fsync calls

# Stats

total_connections_received:8466 # # #服务器已接受的连接请求数量

total_commands_processed:900668 # # #服务器已执行的命令数量

Instantaneous_ops_per_sec:1 # # #服务器每秒钟执行的命令数量

total_net_input_bytes:82724170

total_net_output_bytes:39509080

instantaneous_input_kbps:0.07

instantaneous_output_kbps:0.02

rejected_connections:0 # # #因为最大客户端数量限制而被拒绝的连接请求数量

Sync_full:2

sync_partial_ok:0

sync_partial_err:0

expired_keys:0 # # #因为过期而被自动删除的数据库键数量

evicted_keys:0 # # #因为最大内存容量限制而被驱逐 (evict) number of keys.

keyspace_hits:0 # # #查找数据库键成功的次数.

keyspace_misses:500000 # # #查找数据库键失败的次数.

pubsub_channels:0 # # #目前被订阅的频道数量

pubsub_patterns:0 # # #目前被订阅的模式数量

latest_fork_usec:402 # # #最近一次 The number of milliseconds spent in the fork () operation

# Replication

Role:master # # #如果当前服务器没有在复制任何其他服务器, then the value of this field is master; otherwise, the value of this field is slave. Note that when you create a replication chain, a Slave server may be the primary server for another server

Connected_slaves:2 # # #2个slaves

Slave0:ip=192.168.65.130,port=6379,state=online,offset=1639,lag=1

Slave1:ip=192.168.65.129,port=6379,state=online,offset=1639,lag=0

master_repl_offset:1639

Repl_backlog_active:1

repl_backlog_size:1048576

Repl_backlog_first_byte_offset:2

repl_backlog_histlen:1638

# CPU

used_cpu_sys:41.87 # # #Redis Server-intensive system CPU

used_cpu_user:17.82 # # #Redis user CPU consumed by the server

used_cpu_sys_children:0.01 # # #后台进程耗费的系统 CPU

used_cpu_user_children:0.01 # # #后台进程耗费的用户 CPU

# Keyspace

Db0:keys=3101,expires=0,avg_ttl=0 # # #keyspace section records statistics related to the database, such as the number of keys in the database, the number of expired keys that the database has been deleted, and so on. For each database, this section will add a line of information in the following format

See only one part: info Replication

Re-count: Config Resetstat

1.6 Viewing and modifying configurations

View:

Config get: Gets the server configuration information.

Redis 127.0.0.1:6379> config get dir

Config Get *: View all Configurations

Modify:

Temporary settings: Config set

Permanent setup: Config rewrite, writes the current server's parameter configuration to Redis conf.

1.7 Performing operations in bulk

You can also connect redis-server using Telnet. and the use of NC commands in the script for Redis operations is also very effective:

[Email protected]:~$ (echo-en "Ping\r\nset key Abc\r\nget key\r\n"; Sleep 1) | NC 127.0.0.1 6379

+pong

+ok

$

Abc

Another way is to use pipeline:

Perform multiple write operations in one script in bulk:

Put the insert operation into the operation text Insert.dat first:

Set a B

Set 1 2

Set h W

Set F U

Then execute the command: Cat Insert.bat |./redis-cli--pipe, or the following script:

#!/bin/sh

Host=$1

port=$;

Password=$3

Cat Insert.dat |./redis-cli-h $host-P $port-a $password--pipe

1.8 Selecting a Database

Select Db-index, the default connected database is 0, and the default number of databases is 16. Returns 1 indicates success, 0 failed

1.9 Emptying the database

FLUSHDB: Deletes all keys in the currently selected database. The production has been banned.

Flushall: Delete all the databases. The production has been banned.

1.10 Simulation Downtime

REDIS-CLI Debug Segfault

1.11 Analog Hang

Redis-cli-p 6379 DEBUG Sleep 30

1.12 Renaming commands

Rename-command, for example:rename-command flushall "". Must be restarted.

1.13 Executing LUA scripts

--eval. For example:

REDIS-CLI--eval Myscript.lua key1 key2, arg1 arg2 arg3

1.14 Setting a password

Config set requirepass [Passw0rd]

1.15 Verifying the password

Auth Passw0rd

1.16 Performance Test Commands

Redis-benchmark-n 100000

1.17 Getting slow queries

Slowlog GET 10

The result is the query ID, the occurrence time, the run-time length, and the original command

1.18 Viewing logs

Log location under/redis/log, Redis.log is the Redis master log, and Sentinel.log is the Sentinel monitoring log.

1.19 REDIS-CLI command Line other operations

1. Echo: Print some content at the command line

Redis 127.0.0.1:6379> Echo Hongwan

"Hongwan"

2. Quit: Quit the connection.

Redis 127.0.0.1:6379> quit

3. The-X option reads the last parameter from standard input (stdin). For example, read input from a pipeline:

Echo-en "Chen.qun" | Redis-cli-x Set Name

4.-r-i

The-r option repeats the number of times a command is specified.

-I sets the interval at which the command executes.

For example, see Commands (QPS) performed by Redis per second

Redis-cli-r 100-i 1 Info Stats | grep instantaneous_ops_per_sec

5.-C: Turn on the Reidis cluster mode and use it when connecting to the Redis cluster node.

6.--rdb: Gets the Rdb file for the specified Redis instance, which is saved locally.

Redis-cli-h 192.168.44.16-p 6379--rdb 6379.rdb

7.--slave

Simulates the slave received from master on the commands. The commands that are received on the slave are update operations that record the updated behavior of the data.

8.--pipe

This is a very useful parameter. Sends raw REDIS PROTOCL format data to server-side execution. For example, the following form of data (Linux server needs to be converted to DOS file Unix2dos).

The default line break for Linux is the \n,windows system's newline character is \r\n,redis use \ r \ n.

Echo-en ' *3\r\n$3\r\nset\r\n$3\r\nkey\r\n$5\r\nvalue\r\n ' | REDIS-CLI--pipe

Gnuhpc
Source: http://www.cnblogs.com/gnuhpc/

"Redis uses full resolution" common operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.