Non-relational database and install redis

1. What is NoSQL?

NoSQL (NoSQL = Not Only SQL), which means anti-SQL movement, is a new revolutionary movement database, 2000 years ago, it was suggested that the development trend of increasingly rising to 2009. It refers to the use of non-relational data storage, with respect to the use of relational databases overwhelming, this concept is undoubtedly injected a new thinking. With the rise of the Internet web2.0 websites, traditional relational databases in dealing with web2.0 sites, particularly large scale and high concurrent SNS type of web2.0 pure dynamic site has appeared to be inadequate, exposed a lot of problems difficult to overcome, rather than relational databases due to its own characteristics has been very rapid development. NoSQL database is generated in order to solve large-scale data collection of multiple data types of challenges brought about, especially in big data application problems.

classification For example Scenarios Data Model Feature
Key type Tokyo Cabinet/Tyrant, Redis, Voldemort,BDB Content caching, mainly for high-load processing to access large amounts of data, but also for some of the logging system, and so on. Key points Value of key-value pairs, usually implemented hash table Find Fast
Column-store database Cassandra, HBase, Distributed File System Storage cluster in a column, the column data is present together in the same Find fast speed, scalability, easier to distributed expansion
Document database CouchDB, MongoDB Web application (similar to the Key-Value, Value is structured, except that the database can understand the content of Value) Key-Value corresponding to the key-value pair, Value structured data The data structure is not critical, the variable table structure, not like the relational database table structure defined in advance as required
Graphics Database Neo4J, InfoGrid, Infinite Graph Social networking, recommendation systems. Focus on building relationship map Figure structure Correlation algorithm using the structure of FIG. For example, the shortest path addressing multi-dimensional relationship Find etc.
2, nNoSQL Features

NoSQL key-value is stored, and the traditional relational database is not the same, do not necessarily follow a few basic requirements for traditional database, such as SQL standard to follow, ACID properties, table structure and so on.
Such a database has the following characteristics:

  • Non-relational, distributed, open source, scalable level
  • Super processing large amounts of data
  • Break the performance bottleneck
  • High concurrent read and write data
  • Efficient storage and access to massive data
  • High scalability and high availability for data
3, redis Introduction

Redis is an open source, advanced key-value non-relational database. It is often called a data structure of the server, since the key may comprise a string (string), the hash (hash), List (list), SET (set) and zset (sorted-set-- ordered set). These data types are supported push / pop, add / remove and on the intersection and union, and difference operations richer.
Redis and Memcached similar, it supports the type of stored value relatively more, and, like memcached, in order to ensure efficiency, the data is cached in memory, the difference is that Redis will periodically update the data written to disk or to modify write operation added into the log file, and on this basis realize the master-slave (master and slave) synchronization.

4, redis installation
4.1 Installation
wget -c  http://download.redis.io/releases/redis-5.0.7.tar.gz
[root@centos7 ~]# tar -zxvf redis-5.0.7.tar.gz  #解压
[root@centos7 ~]# cd redis-5.0.7/
[root@centos7 redis-5.0.7]# make MALLOC=lib  #编译,因版本较新,所以需要指定库
[root@centos7 redis-5.0.7]# make PREFIX=/usr/local/redis install #安装到指定位置
[root@centos7 redis-5.0.7]# mkdir /usr/local/redis/etc
[root@centos7 redis-5.0.7]# cp ./redis.conf    /usr/local/redis/etc/ #生成配置文件
4.2, modify the configuration file
[root@centos7 redis-5.0.7]# vim /usr/local/redis/etc/redis.conf
    daemonize no  修改为 yes  #允许redis以守护进程运行
4.3, start the server
[root@centos7 ~]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 
6562:C 18 Jan 2020 00:35:33.038 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6562:C 18 Jan 2020 00:35:33.038 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=6562, just started
6562:C 18 Jan 2020 00:35:33.038 # Configuration loaded
4.4, server-side connection
[root@centos7 ~]# /usr/local/redis/bin/redis-cli  
-h   127.0.0.1:  #连接指定的 redis 服务器  
-p   6379:  #指定 redis 服务器的端口  
-a   密码:  #使用密码登录  
-n   数据库号: #指定连接哪个数据库  
--raw:   redis #支持存储中文 

[root@centos7 ~]# /usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> 
127.0.0.1:6379> exit
[root@centos7 ~]# 
4.4, shut down the server
[root@centos7 ~]# /usr/local/redis/bin/redis-cli shutdown
[root@centos7 ~]# pkill  -9 redis 

Guess you like

Origin www.cnblogs.com/hjnzs/p/12208015.html