Centos7 install Redis-single-node tutorial, centos7redis-node
1. Download and install gcc
Because Redis is developed in C language, the source code downloaded from the official website needs to be compiled and compiled based on the gcc environment. If there is no gcc environment, you need to install it.
[root@CentOS ~]# yum -y install gcc
2. Download The redis installation package 3. decompress the installation package
[Root @ CentOS local] # tar-zxvf redis-4.0.8.tar.gz # unzip the installation package redis-4.0.8/redis-4.0.8 /. gitignoreredis-4.0.8/00-RELEASENOTESredis-4.0.8/BUGSredis-4.0.8/CONTRIBUTINGredis-4.0.8/COPYINGredis-4.0.8/MANIFESTO ...... (skip the content )...... [root @ CentOS local] # ll # view the total usage of directory file information: 1696drwxr-xr-x. 2 root 6 February 24 16:18 bindrwxr-xr-x. 2 root 6 May November 5 2016 etcdrwxr-xr-x. 2 root 6 August 2016 gamesdrwxr-xr-x. 2 root 6 August 2016 includedrwxr-xr-x. 2 root 6 December November 5 2016 libdrwxr-xr-x. 2 root 6 November 5 2016 lib64drwxr-xr-x. 2 root 6 November 5 2016 libexecdrwxrwxr-x. 6 root 4096 February 3 00:39 redis-4.0.8 # This directory is the directory after decompression-rw-r --. 1 root 1729973 February 3 00:40 redis-4.0.8.tar.gzdrwxr-xr-x. 2 root 6 December November 5 2016 sbindrwxr-xr-x. 5 root 49 January 30 14:30 sharedrwxr-xr-x. 2 root 6 May November 5 2016 src [root @ CentOS local] #
4. Compile and install the file
[Root @ CentOS local] # cd redis-4.0.8/# enter the decompressed directory [root @ CentOS redis-4.0.8] # make # execute the compilation ...... (skip the content )...... CC lazyfree. o CC module. o CC evict. o CC expire. o CC geohash. o CC geohash_helper.o CC childinfo. o CC defrag. o CC siphash. o CC rax. o LINK redis-server INSTALL redis-sentinel CC redis-cli.o LINK redis-cli CC redis-benchmark.o LINK redis-benchmark INSTALL redis-check-rdb INSTALL redis-check-aofHint: it's a good idea to run 'make test';) # If the compilation is successful, the message "make [1]" is displayed. leave the directory "/usr/local/redis-4.0.8/src" [root @ CentOS redis-4.0.8] # make install # execute the installation, by default, it is installed in the/usr/local/bin directory cd src & make installmake [1]: Enter the directory "/usr/local/redis-4.0.8/src" CC Makefile. depmake [1]: Exit directory '/usr/local/redis-4.0.8/src' make [1]: Go to directory '/usr/local/redis-4.0.8/src' Hint: it's a good idea to run 'make test';) # If the installation is successful, the message "INSTALL install INSTALL installmake [1]" is displayed. leave directory "/usr/local/redis-4.0.8/src" [root @ CentOS redis-4.0.8] #
5. Set redis as a system service and start it on startup
[Root @ CentOS redis-4.0.8] #. /utils/install_server.sh # Run the install_server.sh script, then press enter to confirm that the default configuration is used. Then, you can Welcome to the redis service installerThis script will help you easily set up a running redis serverPlease select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379. conf] Selected default-/etc/apsaradb for redis/6379. confPlease select the redis l Og file name [/var/log/redis_62.16.log] Selected default-/var/log/redis_62.16.logplease select the data directory for this instance [/var/lib/redis/6379] Selected default- /var/lib/redis/6379 Please select the redis executable path [/usr/local/bin/redis-server] Selected config: port: 6379 Config file:/etc/redis/6379. conf # redis instance default configuration file Log file:/var/log/redis_62.16.log # redis instance Log file Data dir :/ Var/lib/redis/6379 # data storage directory of the redis instance Executable:/usr/local/bin/redis-server # redis_server execution path Cli Executable: /usr/local/bin/redis-cli # redis_cli execution path Is this OK Then press ENTER to go on or Ctrl-C to abort. copied/tmp/6379. conf =>/etc/init. d/redis_61_installing service... successfully added to chkconfig! Successfully addedto runlevels 345! Starting Redis server... Installation successful! # Prompt has been installed successfully [root @ CentOS redis-4.0.8] #
6. Edit the default configuration file of the redis instance. modify the configuration items as follows:
Daemonize yes # Run bind 0.0.0.0 using the redis instance as the background process # allow any remote host to access requirepass 123456 # Login Password
7. Restart the redis service and add Port 6379 to the firewall.
[Root @ CentOS redis-4.0.8] # service redis_6379 restart # restart redis service Stopping... redis stoppedStarting Redis server... [root @ CentOS redis-4.0.8] # firewall-cmd -- zone = public -- add-port = 6379/tcp -- permanent # add port 6379 to the firewall success [root @ CentOS redis-4.0.8] # firewall -cmd -- reload # reload the Firewall Information success [root @ CentOS redis-4.0.8] #
8. Use jedis for client Testing