In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the installation and configuration steps of redis in the Linux system, the content of the article is of high quality, so share it with you for reference. I hope you can get something after reading this article.
Part one: install redis
Want to install redis to this directory
/ usr/local/redis
Want to download the installation package to this directory
/ usr/local/src
Then the installation process instructions are as follows:
$mkdir / usr/local/redis $cd / usr/local/src $wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz $tar xzf redis-2.6.14.tar.gz $ln-s redis-2.6.14 redis # create a link $cd redis $make PREFIX=/usr/local/redis install # install to the specified directory
Notice that in the last line above, we specified the installation directory through PREFIX. If make fails, generally speaking, gcc is not installed on your system, then you can install it through yum:
Yum install gcc
After the installation is complete, continue to execute make.
After installing redis successfully, you will see a bin directory in / usr/local/redis that contains the following files:
Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
Part two: make redis into a service
1. Copy the script to the / etc/rc.d/init.d directory
When you install Redis by following the steps above, its service script is located at:
/ usr/local/src/redis/utils/redis_init_script
It must be copied to the directory of / etc/rc.d/init.d:
Cp / usr/local/src/redis/utils/redis_init_script / etc/rc.d/init.d/redis
Copy redis_init_script to / etc/rc.d/init.d/, and rename it to redis.
If you add a registration service at this time:
Chkconfig-add redis
The following error will be reported:
Redis service does not support chkconfig
To do this, we need to change the redis script.
2. Change the redis script
Open the script using vi to view the script information:
Vim / etc/rc.d/init.d/redis
What you see is as follows (the following is the changed information):
#! / bin/sh # chkconfig: 2345 80 90 # Simple Redis init.d script conceived to work on Linux systems # as it does use of the / proc filesystem. REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_$ {REDISPORT} .pid CONF= "/ 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
Compared to the original profile:
1. The original file does not contain the following line 2
# chkconfig: 2345 80 90
two。 The parameters of the original file EXEC and CLIEXEC have also been changed.
EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli
The command opened by 3.redis is executed in the background.
$EXEC $CONF &
Ps: pay attention to the following "&", which means to transfer the service to run later, otherwise, when the service is started, the Redis service will
Occupy the foreground, occupy the main user interface, so that other commands can not be executed.
4. Copy the redis configuration file to / etc/redis/$ {REDISPORT} .conf
Mkdir / etc/redis cp / usr/local/src/redis/redis.conf / etc/redis/6379.conf
In this way, the CONF specified by the redis service script exists. By default, Redis does not enable authentication, and you can specify an authentication password through the requirepass that turns on 6379.conf.
After the above operations are completed, you can register the yedis service:
Chkconfig-add redis
5. Start the redis service
Service redis start
Third, add the directory where the Redis command resides to the system parameter PATH
Modify the profile file:
Vi / etc/profile
Append to the last line:
Export PATH= "$PATH:/usr/local/redis/bin"
Then apply this file immediately:
. / etc/profile
This allows you to invoke the redis-cli command directly, as shown below:
$redis-cli redis 127.0.0.1 ping PONG redis 6379 > ping PONG redis 127.0.0.1
At this point, redis is successfully installed.
To sum up: when you install redis in a linux system, you will encounter some problems more or less. Most of the three in this installation
1, download, install, here to use the wget command, make command, I do not quite understand the use of the make command, and have been worried about how to install the make command to the specified directory, this time finally understand.
2, how to add a program to the service, of course, also know something about the file / etc/rc.d/init.d.
3. How to add some commands of a program to the system parameters, and directly enter the command to achieve the operation of a program.
In fact, it is to specify a good environment variable.
These are the steps for the installation and configuration of redis in the Linux system. Have you learned anything after reading it? If you want to know more about it, you are welcome to follow the industry information. Thank you for reading.
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.