This is the sixth day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Caching is a good thing.

It can withstand a lot of traffic for a while.

Although the only time I get a lot of traffic is when my data is being crawled.

It would be bad enough if this database collapsed once.

Try to install a Redis on the server.

Let’s see how long he lasts.

I’m not a big fan of using a compiled install to install programs.

When I first got to know Linux, I used the compiler to install the LAMP environment, which often failed and left a shadow.

So I used the yum command to install.

Centos does not have redis in the yum source.

Here we need to install a third-party YUM source using Fedora’s Epel repository

1: Install the EPEL first, yes, and run the following command:

yum install epel-release
Copy the code

2: After the third-party source is configured, we start to install Redis

yum install redis
Copy the code

After the installation is complete, note the following: Important, redis access port 6379, you need to open port 6379, otherwise redis cannot access.

3: enable redis command:

systemctl start redis
Copy the code

4: Set redis startup command:

systemctl enable redis
Copy the code

5: Check the running status of Redis

systemctl status redis
Copy the code

At this point, the Linux server installation of Redis is complete.

Redis.conf daemonize = yes

7: Redis set password: (this password you can not set, I did not set)

Redis -cli // Go to the Redis operation interface, configsetRequirepass test123 // Set the password auth test123 // Verify the password config get requirepass // Obtain the passwordCopy the code

After the password is set, run the redis command. If an error occurs, run the redis command first

Auth test123 // Password authenticationCopy the code

8: Stop the Redis server

Stop the Redis server with the following command.

Redis -cli shutdown redis set the password to shutdown the redis serverCopy the code

Redis allows remote access

The redis server is in protected mode by default and can only be accessed locally. Open the redis. Conf file and you can see the following configuration

bind127.0.0.1 protected mode - yesCopy the code

Modified to

# bind 127.0.0.1
protected-mode no
Copy the code

Then reload the Redis configuration

redis-server redis.conf
Copy the code

10: Redis remote connection password authentication

Conf, open the configuration file to find

#requirepass foobared
Copy the code

Remove the comments before the line, change the password to the desired password, and save the file

requirepass myRedis
Copy the code

Restart the redis

redis-cli shutdown
redis-server redis.conf
Copy the code

11: Redis forgot password handling method

If one day my hand suddenly shakes, oh, no, I can’t remember the redis password.

Don’t panic at this point, open the Linux command line.

Input:

whereis redis.conf
Copy the code

[picture archived failure outside the chain, the source station might be hotlinking prevention mechanism, proposed to directly upload picture preserved (img – PsojD7YE – 1610250606439) (API. Guanchao. Site/ueditor/PHP…)]

Then open the Redis configuration file

Full-text search: requirepass

Requirepass is your Redis password

The above is basically Linux installation and configuration of Redis related content

For good suggestions, please enter your comments below.

Welcome to my blog guanchao.site

Welcome to applets: