Redis 2.8 OPS, building a cluster

Source: Internet
Author: User

1 Redisoperation and Maintenance1.1   Persistence of

Redis automatically writes memory data to disk. (Because memory data is lost when the server goes down, Redis saves the memory data to disk and makes a backup.) This is why Redis is called a database.

1.1.1  Rdb

1) persistence mechanism: Writes the in-memory dataset to disk in a snapshot at a specified time interval

2) Advantages and disadvantages of RDB persistence mode

Advantage: The whole The Redis database will contain only one file, which is perfect for file backups

disadvantage:an RDB is a persistent data that takes a snapshot every once in a while, and if a server failure occurs at this time, it will be catastrophic.

1.1.2  AOF

1) Persistence mechanism: Log the server every operation, in the Redis server startup early read the file to rebuild the database to ensure that the database after the start of the data is complete.

2)AOF Persistence mode Advantages and disadvantages:

Advantages: There are 3 synchronization Policies in Redis, that is, synchronization per second, synchronization per modification, and unsynchronized

Modify synchronization: Each time a synchronization is modified, the performance is very expensive.

Sync per Second: Synchronize operations per second

Out of sync

disadvantage: For the same number of datasets, AOF files are typically larger than Rdb files, and depending on the synchronization strategy,the AOF is often less efficient than an RDB

1.1.3  Rdbwith theAOFConfiguration

1)RDB Persistent configuration (Modify redis.conf file) Note: Red is the configuration file modification Section

deamonize The form of the process has changed to:Yes

Timeout client does not operate on interrupt service 0 uninterrupted

configuration of RDB snapshots

Database default number of libraries

Save 1 a snapshot once per second

rdbcompression compressing the snapshot Yes

dbfilename can change Dump.rdb 's name here.

dir./ Default build current directory (directory can be modified)

2)AOF Persistent configuration (Modify redis.conf file)

appendonly no change to Yes

Appendfsync The policy of synchronizing write data always: Record one everysec per change : Per second

No-appendfsync-no-rewrite No is not synchronized at the time of repeat writing, only one time is recorded

Percenttage The last time the content was written.

min-size 64mb up to 64MB when finishing a write

3) Other commands

Ps-ef | grep Redis to see if the process service is started

kill-9 3004 Kill the process

bgrewriteaof manual override aof

requirepass Password configuring redis Access Passwords

auth Password Client login enter access password

1.2   master-slave replication

what is master-slave replication : If the primary server goes down, the server can replace the primary server to serve the client, which is equivalent to a backup. And can put the persistent configuration on the server side to alleviate the pressure of the primary server, the primary server is not persistent, from the server responsible.

1 ) configuration instructions (read/write separation) :

Master: The primary server configures write operations and does not persist.

slave: Configures read-only data and persisted data from the server to share the stress of the primary server.

2 ) configuration content:

copy An redis.conf modify port, as slave:cp redis.confredis6380.conf Copy a file to the current directory, the master server does not need an RDB, aof, from the server to share the primary server pressure

vi redis6380.conf edit the file

pidfile process . PID file modified to redis6380.conf

Modify the port number to 6380

slaveof Primary server IP port number 6379

slave-read-only Yes

Dbfilename Dump6380.rdb

You can also modify appendonly6380.aof

Configure Dir/redis-slave, after the edit completes exiting. This is used here to Redis-slave so you need to create the Redis-slave directory mkdir redis-slave

3) operation and Maintenance precautions

each time slave disconnects, connect master again , all the master dump out the RDB and then synchronize the AoF, That is, the process of synchronization needs to be re-slave, so remember, more than one is better not to start up

4 )Redis Master & Persistence Project architecture diagram:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/BF/wKiom1WEIknAU14MAAF7daugThk054.jpg "title=" 7kj5z% Jv]t0367gta_4 ' Apg.png "alt=" Wkiom1weiknau14maaf7daugthk054.jpg "/>

1.3   common operation and maintenance commands and precautions1.3.1  OPS Command

number of dbsize keys

Flushall clears all Keys in the current server-managed database

flushdb clears all Keys in the current database

SAVE RDB Persistence mode

SHUTDOWN stop server side

slaveof Host Port manual configuration is currently from the server

Monitor opens the console

client kill shuts down one of the clients

sync Synchronize manually

bgrewriteaof background Write aof

Bgsave background Write Rdb

shutdown save|nosave shutdown Server --- save / not save

Info display server information

1.3.2   Precautions

If you accidentally flushall , you should first close the Redis service process shutdown Nosave

then edit aof and then delete the Flashall three line identifier inside the aof log file.

Restart


Redis 2.8 OPS, building a cluster

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.