In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what are the high-level practical commands of Redis in NoSQL", which are easy to understand and clear, hoping to help you solve your doubts, the following let the editor lead you to study and learn what are the advanced practical commands of Redis in NoSQL?
First, security
Set the password for redis: set a practical password before making any other assignments after the client connects.
Warning: because redis is very fast, under a better server, an external user can try 150k passwords per second, which means you need to specify a very powerful password to prevent brute force cracking.
How to change the password:
You only need to enable requirepass in the configuration file redis.conf of redis. For example, I set my access password to mypassword.
Requirepass mypassword
After adding this line of code to redis.conf, we kill the original redis process: pkill redis and restart redis:/usr/local/redis-2.8.1/src/redis-server / user/local/redis-2.8.1/redis.conf
Then we use / usr/local/redis-2.8.1/src/redis-cli to find that we can still log in, but when we perform an operation, such as keys *, there will be the following error:
127.0.0.1 6379 > keys *
(error) NOAUTH Authentication required.
There is no necessary authorization verification.
Here, redis supports two authorization methods. One is to authorize directly with the auth command:
The first time you enter a wrong password test, authorization fails, the second time you enter the correct password, return ok, authorization is successful, and then all operations can be carried out.
If we don't want to use auth for authorization every time we log in, then we can use another authorization method, which is to use-a to specify the password when logging in to the client.
Sh-3.2# / usr/local/redis-2.8.1/src/redis-cli-a mypassword
If the above password is typed incorrectly, it can also be entered, but it cannot be operated later. Re-authorization is required with auth.
Second, master-slave replication
Redis master-slave replication is very simple to configure and use. Master-slave replication allows multiple slave server to have the same database replica as master server.
The characteristics of redis master-slave replication:
1. A master can have multiple slave (1-to-many relationships)
two。 Multiple slave can be connected not only to the same master, but also to other slave (this is because if one of the slave can act as master immediately after the masterdown is dropped, so that the whole service process is not affected)
3. Slave replication in does not block master, and master can continue to process client requests while synchronizing data.
4. Improve the scalability of the system
The process of redis master-slave replication:
1.slave establishes a connection with master and sends sync synchronization commands.
2.Master starts a background process to save the database snapshot to a file, while the master main process starts collecting new write commands and caching them.
3. After the background finishes saving, send the file to slave
4.slave saves the file to the hard drive
Configure the master and slave servers:
Configuring the slave server is easy, as long as you add the following configuration to the configuration file of slave:
Slaveof masterip masterport
If login authentication is enabled on the host, the following sentence needs to be added:
Masterauth authpassword
Then start the slave, first the master sends a snapshot to the slave, the database of the slave will be updated to the same state as the host, and then write to the host, and the slave will be updated accordingly.
If we are writing data from the computer, we will report an error:
(error) READONLY You can't write against a read only slave.
We can use the info command to view the information of the master and slave servers, and the info command on the slave machine can see
Role:slave
Master_host:masterip
Master_port:masterport
Master_link_status:up proves that it is connected to the host.
Use the info command on the host
Role:master
Several slave computers are connected at the same time.
Connected_slaves:1
At the same time, you can view the ip and online status of the slave connected to the host
Slave0:ip=192.168.1.107,port=6379,state=online,offset=1709,lag=1
The above is all the contents of the article "what are the advanced practical commands of Redis in NoSQL?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.