Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Redis in CentOS7

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to install and configure Redis in CentOS7. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

Installation

Download the source code wget http://download.redis.io/releases/redis-4.0.12.tar.gz

Decompress and enter the directory tar xzf redis-4.0.12.tar.gz and cd redis-4.0.12/

Compile to the specified directory make PREFIX=/usr/local/redis install to create / usr/local/redis/ect directory, copy the redis.conf over

The / usr/local/redis directory structure is as follows

Add Redis to the system service and execute vim / usr/lib/systemd/system/redis-server.service, as follows

[Unit] Description=The redis-server Process ManagerAfter=syslog.target network.target [service] Type=simplePIDFile=/var/run/redis.pidExecStart=/usr/local/redis/bin/redis-server / usr/local/redis/etc/redis.confExecReload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s QUIT $MAINPID [install] WantedBy=multi-user.target

Enable the service systemctl start redis-server

Set to boot boot systemctl enable redis-server

Test, use redis-cli test to take a look

Modify Redis configuration

Modify the data save path, create a new / usr/local/redis/data directory, and set dir to this path

RDB and AOF persistence

The default RDB is save 9001 save 300 10 save 60 10000, that is, 1 change in 900 seconds, 10 changes in 300 seconds, and 10000 changes in 60 seconds. Any of the above conditions can be met and the default value is used.

AOF is turned off by default, so change appendonly to yes. There are three options for update conditions. Always means to manually call fsync () after each update operation to write data to disk (slow, secure), everysec means to synchronize once per second (eclectic, default), no indicates that operating systems such as data cache are synchronized to disk (fast), and the default value is fine.

Both can be used at the same time, and other related configurations use the default values.

Modify data elimination strategy

Maximum memory usage maxmemory is annotated by default, which is set to 512m. Note that the unit is bytes, so the value is 536870912.

Redis provides a total of six data elimination strategies after exceeding the value, which are

Volatile-lru: select the most recently unused data release from the dataset with the expiration time set

Allkeys-lru: select the most recently unused data release from the dataset (including datasets that set expiration time and those that do not set expiration time)

Volatile-random: from a dataset with an expiration time set, randomly select a data to release

Allkeys-random: randomly select a data from the dataset (including setting expiration time and not setting expiration time) to enter and release

Volatile-ttl: from the dataset with the expiration time set, select the data that is about to expire to release.

Noeviction: no data is deleted (but redis will also release it based on the reference counter), and an error will be returned directly if there is not enough memory.

Here set maxmemory-policy to volatile-lru.

Other configurations will remain at default values and will be modified later as required. Remember to restart the service systemctl restart redis-server after the modification is completed.

After reading the above, do you have any further understanding of how to install and configure Redis in CentOS7? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report