The first met with Redis, Redis installation, startup and configuration

Original starting to blog Park, author: after puberty Keats; Address: https://www.cnblogs.com/keatsCoder/ reproduced please specify, thank you!

Recently had the opportunity to introduce a Redis for the company's project, you can learn in actual combat is a very happy thing. Therefore, in crude read: after "Redis depth Adventures core principles and practical application" purchase "Redis development and operation and maintenance" continue to learn Redis. The process of learning some of the highlights to share with you a small record partnership

According to the current understanding of learning and Redis, I intend to reason out the following knowledge structure. Each secondary node as an independent blog. The first part is the basic Benpian -Redis

1585571520993

Redis advantage

  1. Fast, why fast?

    1. Data in memory
    2. Written in C language, the road between the C language and operating system shorter
    3. Single thread, a thread to avoid the deployment and snatch
    4. High levels of coding
  2. Based on key-value pairs well understood

    Redis key supports only String type, type values ​​are: String, hash, list, set, zset. String and by the evolution of these bitmaps HyperLogLog GEO rich types can let developers create a lot of interesting applications

  3. Simple and stable

    Before Redis 3.0, only 2W lines of code, plus 3.0 cluster only 5W line. A casual amount of code Background Management System (dog is regrettable that the C language source code for Javaer look at the cost of slightly higher). And is single-threaded model, client development is very simple, Java clients such as the famous Jedis API and native API is very similar name, learning cost is not large. And Redis has been used in major companies. DESCRIPTION sufficient stability.

  4. Endurance of

    As memory database, there is a pain point is the persistence of the problem. The total power failure the data will not be lost. Redis provides RDB and AOF two kinds of persistent approach to ensure persistent data

  5. Master and slave, Sentinel, clusters

    Version 3.0 supports native multi-machine, it is convenient

Redis inadequate

  1. Redis data is stored in memory, and memory prices determines that it can not store particularly large data.
  2. Data are from the cold, the heat of the points. For example: users to view product information and records. Product information is hot data, each user may view; the user to view data records that belong to the cold, he only occasionally look at. If the data is stored cold in Redis. It can be said is a great waste of Redis.

Redis installed

Installation under Linux Redis

Redis intermediate version number is an odd number even number representative of a version of the development version. We recommended an even number of intermediate stable version. Here I use version 3.0.7

download:

wget http://download.redis.io/releases/redis-3.0.7.tar.gz

如果提示找不到命令,使用 yum 安装 wget 命令: yum -y install wget

Decompression:

tar xzf redis-3.0.7.tar.gz

Establish Redis directory soft link. This is done for shielding the associated version number and Redis, easy to upgrade version

ln -s redis-3.0.7 redis

installation:

# 检查有没有安装 gcc,
gcc -v
# 如果是 commond not found 则没有安装,需要输入以下命令安装
yum install gcc
# 开始安装
cd redis
make # 编译
make install # 安装

Start Redis

redis-server

If you need to configure the command to start, through the following ways:

redis-server --configKey1 v1 --cK2 v2

Production environment is generally recommended to write the parameters in the configuration file, and then specify the startup configuration file

redis-server /opt/redis/redis.config # 配置文件的绝对路径

Redis Basic Configuration

Placement name Explanation remind
port Port, default 6379
logfile Log Files Configuration file rather than a directory to xxx
to you Redis working directory, log files, and persistent storage file

Redis Client

redis-cli -h {host} -p {por
t} # 默认是 127.0.0.1 6379

Close Redis

shutdown

ctrl -c running in the foreground, then close the command line

Not recommended kill -9 forced to close, persistence will be too late, resulting in data loss

Guess you like

Origin www.cnblogs.com/keatsCoder/p/12635967.html