Linux configuration Redis

Source: Internet
Author: User

This article refers to:

Http://www.cnblogs.com/HYXJavaweb/p/5217262.html?utm_source=tuicool&utm_medium=referral

Http://www.2cto.com/os/201406/307712.html

1, the installation of Redis must already have gcc installed, if you do not install gcc Use the command yum install -Y gcc

2.unpack the redis installation package and enter /etc/local/prod_src/redis-3.2.9

3. Compiling: make

4. Test installation:make test (if there is an error, install the missing component according to the error, if not, install it directly)

5.MakeInstall

  [[email protected] src]# make install

  Hint:it ' s a good idea to run ' make test ';)

  Install install .....

See this you installed successfully , meaning that the good habit is to run the test first , then we will move and modify the configuration file.

6, mobile files, easy to manage:( all the source code installed software is installed under /usr/local/prod_src )

Create two folders,bin for holding commands,conf for storing configuration files.

Move the 7 command files in the SRC directory to /usr/local/redis/bin/

Mkdir-p/usr/local/prod_src/redis-3.2.9/bin/usr/local/prod_src/redis-3.2.9/etc

CP mkreleasehdr.sh Redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb .. /bin

Copy the redis.conf under the redis-3.2.9 folder to /usr/local/redis-3.2.9/conf/

MV *.conf conf

7. start redis service
Enter the/usr/local/redis/bin/ directory to execute , the configured file starts Redis:

./redis-server usr/local/prod_src/redis-3.2.9/conf/redis.conf
redis whether to start We often need to see 6379 Whether the port is occupied If the following occurs, the service is open successfully
[[email protected] bin]# NETSTAT-TUNPL | grep 6379
TCP 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 41645/./redis-serve 
tcp6 0 0::: 6379:::* LISTEN 41645/./redis-serve 
So far, redis< Span style= "font-family: Arial" > Service has been successfully started according to the configuration file!!

8, modify redis configuration file, set up Redis can run in the background,vim redis-3.2.9/conf/redis.conf

Change daemonize to Yes . redis changes to background boot

9, installed in the redis-3.2.9 directory to execute Bin/redis-server

Then execute the SRC/REDIS-CLI in another shell window to run correctly.
But we obviously want to start the operation as a service.

10. Here is the procedure to configure Redis as a service, first copy the Utils/redis_init_script file to/etc/init.d
Cp/usr/local/redis-3.2.9/utils/redis_init_script/etc/rc.d/init.d/redis
Copy Redis_init_script to/etc/rc.d/init.d/and easily name Redis
Then Vi/etc/rc.d/init.d/redis
Add in the second line of the document
# chkconfig:2345 80 90
Then notice
Exec=/usr/local/redis/bin/redis-server
Cliexec=/usr/local/redis/bin/redis-cli
Because our installation directory is/usr/local/redis-3.2.9, the above two lines are changed to
Exec=/usr/local/redis-3.2.9/bin/redis-server
Cliexec=/usr/local/redis-3.2.9/bin/redis-cli
Also pay attention to the Redis file's
$EXEC $CONF
Here, add & at the back of Conf
$EXEC $CONF &
"&", that is, to move the service back to the meaning of running, otherwise when the service is started, the Redis service will occupy the foreground, occupying the main user interface, resulting in other commands can not be executed.

4. You can see that in the/etc/init.d/redis file, there is a line:
conf= "/etc/redis/${redisport}.conf"
The Redis configuration file is then copied to the/etc/redis/
Mkdir/etc/redis
Cp/usr/local/redis-3.2.9/redis.conf/etc/redis/6379.conf
5. After completing the above operation, you can register the service:
Chkconfig--add Redis
Then start the Redis service
Service Redis Start
Redis can be run as service mode

Linux configuration Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.