Redis Server-side commands

Source: Internet
Author: User
Tags redis server

Redis 127.0.0.1:6380> time , display server times , timestamp ( seconds ), microseconds

1) "1375270361"

2) "504511"


redis127.0.0.1:6380> dbsize // number of keys in the current database

(integer) 2

Redis127.0.0.1:6380> Select 2

Ok

Redis127.0.0.1:6380[2]> dbsize

(integer) 0

Redis127.0.0.1:6380[2]>



bgrewriteaof background process rewrite AOF

BGSAVE background Save Rdb Snapshot

Save the Rdb snapshot

Lastsave Last Saved time


Slaveofmaster-host Port, set the current instance to master slave


Flushall Empty All library keys

FLUSHDB clears all keys for the current library

Showdown[save/nosave]


Note : If you accidentally run the Flushall, immediately Shutdownnosave, shut down the server

then manual edit aof file , Remove files from "flushall " related rows , then turn on the server , can be imported back to the original data


If , after Flushall , the system happens to be bgrewriteaof, then the aof is emptied and the data is lost .


Slowlog Show Slow Query

Note : How slow is slow ?

Answer : specified by slowlog-log-slower-than10000 , (in microseconds )


How many slow query records does the server store ?

Answer : by slowlog-max-len128 , to do the restriction


Info[replication/cpu/memory..]

View information for a redis server


Configget Configuration Items

ConfigSet configuration Item Value (special option , not allowed with this command setting , such as slave-of, need to be set with separate slaveof command )

Parameters to be aware of when Redis operations

1: Memory

#Memory

used_memory:859192 Space for data structures

used_memory_rss:7634944 Real Space

mem_fragmentation_ratio:8.89 ago2 proportion ,1.n for best , If this value is too large , description redis,

2: Master-slave replication

#Replication

Role:slave

master_host:192.168.1.128

master_port:6379

Master_link_status:up


3: Persistent

#Persistence

rdb_changes_since_last_save:0

rdb_last_save_time:1375224063


4:fork Time consuming

#Status

latest_fork_usec:936 last export of Rdb snapshot , persistence takes microseconds

note :10g content , export required 2 minutes

Writes 10,000 times per minute , resulting in an ongoing RDB export , where the disk is in a high io State .



5: Slow Log

Configget/set Slowlog-log-slower-than

Configget/set Slowlog-max-len

Slowlogget N Get slow log

Run-time change master-slave

Modify a slave (set to a) to newmaster

    1. Command This service not to do other Redis service slave

Command : slaveof no One

    1. Modify its readonly to Yes


The other slave point to newmaster A .

    1. Command This service for newmaster a slave

Command format SLAVEOFIP Port

Redis Server-side commands

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.