Redis configuration file description

Source: Internet
Author: User
Redis Introduction

Reids is a relatively advanced open-source key-value storage system, which is implemented using ansi c. Similar to memcached, but supports persistent data storage, and supports multiple types of value:String(Same as the value in memcached ),List,Set(SET ),Ordered Set(Orderset) andHash. All value types support atomic operations, such as appending pop-up elements in the list and inserting and removing elements in the set. Most of the rdids data is stored in the memory, and its Read and Write efficiency is very high. It provides two persistence Methods: aof (append operation record file) and dump (regular data backup. Redis supports a custom VM (Virtual Memory) mechanism. When the data capacity exceeds the memory, some values can be stored in files. Redis also supports the master-slave mechanism for data replication.

Appendix: redis. conf configuration file:

# Running as a daemon
Daemonize Yes
# Configure the PID storage path and file name. The default value is under the current path.
Pidfile redis. PID
# Redis default listening port
Port 6379
# How many seconds after the client is idle, disconnect
Timeout 300
# Log display level
Loglevel verbose
# Specify the log output file name or the standard output port
Logfile stdout
# Set the number of databases. The default connected database is 0. You can use select n to connect to different databases.
Databases 16
# Policy for saving data to disk
# If one of the keys data is changed, it will be refreshed to disk once every 900 seconds.
Save 900 1
# When 10 keys data items are changed, refresh them to disk once every 300 seconds
Save 300 10
# When pieces of keys data are changed, refresh to disk once every 60 seconds
Save 60 10000
# Whether to compress data objects when dump. RDB Databases
Rdbcompression Yes
# Name of the data stored in the dump Database
Dbfilename dump. RDB
# Redis working directory
DIR/home/Falcon/redis-2.0.0/
########### Replication #####################
# Redis replication Configuration
# Slaveof <masterip> <masterport>
# Masterauth <master-Password>

############# Security ###########
# Requirepass foobared

############## Limits ##############
# Maximum number of client connections
# Maxclients 128
# Maximum memory usage
# Maxmemory <bytes>

######### Append only mode #########
# Whether to enable the log function
Appendonly No
# Refresh the log to disk rules
# Appendfsync always
Appendfsync everysec
# Appendfsync No
############### Virtual memory ###########
# Whether to enable the VM Function
VM-enabled No
# VM-enabled Yes
VM-Swap-file logs/redis. Swap
VM-max-memory 0
VM-page-size 32
VM-pages 134217728
VM-max-threads 4
############ Advanced config ###############
Glueoutputbuf Yes
Hash-max-zipmap-entries 64
Hash-max-zipmap-value 512
# Whether to reset the hash table
Activerehashing Yes

 

Redis Master/Slave Configuration

Redis master-slave configuration is quite simple. I wrote a large article in some articles, but there are actually two sentences:

Enable redis. conf on the slave

Port 6380 (Note: it cannot be the same as the host)

Sleverof 192.168.194.102 6379 (Note: IP is the Host IP address and 6379 is the host redis port number)

Restart the host first, and then restart the slave

 

 

A simple test was conducted:

<?php
$redis=new Redis();
$redis->connect('192.168.194.102',6379);
$redis->set('test','hello redis');
echo 'From master:'.$redis->get('test').'<br>';

$redis_salve=new Redis();
$redis_salve->connect('192.168.194.103',6380);
echo 'From salve:'.$redis_salve->get('test').'<br>';
?>

Execution result:

From master: Hello redis
From salve: Hello redis

-----------------------------------

We can see that there is data on the slave machine. Now I turn off the host and check whether the data on the slave machine can be read?

Stopping redis-server: redis-server.

Test code:

<?php

$redis_salve=new Redis();
$redis_salve->connect('192.168.194.103',6380);
echo 'From salve:'.$redis_salve->get('test').'<br>';
?>

Running result:

From salve: Hello redis

This means that when the host crashes, it can continue to obtain data from the host. However, if the code for connecting to the host is found in the test code, it will lead to incorrect results.

-----------------------------------------------------------

After the host is enabled, the slave machine is disabled and data can only be obtained from the host, but not from the host.

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.