Redis database of NoSQL Database: Redis introduction and installation and deployment, nosqlredis

Source: Internet
Author: User
Tags redis server

Redis database of NoSQL Database: Redis introduction and installation and deployment, nosqlredis
Zookeeper

NoSQL (NoSQL = Not Only SQL) refers to non-relational databases. With the rise of Internet Web websites, traditional relational databases are dealing with Web websites, especially ultra-large-scale and high-concurrency SNS type web pure dynamic websites, many insurmountable problems are exposed, while non-relational databases have developed rapidly due to their own characteristics.

 

Features of NoSQL:

Feature 1:

It is stored in the form of key-value. Unlike traditional relational databases, it does not necessarily follow some basic requirements of traditional databases, such as following SQL standards, ACID attributes, and table structures, such databases have the following features: Non-relational, distributed, open-source, and horizontally scalable.

 

Feature 2:

  1. Processing a large amount of data has advantages over Mysql.

  2. Run on a cheap PC server cluster.

  3. Breaks down the performance bottleneck. (MySQL requires a lot of optimization, but NoSQL does not, and the performance is very high)

 

Feature 3 (performance ):

  1. High-concurrency read/write of data. (Tens of thousands of read requests to MySQL may survive, but if tens of thousands of write requests are made to MySQL, the hard disk IO requirements are high and the efficiency is low, but NoSQL is a comparison .)

  2. Efficient storage and access to massive data.

  3. High scalability and availability of data. (NoSQL can add a server node. It is easier to use NoSQL for distributed processing because there is no fixed table structure, so it is easier to change it ).

 

Redis introduction:

  1. Redis is an open-source, advanced key-value storage. It is usually called a Data Structure server, because keys can contain strings, hash, linked lists, sets, and ordered sets.

  2. Redis is a key-value storage system. It supports many types of stored values, including string, list, set, and zset ). These data types support push/pop, add/remove, intersection and Union operations, and richer operations. Redis supports sequences of different methods. To ensure efficiency, they are all cached in the memory. It can also periodically write updated data to the disk or modify the operation to write the append record file.

 

Redis application scenarios:

There are many deployment scenarios for Sina Weibo Redis, which are roughly divided into the following two types:

  1. Applications directly access the Redis database.

  1. The application directly accesses Redis and accesses MySQL only when Redis access fails.

 

The process of installing an elephant in a refrigerator:

Redis database provides flexible data structures and operations to build different refrigerators for different elephants.

 

Specific application scenarios of Redis:

  1. Operations on the latest N Databases

  2. Ranking application, top n operations

  3. Applications that need to precisely set the expiration time

  4. Counter application

  5. Uniq operation to obtain the values of all data records in a certain period of time

  6. Real-Time System and Anti-Spam system.

  7. Pub/Sub: Build a Real-Time Message System (Redis exclusive publishing and subscription system)

  8. Build a queue system

  9. Cache.

 

Redis installation and deployment

Step 1:

Redis official download site is: http://redis.io/download

It is best to use the Stable version (Stable version ).

 

Step 2: Compile the source program

Tar zxvf redis-2.8.19.tar.gz

Cd redis-2.8.19

Make

Cd src & make install (pay attention to permission issues)

Online installation method:

$ Wget http://download.redis.io/releases/redis-2.8.19.tar.gz

$ Tar xzf redis-2.8.19.tar.gz

$ Redis-2.8.19 cd

$ Make

 

 

Step 3:

Move files to facilitate management:

Mkdir-p/usr/local/redis/bin

Mkdir-p/usr/local/redis/etc

Music/home/toto/redis/redis-2.8.19/redis. conf/usr/local/redis/etc/

Cd src

Mv mkreleasehdr. sh redis-benchmarkredis-check-aof redis-check-dump redis-cli redis-server/usr/local/redis/bin/(that is, moving all executable files)

 

Step 4: Start the Redis service:

/Usr/local/redis/bin/redis-server (or to the/usr/local/redis/bin directory, execute:./redis-server)

You can specify the configuration file:

/Usr/local/redis/etc/redis. conf (you can add this configuration file after./redis-server)

The default connection ports of the Redis server are 6379 (mongodb port numbers are 27017 and 28017)

 

Step 5:

Client Connection:/usr/local/redis/bin/redis-cli (cli is short for client ).

You can exit the client through exit or quit.

 

Step 6:

Stop a Redis instance

We can use/usr/local/redis/bin/redis-cli and then

Shutdown

You can also use pkill redis-server or kill-9.

 

Redis Configuration:

Daemonize: If you need to run the command in the background, change the value to yes.

Pidfile: The address configured for multiple PIDs is/var/run/redis. pid by default.

Bind: bind an ip address. After setting, only requests from this ip address are accepted.

Port: listening port. The default value is 6379.

Timeout: Set the timeout time for client connection, in seconds

Loglevel: divided into four levels: debug, verbose, notice, warning

Logfile: configure the log file address

Databases: set the number of databases. The default value is 0.

Save: set the frequency of redis database images. (Back up data)

Rdbcompression: whether to perform compression during image backup

Dbfilename: name of the backup image file

Dir: Path of the database image backup file

Slaveof: sets the database as the slave database of another database.

Masterauth: password verification required for primary database connection.

Requirepass: Set the password used for logon.

Maxclients: Limit the number of customers connected at the same time.

Maxmemory: sets the maximum memory available for redis.

Appendonly: Enable append only mode.

Appendfsync: Set the synchronization frequency for the appendonly. aof file.

Vm-enabled: whether to enable virtual memory support.

Vm-swap-file: sets the swap file path for the virtual memory.

Vm-max-memory: sets the maximum physical memory size used by redis.

Vm-page-size: Set the page size of the virtual memory.

Vm-pages: Set the total number of pages for swap files

Vm-max-threads sets the number of threads simultaneously used by VMIO.

Glueoutputbuf: stores small output caches together.

Hash-max-zipmap-entries: sets the hash critical value.

Activerehashing: Re-hash

How to view the process: ps-ef | grep "redis"

How to view the port: netstat-tunpl | grep 6379

 

 

 

 

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.