Redis is a very efficient key-value database, which is widely used in projects. However, Redis has obvious disadvantages in memory processing, at the beginning of the project launch, you must plan the memory properly. Otherwise, the memory may burst. Generally, the reasonable memory size is 3/5 of the physical memory of the computer. Redis provides a variety of data types. I often use string, hash, list, set, sortedset, which can basically meet the needs of projects for data types.
Redis is a very efficient key-value database, which is widely used in projects. However, Redis has obvious disadvantages in memory processing, at the beginning of the project launch, you must plan the memory properly. Otherwise, the memory may burst. Generally, the reasonable memory size is 3/5 of the physical memory of the computer.
Redis provides a variety of data types. I often use string, hash, list, set, sorted set, which can basically meet the project's data type requirements. We use the redis Java client and provide a series of APIS for redis commands. Redis persistence provides a variety of policies, but we didn't do persistence. After studying it ourselves, the AOF method is the most reliable. The principle is similar to that of mysql binary logs, it also records operation information and writes it to a file, reads logs from the server, and performs operations.
In general intranet development, you may need to adjust the data storage details. Therefore, if the previous data remains in the memory, many functions may fail to run normally. Therefore, after adjusting the details, perform the flushdb operation on the redis database.
Redis and ssdb are very suitable for use in some scenarios. For example, some data can only be left in the database for 2 minutes, similar to T people in YY channel. They can only come in after several minutes, you can use the setex key seconds value command to determine whether the value has expired. You can use the exists key command.
Redis common command site: http://redis.readthedocs.org/en/latest/ covers redis commands and demo.
Redis was mentioned before building ssdb because ssdb is compatible with redis APIs. It is a good alternative to redis.
Compared with redis, ssdb has many advantages: it is 100 times the capacity of redis database and can store billions of data. Apsaradb for redis occupies a small amount of memory. So I downloaded ssdb myself. The following describes how to build ssdb.
Ubuntu 14.04 Redis installation and simple test http://www.linuxidc.com/Linux/2014-05/101544.htm
Redis cluster details document http://www.linuxidc.com/Linux/2013-09/90118.htm
Ubuntu 12.10 install Redis (graphic details) + Jedis connection Redis http://www.linuxidc.com/Linux/2013-06/85816.htm
Redis series-installation, deployment, maintenance http://www.linuxidc.com/Linux/2012-12/75627.htm
CentOS 6.3 install Redis http://www.linuxidc.com/Linux/2012-12/75314.htm
Redis configuration file redis. conf detailed description http://www.linuxidc.com/Linux/2013-11/92524.htm
Environment: Ubuntu 14.04
Vm a: 192.168.1.20.
Virtual Machine B: 192.168.1.252
Gateway: 192.168.1.1
My two virtual machines are respectively mounted on different physical machines, but both adopt the bridging mode, and the ip addresses are all in the same ip segment.
Install ssdb online on both VMS.
Wget -- no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
Unzip master
Cd ssdb-master
Make
Sudo make install
These can be found on the ssdb official website at http://www.ideawu.com/ssdb/zh_cn /.
The ssdb master-slave architecture is actually very simple. You only need to find ssdb. conf under the ssdb installation directory of the two virtual machines.
Sudo vi ssdb. conf
Change the ip address of the server to the default ip address of the VM.
Virtual Machine:
Server:
Ip: 192.168.1.20.
Port: 8888 // The port is not changed. Use the default value.
Virtual Machine B:
Server:
Ip: 192.168.1.252
Port: 8888
This is the most basic configuration.
Now, you only need to configure ssdb. conf on the basis of:
Replication:
Slaveof:
# To identify a master even if it moved (ip, port changed)
# If set to empty or not defined, ip: port will be used.
Id: svc_2
# Sync | mirror, default is sync
Type: sync
Ip: 192.168.1.252
Port: 8888
Note: In the above configuration process, do not use the space key, use tab.
Now you can start ssdb.
./Ssdb-server ssdb. conf
Then you can use the command line tool provided by ssdb to perform operations.
Vm a:./ssdb-cli-h 192.168.1.20.- p 8888
Virtual Machine B:./ssdb-cli-h 192.168.1.252-p 8888
Redis details: Click here
Redis: Click here
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-05/101598.htm