1.redis Simple Description
1.redis is a key-value storage system that supports storage of value types compared to memcached more, including string,list,set,sets,hashes, etc. (it supports data structures such as strings,hashes,lists,sets,sorted sets with range queries,bitmaps,hyperloglogs and geospatial indexes with radius q Ueies) These data types support rich operations such as Push/pop,add/remove, and these operations are atomic in nature.
2.redis and memcached, in order to ensure efficiency, data are cached in memory, the difference is that Redis will periodically write updated data to disk, and can achieve master-slave (Master-slave) synchronization. 3.redis in data storage, using the idea of NoSQL database, the key as a unique indicator of data retrieval, it can be easily understood as a relational database index key, and value as the main object of data storage, Each value has a key corresponding to it, and 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, Thus in our data query is, can only be based on key as a condition of our query. 4.redis official website: http://www.redis.io/b. Download the Redis package: http://download.redis.io/releases/redis-3.0.5.tar.gzC.redis is implemented in the C language, so you need to install GCC in Linux system to compile, please refer to the third step for installing GCC. D. The next need to install the UNIX TCL tool, if not installed later we will not be able to test Redis, after the installation of make test error, install TCL please refer to the 4th step, TCL package is:/http Downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gzE. After installing the required packages above, you can install Redis, please refer to the 5th step. F. Required software and system as follows: Virtual machine (Vmware), CentOS system installed in virtual machine, Xshell,xftp,redis package, TCL packageInstallation of 3.GCC
A. With the above preparation, we now have an environment that can be installed and released, and if not, check the installation yourself.
B. Install gcc under CentOS, we install with Yum (Package manager) because GCC relies on a lot of things, and some package systems may already be installed, some of them are not, so the following commands are executed at the end and execute the following command in Xshell:b.1 Yum Install CPPb.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 makeNote: All of the above package information will be prompted when the installation is complete, if it is not completed, but nothing to do, then the server has installed this package, do not need to install again, so it doesn't matter, continue to execute the next command. C. If there is no error during installation, the installation of GCC is complete and TCL is installed below. Installation of 4.TCL
A. In Xshell, use the command to jump to local to create your own folder: Kencery
A.1 CD usr/local/mkdir kencery CD kencery/B. Then use XFTP to copy the TCL package to the Kencery folder under the ready-to-Work download:
C. Unzip the uploaded TCL package and rename it to Tcl after decompression.
C.1 TAR-ZXVF tcl8.6.3-src.tar.gzC.2 MV tcl8.6.3 tclC.3 CD tclD. Use the following command to install after the decompression is complete, the order of command execution according to my written. D.1 CD unix/D.2./configureD.3 MakeD.4 make installE. In the process of execution if there is no error, wait patiently, these commands are not placed here, according to the order I wrote. Installation of 5.redisA. With the steps above, the preparation is complete, and Redis is ready to begin installation. B. Use xftp to copy the Redis package downloaded under preparation to the Kencery folder:
C. Unzip the uploaded Redis package and rename it to Redis after decompression:
C.1 TAR-ZXVF redis-3.0.5.tar.gzC.2 MV redis-3.0.5 RedisC.3 CD RedisD. Once the package has been unzipped, it can be installed and the command is installed (performed under Redis directory):D.1 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 execute make has an error, and when you execute make again, we recommend that you clean it up in execution, and the command is: make. D.2 CD Src/make Test(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 question If it appears: The test does not have a 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.
D.3 make installThe final implementation of make install, without errors, indicates that the Redis installation was successful:
Test of 6.redisA. 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:B.1 Src/redis-server & Start Redis, plus & means Redis is running in daemon modeB.2 redis-server/usr/local/kencery/redis/redis.conf Start Redis
b.3 src/redis-cli shutdown turn off Redisb.4 Enter the command to start Redis and start Redis:
B.5 after 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.
B.6 Connect Redis and test, Connection command for: SRC/REDIS-CLI, final Test result:
B.7 to here Reids installation and testing work is complete.
Server startup and shutdown for Redis set up in 7.Linux
A. 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:
# Date .- .- +# Chkconfig:2345 Ten -# Description:start and Stop Redis PATH=/usr/local/kencery/redis/src:/sbin:/usr/bin:/bin Redisport=6379EXEC=/usr/local/kencery/redis/src/redis-Server Redis_cli=/usr/local/kencery/redis/src/redis-CLI Pidfile=/var/run/redis.pid CONF="/usr/local/kencery/redis/redis.conf"AUTH="1234" Case " $" inchstart)if[ -F $PIDFILE] then echo"$PIDFILE exists, process is already running or crashed." ElseEcho"starting Redis Server ..."$EXEC $CONF fiif["$?"="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 $REDISPORT SHUTDOWN 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, using a script file can be executed, the command is: 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:D.1 Service Redis start to turn on Redis servicesD.2 service Redis stop off Redis services
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 8.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/kencery/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 onD. When the above steps are complete, you can restart Linux and follow the previous test to start automatically with the machine.
Linux (Centos) installation Redis and considerations