Install Redis in Linux (Centos) and precautions
1. redis simple description a. Previously I mentioned that redis is encapsulated into a shared class. 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. redis Official Website: http://www.redis.io/2. preparations. 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 The redis Package c. redis is implemented in c language. Therefore, you need to install gcc in Linux for compilation. For gcc installation, see step 3. 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 the installation is complete, make test will report an error. for installation of tcl, see Step 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 binutilsb.3 yum install glibc-kernheadersb.4 yum install glibc-commonb.5 yum install glibc-develb.6 yum install gccb.7 yum install make note: all of the above package information will prompt Complete upon installation completion, if there is no Complete but Nothing to do, it indicates that this package has been installed on the server and does not need to be installed again. So it doesn't matter. Continue to 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. in Xshell, run the command 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 into the file, save and exit: redis 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.. in most cases, we need to enable redis automatically when the server is restarted, instead of manually enabling it. 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.