Install Redis in Linux (Centos) and precautions: centosredis

Source: Internet
Author: User
Tags download redis install redis redis server

Install Redis in Linux (Centos) and precautions: centosredis
1. Simple Description of redis

A. As I mentioned earlier, redis is encapsulated into a shared class. The address is http://www.cnblogs.com/hanyinglong/p/redis.html.

B. redis is a key-value storage system that supports more value types than Memcached, including string, list, set, sets, and hashes (It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queies) These data types support multiple operations, such as push, pop, Add, and remove, these operations are atomic. C. redis and Memcached are the same. To ensure efficiency, data is cached in the memory. The difference is that redis periodically writes updated data to the disk and can implement master-slave synchronization. D. redis adopts the NoSql Database concept in terms of data storage, that is, the Key is the unique identifier of Data Retrieval. It can be simply understood as the index Key in a relational database, value is the primary object for data storage. Each Value corresponds to a Key. In Redis, Value is considered as a binary byte stream used to store data in any format, for example, Json, XML, images, and serialized object byte streams. Therefore, we can think of them as Blob fields in RDB, so that we can query the data as follows, key-Based Query conditions can only be set. E. Official redis Website: http://www.redis.io/2.

A. after the above instructions, we can start to install redis in the linux system. During the installation of redis, I encountered some problems, but all solved them, originally, I wanted to write directly and encountered an error leading to what needs to be installed, but it was not very easy to write, so I still prepared these software in front of me, when installing redis, you can install redis to verify if there will be any problems.

B. Download redis package: http://download.redis.io/releases/redis-3.0.5.tar.gz c. redis is implemented in c language, so in the Linux system need to install gcc to compile, install gcc please refer to the third step. D. next, we need to install the Unix Tcl tool. If it is not installed, we will not be able to test Redis in the future. After installation, make test will report an error. For details about how to install tcl, refer to step 1, the tcl package is: http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz e. after installing the required packages, you can install redis. For more information, see step 1. F. The required software and systems are as follows: Virtual Machine (Vmware), Centos system installed in the virtual machine, Xshell, Xftp, redis package, and tcl package. 3. Install gcc

A. After the above preparations, we now have an environment for installation and release. If not, please check the installation on your own.

B. to install gcc under centos, we use yum (Package Manager). Because gcc depends on many things, some package systems may have been installed, and some do not, therefore, the following commands are executed at the end, and the following commands are executed in Xshell: B .1 yum install cpp B .2 yum install binutils B .3 yum install glibc-kernheaders B .4 yum install glibc-common B .5 yum install glibc-devel B .6 yum install gcc B .7 yum install make remarks: all the above package information will prompt the Complete when the installation is Complete. If there is no Complete but Nothing to do, it indicates that the package has been installed on the server and does not need to be installed again, so it doesn't matter. Just execute the next command. C. If no error is reported during the installation process, it indicates that the gcc installation is complete. Continue to install tcl. 4. Installation of Tcl

A. Run the command in Xshell to jump to the local directory and create your own folder: kencery

A.1 cd usr/local/mkdir kencery cd kencery/B. use Xftp to copy the tcl package downloaded during preparation to the kencery Folder: c. decompress the uploaded tcl package, decompress it, and rename it to tcl, c.1 tar-zxvf tcl8.6.3-src.tar.gz c.2 mv tcl8.6.3 tcl c.3 cd tcl d. after decompression, run the following command to install the tool. The command execution sequence is as follows. D.1 cd unix/d.2. /configure d.3 make d.4 make install e. if no error occurs during execution, please wait patiently. These commands will not be placed here and can be executed in the order I write. 5. Install redis

A. After completing the preceding steps, you can start to install redis.

