In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to install and deploy Redis in Linux". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope this article "how to install and deploy Redis in Linux" can help you solve the problem.
1. Download redis
Pull it directly using wget, or you can download the official website of redis directly from the official website.
[root@install_folder] # wget http://download.redis.io/releases/redis-5.0.7.tar.gz2, extract the file tar-avxf redis-5.0.7.tar.gz3, and move it to the installation directory [root@install_folder] # mv redis-5.0.7 / usr/local/ rediss [root @ install_folder] # cd / usr/local/redis4, Perform make compilation [root@ redis] # makecd src & & make allmake [1]: enter directory "/ usr/local/redis/src" CC Makefile.depmake [1]: leave directory "/ usr/local/redis/src" make [1]: enter directory "/ usr/local/redis/src" rm-rf redis-server redis-sentinel re
A large number of commands will be executed here, and when it is finished, you can install it.
5. Install [root@ redis] # make PREFIX=/usr/local/redis install
The function of the keyword PREFIX= is to specify the path to which the program is stored at compile time. For example, we now specify that redis must be stored in the / usr/local/redis directory. Suppose that not adding the keyword Linux will store the executable in the / usr/local/bin directory
The library files are stored in the / usr/local/lib directory. The configuration file is stored in the / usr/local/etc directory. Other resource files are stored in the usr/local/share directory. The directory specified here is also convenient for subsequent uninstallation, and the redis can be deleted by directly rm-rf / usr/local/redis.
[root@ redis] # make PREFIX=/usr/local/redis installcd src & & make installmake [1]: enter directory "/ usr/local/redis/src" CC Makefile.depmake [1]: leave directory "/ usr/local/redis/src" make [1]: enter directory "/ usr/local/redis/src" Hint: It's a good idea to run 'make test';) INSTALL install INSTALL install
The installation is complete.
6. Modify redis.conf configuration [root@ redis] # vi redis.conf
1. Modify the daemonize to run the daemon
By entering
/ add search keywords to find and modify
Such as
Click enter to find the corresponding data and press n to find the next one.
First, change daemonize to yes.
two。 Modify the specified port port
This port can not be modified, depending on your own needs.
3. Set requirepass password
4. Modify link mode protected-mode
If you need to allow external links, you must change it to no.
5. Modify bind host address
If you need a prototype component link, directly # comment it out, such as # bind 127.0.0.1
All right, the configuration has been changed.
Next:
Press Esc
Again: wq
Save changes
Here is a list of all the data for easy query.
The configuration item name configuration item value range indicates that daemonizeyes and noyes means that the daemon is enabled. The default is no, that is, it does not run as a daemon. It is not supported to run port in daemon mode under Windows system to specify Redis listening port. The default port is the host address bound with 6379bind. If you need to set remote access, you can directly comment on this attribute or change it to bind *. This attribute and the protected-mode below control whether remote access is possible. Protected-modeyes and no protection mode, which controls whether the external network can connect to the redis service. The default is yes, so by default, our public network is inaccessible. If you need to connect to the rendis service through the public network, you need to change this attribute to no. Timeout300 closes the connection when the client has been idle for how long. If 0 is specified, the log level of logleveldebug, verbose, notice and warning is disabled. The default is the number of databases set by noticedatabases16. The default database is 0. The whole rdbcompressionyes can be seen through the client tool, and no specifies whether to compress the data when it is stored in the local database. The default is that yes,Redis uses LZF compression. If you want to save CPU time, you can turn off this option, but it will cause the database file to become huge. Dbfilenamedump.rdb specifies the file name of the local database. The default value is dump.rdbdir, which specifies the local database storage directory. Requirepass sets the Redis connection password. If the connection password is configured, the client needs to provide a password through the AUTH command when connecting to Redis. By default, turn off maxclients0 and set the maximum number of client connections at the same time. By default, there is no limit. The number of client connections that Redis can open at the same time is the maximum number of file descriptors that can be opened by the Redis process. If you set maxclients 0, there are no restrictions. When the number of client connections reaches the limit, Redis closes the new connection and returns a max number of clients reached error message to the client. MaxmemoryXXX specifies the maximum memory limit of Redis. Redis will load data into memory at startup. After reaching the maximum memory, Redis will first try to clear the expired or expiring Key. When this method is processed, the maximum memory setting is still reached, and no more write operations can be performed, but read operations can still be performed. Redis's new vm mechanism stores Key in memory and Value in the swap area. XXX is a value in the range of configuration item values. 7. Start redis
Above, we modified redis.conf.
Here is to specify the configuration file to start redis
. / bin/redis-server&. / redis.conf
Or start it in the following way (the way I started it)
[root@redis] # redis-server redis.conf
Here may be a hint
-bash:. / redis.conf: insufficient permissions
You can directly
Permission to modify a folder: chmod 777 redis or chmod + x redis
8. Check ps-aux | grep redis
View startup status
Ps-aux | grep redis9, close redis [root@ redis] # redis-cli127.0.0.1:6379 > shutdown
Note that the default port for redis-cli is 6379. If the port is modified, then the link should be accompanied by-p.
Such as
[root@ redis] # redis-cli-p 678910, View the redis log [root@ redis] # redis-cli-p 6789127.0.1 slowlog get 6789 > slowlog get 5 (error) NOAUTH Authentication required.### and the following command records all queries with query time longer than 1000 microseconds: 127.0.0.1 redis-cli 6789 > CONFIG set slowlog-log-slower-than 1000 (error) NOAUTH Authentication required.127.0.0.1:6789 > auth "your password" OK## use the command SLOWLOG to view the current The number of logs is 127.0.0.1 6789 > SLOWLOG len
Note error) NOAUTH Authentication required requires you to enter a password
127.0.0.1 6789 > auth "your password"
Ok to this redis installation is complete, can be happy to use.
This is the end of the content about "how to install and deploy Redis in Linux". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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