In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
During this period of time to do their own website, the site used the redis service, the water of redis is very deep, 01:30 can not touch the bottom. This article starts with installation and teaches you how to install and use redis quickly.
Redis is a kind of non-relational database (NoSQL). NoSQL is stored in the form of key-value, which is different from the traditional relational database and does not necessarily follow some basic requirements of the traditional database, such as SQL standard, ACID attribute, table structure and so on. This kind of database mainly has the following characteristics: non-relational, distributed, open source, horizontal extensible.
NoSQL usage scenarios: high concurrent reading and writing of data, efficient storage and access of massive data, high scalability and high availability of data. My website also puts a lot of home page data into redis to reduce the pressure on the database.
To ensure efficiency, data is cached in memory, so redis is fast. It can also periodically write updated data to disk or modify operations to additional record files. What are the other benefits of Redis? Take a relatively simple example:
The Redis cluster and the Mysql are synchronized, first getting data from the redis, and then getting the data from the mysql if the redis is dead, so that the website will not die. At the same time, it also reduces the pressure on the database.
Let's show you how to install redis by hand.
1. Install gcc compilation
Because you need to compile when you install redis later, you have to install gcc compilation in advance. Gcc has been installed by default on Ali CVM. If you install your own virtual machine, you need to install gcc first:
Yum install gcc-c++
two。 Download redis
There are two ways to download the installation package, one is to download it on the official website, and then test the installation package to CentOS, the other way is to download it directly using wget.
Wget http://download.redis.io/releases/redis-3.2.9.tar.gz
If you have not installed wget, you can install it with the following command.
Yum install wget
3. Decompression and installation
It's easy to unpack the installation package, not to mention much.
Tar-vzxf redis-3.2.9.tar.gz
After decompressing, there will be a redis-3.2.9 folder, and go to this folder and execute the make command to complete the installation. If the installation fails, you can try the following command to install.
Make MALLOC=libcmake install
4. Modify the configuration file
After the installation is successful, you need to modify the configuration file, including the ip that allows access, allow background execution, set the password, and so on. The configuration file for redis is the redis.conf file in the redis-3.2.9 directory. Open this file.
Enter / bind in command mode to find the bind configuration, press n to find the next one, and after finding the configuration, configure bind to 0.0.0.0 to allow any server to access the redis, that is:
Bind 0.0.0.0
Using the same method, change daemonize to yes (default is no), allowing redis to execute in the background.
Open the requirepass comment and set the password such as 123456 (password yourself).
5. Start redis
In the redis-3.2.9 directory, specify the newly modified configuration file redis.conf to start redis:
Redis-server. / redis.conf
Since the background startup is set up, there will be no prompt message, and after the startup is complete, you can use the following command to see if redis has started successfully.
Ps-ef | grep redis
If you see a redis-server, the startup is successful. Then we start the redis client.
Redis-cli
Because we have set the password, after starting the client, enter auth 123456 to log in to the client. Then let's test it and insert a piece of data into redis.
Set name CSDN
Then get the name.
Get name
If the CSDN can be obtained normally, there is no problem.
6. Close redis
If you shut down the redis service, you can simply use the following command.
Pkill redis-server
Of course, you can also use the shutdown command on the redis client to shut down the redis service.
Summary
The above is the steps of installing redis introduced by the editor to you. I hope it will be helpful to you. If you have any questions, please leave a message for me. The editor will reply you in time. Thank you very much for your support to the website!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.