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 > Database >
Share
Shulou(Shulou.com)06/01 Report--
Installation environment:
Linux:centos6.9 64 bit
Redis version: redis-4.0.2.tar.gz
Redis installation
Redis official website address: http://www.redis.io/
The latest version is 4.0.2.
1. Download the source code, decompress and compile the source code
[root@localhost ~] # wget http://download.redis.io/releases/redis-4.0.2.tar.gz
[root@localhost ~] # tar-xfredis-4.0.2.tar.gz
[root@localhost ~] # cd redis-4.0.2
[root@localhost redis-4.0.2] # make compilation
2. After the make compilation is completed, we see the following interface, which shows that we have successfully installed it.
We will see several more executable files in the redis-4.0.2/src directory, of which redis-server is used to start the service, redis-cli is used to start the client, the rest is not clear, you can check.
After the default make, if we start the redis service, we have to go to the installation directory every time, which is very tedious, so we can execute make install after make and put the generated binaries in the / usr/local/bin directory.
Make install
1. Make install will generate a file under the / usr/local/bin path (the one I run), and the redis executable will be copied to / usr/local/bin/
2. Make PREFIX=/opt/redis install specifies the installation directory, which will generate a bin path under / opt/redis. Here are the executable files.
Note: if an ordinary user needs root permission to execute make install, use sudo make install
3. Set up services
First copy the redis-4.0.2/utils/redis_init_script file to / etc/init.d and rename it to redis. Execute a command
Cp redis-4.0.2/utils/redis_init_script / etc/init.d/redis
Vi / etc/rc.d/init.d/redis
Add in the second line of the document
# chkconfig: 234580 90 .
Make sure there are redis-server and redis-cli files in / usr/local/redis/bin (if someone installed without using the make install command, you need to copy redis-server and redis-cli to the / usr/local/redis/bin directory in the installation directory, otherwise you won't find redis-server when the service starts) as shown in the second red box below.
You can see this line in the / etc/init.d/redis file: CONF= "/ etc/redis/$ {REDISPORT} .conf". So copy the redis configuration file to / etc/redis/ and rename it to 7200.conf.
Mkdir / etc/rediscp redis-4.0.2/redis.conf / etc/redis/7200.conf copy redis.conf to the installation directory cp redis.conf / opt/redis Note: CONF= "/ etc/redis/$ {REDISPORT} .conf" here you need to modify the configuration file of your installation path
4. Modify 7200.conf configuration file
# specify the port under which redis runs. Default is 6379port 7200#daemonize no. By default, redis does not run in the background. If you need to run in the background, change the value of this item to yesdaemonize yes # when redis is running in the background, Redis will put the pid file in / var/run/redis.pid by default, and you can configure it to another address. # when running multiple redis services, you need to specify different pid files and ports # pidfile / var/run/redis_6379.pid pidfile / var/run/redis_7200.pid # specify that redis only receives requests from this IP address. If it is not set, then all requests will be processed. # it is best to set the timeout period (in seconds) for setting client connections for this item # bind 127.0.0.in production environment. When the client does not issue any instructions during this period, closing the connection # 0 closes this setting timeout 0 # specifies the logging level # Redis supports a total of four levels: debug, verbose, notice, warning. By default, verbose# debug records a lot of information, which is used to develop and test useful information for # varbose, unlike debug to record as many common verbose as # notice. Commonly used in production environment # warning only very important or serious information will be recorded to the log loglevel debug # configuration log file address # default value is stdout, standard output, if the background mode will be output to / dev/null# to generate the default log file location # logfile "" logfile "/ var/log/redis/redis.log" # configuration persistence file location dir / opt/data/redisData
5. Two ways to start in the background
By default, the redis startup service monopolizes the input screen. There are two ways to start it in the background:
A. Find $EXEC $CONF in / etc/init.d/redis and add a & after it means let redis start b as a background service and modify the configuration file of redis. Conf (/ etc/redis/7200.conf) will configure whether some options are started in the foreground or background, if the background startup is set to yes)
6. Join service service management
Once you have done the above, you can register for the service:
Chkconfig-add redis
Then start the redis service
Service redis start
So we have registered the redis service.
If service redis stop, prompt / var/run/redis_7200.pid does not exist, process is not running
This shows that there is no this file under run. We really do not have this file before we go to / var/run, but there is a redis.pid file.
Solution:
A, modify the redis_$ {REDISPORT} .pid in the / etc/rc.d/init.d/redis file to redis.pidb, modify the pidfile / var/run/redis.pid in the 7200.conf configuration file to pidfile / var/run/redis_7200.pid, generate pid before deletion, and restart will generate the redis_7200.pid file.
In this way, after we restart the service, we can turn it off with this command. At this point, our redis service is installed and a service is ready.
The above is the whole process of installing Redis under Linux. I hope it will be helpful for you to install Redis.
Redis startup script is attached:
#! / bin/sh# chkconfig: 2345 80 90 percent # Simple Redis init.d script conceived to work on Linux systems# as it does use of the / proc filesystem.REDISPORT=7200EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-cliPIDFILE=/var/run/redis_$ {REDISPORT} .pidCONF = "/ etc/redis/$ {REDISPORT} .conf" case "$1" in start) if [- f $PIDFILE] then echo "$PIDFILE exists Process is already running or crashed "else echo" Starting Redis server... "$EXEC $CONF & fi Stop) if [!-f $PIDFILE] then echo "$PIDFILE does not exist Process is not running "else PID=$ (cat $PIDFILE) echo" Stopping... "$CLIEXEC-p $REDISPORT shutdown while [- x / proc/$ {PID}] do echo" Waiting for Redis to shutdown... " Sleep 1 done echo "Redis stopped" fi;; *) echo "Please use start or stop as first argument";; esac
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.