Linux installation Redis

Source: Internet
Author: User
Tags install redis redis server

1.redis Simple Description

In data storage, Redis uses the idea of a NoSQL database, which is a unique indicator of data retrieval, which can be simply understood as the key of the index in the relational database, and value as the main object of the data storage, where each value has a key corresponding to it. In Redis, value is treated as a binary byte stream for storing data in any format, such as Json,xml, picture, and Byte stream of serialized objects, so we can also think of it as a blob type field in an RDB, so that when we do a data query, Can only be based on key as a condition of our query.

Redis Official website: http://www.redis.io/2. Preparatory work. Download the Redis package: http://download.redis.io/releases/redis-3.0.5.tar.gz. To Redis official website: http://www.redis.io/3. Installation must plug-in
Yum Install CPP  Yum Install binutils Yum Install glibc-kernheadersyuminstall glibc-commonYum  Install glibc-develyuminstallgccYum Install  Make

Installation of 3.redis

After a few steps above, the preparation is complete and you can start to install Redis.

   Unzip the uploaded Redis package and rename it to Redis after decompression,:
tar -zxvf redis-3.0. 5. Tar  mv redis-3.0. 5  /usr/local/Rediscd/usr/local/redis

Once the package has been unpacked, you can start installing it, with the command installed (performed in the Redis directory):
Make
(1) In the practice of typing make error, but now write blog when the deployment does not appear error, if there is an error, please use this command (made MALLOC=LIBC) can be executed, because there is no error, so no, if you encounter words to me, thank you. (2) If the Execute make error occurs, we recommend that you clean up the execution, and the command is executed.
 Make Clean
CD src/ make
(1) After you have finished making, the final program will output (t ' a good idea to run ' make test '), it is recommended that we perform the test by making test, then we will enter makes test, check the test, whether there is a problem,      If it appears: the test has no problem: (2) When I enter make test execution, I will be wrong when I practice, but this error does not affect our test, so we can ignore it. Final execution
 Make Install
, the Redis installation succeeds if the error does not occur:test of 5.redis    A. After you install Redis, you need to test, and here's a simple test to verify that our Redis installation is successful. B. First we start the Redis service and start and close the Redis Service command as follows:
Src/redis-server &                                     #启动redis, plus & means Redis is running in daemon mode-server/usr/local/redis/redis.conf              #启动redis
Start Redis,: 3 When Redis boot is complete, use NETSTAT-NTLP |grep 6379 to see if the port is in use, and if it is in use, the installation is successful or the installation is unsuccessful. 4 Connect Redis and test, Connection command for: SRC/REDIS-CLI, final Test result: here Reids's installation and testing work has all been done.server startup and shutdown for Redis set up in 6.LinuxA. As mentioned above, we have completed the installation of Redis, and then we can follow the above methods, but there are still some small problems, that is, after the Linux system restarts need to find the installation path to execute the boot command, then we can set the form of service to start Redis? B. Execute command: Vim/etc/init.d/redis, create a script file, write the following code in the file, save and exit:
#chkconfig:2345#The Redis service must be started or shut down at run-level 2,3,4,5, with a priority of 90, and a shutdown of 10. #Description:start and Stop RedisPATH=/usr/local/redis:/sbin:/usr/bin:/binexport PATH Redisport=6379#port number, which is the default, if you do not install the default port number, you need to modifyExec=/usr/local/bin/redis-server#Redis-server The location of the startup script, you can find it with Find or whereis if you forgetRedis_cli=/usr/local/bin/redis-cli#REDIS-CLI The location of the client startup script, you can find it with Find or whereis if you forgetPidfile=/var/run/redis.pid#This can also be found with Find or Whereis .conf="/usr/local/redis/redis.conf" #redis.conf The location of the configuration file, you can find it with Find or whereis if you forgetAuth="1234" Case" $" inchstart)if[- F $PIDFILE] then echo"$PIDFILE exists, process is already running or crashed."        ElseEcho"starting Redis Server ..."            $EXEC $CONFfiif["$?"="0"] then echo"Redis is running ..."fi;; Stop)if[ !- F $PIDFILE] then echo"$PIDFILE exists, process is not running."        ElsePID=$ (cat$PIDFILE) echo"stopping ..."            $REDIS _cli-P$REDISPORTSHUTDOWN Sleep2 while[-X$PIDFILE ]               DoEcho"waiting for Redis to shutdown ..."Sleep1Done Echo"Redis stopped"fi;; Restart|force-Reload)${0}Stop${0}start;; *) echo"Usage:/etc/init.d/redis {start|stop|restart|force-reload}">&2Exit1Esac
C. Add permissions to the file, which can be executed using a script file, with the following commands:
chmod 755 /etc/init.d/redis
D. The above work successfully completed and no error occurred, the configuration is complete, each time we turn on the following two commands can be entered to start and close the Redis service:
service redis start       #开启redis服service redis stop        #关闭redis服务
F. When the service is turned on, you can either connect to the Redis test or use another client to operate Redis, testing: set up Redis's boot boot in 7.Linux

A. In most cases, we need to automatically turn on Redis when the server restarts, not when we manually turn it on, so let's say the startup auto-start setting.

B. First set the daemonize in Redis.config to Yes to ensure that the daemon is turned on and execute the following command:B.1 CD Usr/local/redisb.2 vim redis.conf Open config file, find daemonize attribute wine set to Yes, save and exit. C. Then set the boot up command:
chkconfig Redis on
D. When the above steps are complete, you can restart Linux and follow the previous test to start automatically with the machine.

Linux installation 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.