Redis introduction and Linux stand-alone installation

1. RedisIntroduction

1.1. What isRedis

Redis( Remote Dictionary Server), that is, the remote dictionary service, is an open-source ANSI Clanguage-written, network-enabled, memory-based and persistent log-type Key-Valuedatabase, and provides multiple languages API.

RedisIt is completely open source, complies with BSDthe agreement, and is a high-performance key-valuedatabase.

RedisCompared with other key - valuecaching products, it has the following three characteristics:

  • RedisSupports data persistence, can save the data in the memory to the disk, and can be loaded again for use when restarting.
  • RedisIt not only supports simple key-valuetypes of data, but also provides storage of data structures such as list, set, zset, and so on.hash
  • RedisSupport data backup, that is, master-slavemode data backup.

1.2. RedisAdvantages

  • High performance. RedisThe speed at which you can read is 110000次/s, and the speed at which you can write is 81000次/s.
  • Rich data types. Supports the , , , and data type operations Redisfor the binary case .StringsListsHashesSetsOrdered Sets
  • atom. RedisAll operations on are atomic, meaning they either succeed or fail at all. Individual operations are atomic. Multiple operations also support transactions, ie atomicity, by wrapping them MULTIwith instructions.EXEC
  • Rich features. RedisAlso supports publish/subscribe, notification, keyexpiration and other features.

1.3. How is it different Redisfrom other key-valuestorages?

  • RedisHaving more complex data structures and providing atomic operations on them is a different evolution path than other databases. RedisThe data types are based on the basic data structure and are transparent to the programmer without additional abstraction.

  • RedisIt runs in memory but can be persisted to disk, so memory needs to be weighed when performing high-speed reading and writing of different data sets, because the amount of data cannot be larger than the hardware memory. Another advantage of having an in-memory database is that it is very simple to operate in-memory compared to the same complex data structure on disk, which Rediscan do a lot of things with a lot of internal complexity. Also, they are compact in terms of on-disk format and are append-generated, since they do not require random access.

2. LinuxStand-alone installation

2.1. Download Redisthe installation package

Log in to the official website to download Redisthe installation package, redis official website

insert image description here

2.2. Installation Redisdependencies

First you need to install Redisthe required dependencies:

yum install -y gcc tcl

insert image description here

2.3. RedisInstallation package upload server

RedisThen upload the installation package downloaded from the official website to Linuxany directory of the server, for example to /homethe directory:

insert image description here

2.4. Unzip Redisthe installation package

Use the unzip command to unzip Redisthe installation package

tar -xvf redis-6.2.4.tar.gz

insert image description here

After decompression:

insert image description here

2.5. Compile and install

Enter redisthe directory:

cd redis-6.2.4

insert image description here

Run the compile command:

make && make install

insert image description here

insert image description here

If there are no errors, the installation should be successful.

Then modify redis.confsome configurations in the file:

# 绑定地址,默认是127.0.0.1,会导致只能在本地访问。修改为0.0.0.0则可以在任意IP访问
bind 0.0.0.0
# 数据库数量,设置为1
databases 1
# 设置redis认证密码
requirepass 123456

2.6. StartupRedis

start Redis:

./src/redis-server redis.conf

insert image description here

After the command window is closed, Redisthe service will also be closed, which does not meet business needs, so it needs to be Redisstarted in the background.

Modify redis.conffile configuration:

# 设置redis认证密码
daemonize yes

insert image description here

Restart Redisthe service after modification:

insert image description here

2.7. TestingRedis

Redis Desktop ManagerTest with visualization tools

insert image description here

Guess you like

Origin blog.csdn.net/qq_37726813/article/details/130790615