B. use Xftp to copy the redis package downloaded under preparation to the kencery Folder: c. decompress the uploaded redis package, decompress it and rename it to redis: c.1 tar-zxvf redis-3.0.5.tar.gz c.2 mv redis-3.0.5 redis c.3 cd redis d. after the package is decompressed, you can start to install it. The installation command is (executed in the redis directory): d.1 make (1) an error occurred when entering make during the exercise, but there is no error in the deployment during blog writing. If an error occurs, use this command (make MALLOC = libc) to execute it, no error occurred. If you have any questions, please leave a message. Thank you. (2) If an error occurs when you execute make again, we recommend that you clean up and execute the command: make clean. D.2 cd src/make test (1) After the make statement is executed, the output (t's a good idea to run 'make test') in the final program is displayed '), it is recommended that we execute make test for testing. Then we enter make test to check whether there is a problem. If yes, the test is normal: (2) when entering make test for execution, I will encounter an error during the exercise, but this error does not affect our test, so we can ignore it. D.3 make install: Execute make install. If no error occurs, the redis installation is successful. redis Test. after installing redis, You need to perform a test. Here is a simple test to verify whether our redis is successfully installed. B. first, we start the redis service, start and close the redis service command: B .1 src/redis-server & start redis, add & to enable redis to run B .2 src/redis-cli shutdown to close redis B .3 and enter the command to start redis, use netstat-ntlp | grep 6379 to check whether the port is in use. If the port is in use, the installation is successful. Otherwise, the installation fails. B .5 connect to and test redis. The connection command is src/redis-cli. The final test result is B .6. Here, all reids installation and testing are completed. 7. set redis server in Linux to start and close. as described above, we have completed the installation of redis, and then we can use it according to the above method, but there are still some small problems, that is, after the linux system is restarted, you must find the installation path to execute the startup command. Can we set to start redis in the form of a service? B. run the command: vim/etc/init. d/redi: Create a script file, write the following code in the file, save and exit: 1 # Date 2 # chkconfig: 2345 10 90 3 # description: start and Stop redis 4 5 PATH =/usr/local/kencery/redis/src:/sbin:/usr/bin: /bin 6 REDISPORT = 6379 7 EXEC =/usr/local/kencery/redis/src/redis-server 8 REDIS_CLI =/usr/local/kencery/redis/src/redis-cli 9 10 PIDFILE =/var/run/redis. pid 11 CONF = "/usr/local/kencery/redis. conf "12 AUTH =" 1234 "13 case" $1 "in 14 start) 15 if [-f $ PIDFILE] 16 then 17 echo" $ PIDFILE exists, process is already running or crashed. "18 else 19 echo" Starting Redis server... "20 $ EXEC $ CONF 21 fi 22 if [" $? "=" 0 "] 23 then 24 echo" Redis is running... "25 fi 26; 27 stop) 28 if [-f $ PIDFILE] 29 then 30 echo" $ PIDFILE exists, process is not running. "31 else 32 PID = $ (cat $ PIDFILE) 33 echo" Stopping... "34 $ REDIS_CLI-p $ redisport shutdown 35 sleep 2 36 while [-x $ PIDFILE] 37 do 38 echo" Waiting for Redis to shutdown... "39 sleep 1 40 done 41 echo" Redis stopped "42 fi 43; 44 restart | force-reload) 45 $ {0} stop 46 $ {0} start 47 ;; 48 *) 49 echo "Usage:/etc/init. d/redis {start | stop | restart | force-reload} "> & 2 50 exit 1 51 esacRedis script c. add permissions to the file. Run the following command in the script file: chmod 755/etc/init. d/redis d. if the above work is successfully completed and no error is reported, the configuration is complete. After each boot, you can enter the following two commands to start and stop the redis service ,: d.1 service redis start enable redis service d.2 service redis stop disable redis service f. after the service is enabled, you can connect to redis for testing or use other clients to operate redis. Test: 8. set redis startup in Linux

A. In most cases, we need to enable redis automatically when the server is restarted, instead of manually enabling redis. Let's talk about the Automatic startup settings.

B. first, set redis. in config, set daemonize to yes to ensure that the daemon is enabled. Run the following command: B .1 cd usr/local/kencery/redis B .2 vim redis. open the configuration file in conf, find the daemonize attribute wine set to yes, save and exit. C. Then set the boot start command: chkconfig redis on d. After the above steps are completed, you can restart Linux and then test whether the random device is automatically started according to the previous test. Next, we will continue to learn about redis. Next, we will continue to improve every day. If any problem exists in this article, you are welcome to point it out and I will modify it as soon as possible. If you don't give up, I will never leave

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.