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

The method of quickly installing and setting up self-booting in Redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to install Redis quickly and set up self-booting". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Redis rapid installation and setup self-booting method"!

There are two more practical solutions:

One is to install redis through docker and hook the configuration file to the local file through the data volume.

The second is to use shell scripts to help us complete these mechanized operations.

The first is very unfriendly to beginners. You need to consult more information and try more mistakes. If you are in a hurry to complete the task, it will cause you more trouble. In order to really help you, this article talks about the second kind, which goes directly to the main topic.

First, go to any directory on the server and execute the following command:

Vi redis-install.sh

Enter the vi editor, click I to open the edit mode, and paste the following code in (the version and installation directory are changed according to your needs):

#! / bin/bashversion= "6.2.2" echo "= check and install gcc=" yum install-y gccecho "= switch directory =" cd ~ echo "= download package =" wget https://download.redis.io/releases/redis-${version}.tar.gzecho "= extract to current directory =" tar xzf redis-$ {version} .tar.gzecho "= remove useless files =" rm redis-$ {version} .tar.gzecho "= switch directory = "cd redis-$ {version} echo" = start compilation = "makeecho" = start installation = "make install PREFIX=/usr/local/redisecho" = configuration file = "cp ~ / redis-6.2.2/redis.conf / usr/local/redis/bin/echo" = installation complete = "

Then: press esc-- to enter colon-enter wq-- to enter enter

The shell script has been written and executed through the sh command:

Sh redis-install.sh

When the execution is complete, the installation operation is completed.

Then change to the installation directory:

Cd / usr/local/redis/bin

There is a redis.conf file in this directory. Open and modify the following items (according to your own needs):

/ / whether to allow daemonize no to be launched in the background and change to yes// to set the maximum physical storage space allowed by requirepass your password// (example is 1gb) maxmemory 1073741824 / elimination rule, which specifies how to eliminate the existing key maxmemory-policy volatile-ttl when there is not enough space.

Change to any directory and execute the following command to create a new service:

Vi / etc/systemd/system/redis.service

Just like vi, press I to enter edit mode, and then copy the following code:

[Unit] Description=redisAfter= network.target[Service] Type=forkingExecStart=/usr/local/redis/bin/redis-server / usr/local/redis/bin/redis.confPrivateTmp= true[Install] WantedBy=multi-user.target

Press esc-- to enter the colon-enter wq-- and click enter.

Then reload the local service:

Systemctl daemon-reload

Start the handwritten service you just wrote:

Systemctl start redis.service

Set up boot boot:

Systemctl enable redis.service

If there is no feedback, it means that the startup is successful and can be tested with the client software link.

At this point, I believe that everyone on the "Redis rapid installation and setup of self-booting method" have a deeper understanding, might as well to actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report