Redis installation and configuration single-instance chapter

Source: Internet
Author: User

I. Introduction of Redis

Redis is an open-source (BSD-licensed), in-memory data structure storage system that can be used as a database, cache, and message middleware. It supports multiple types of data structures, such as string (strings),Hash (hashes),list (lists),collection (sets),ordered set (sorted sets)with scope queries,bitmaps,Hyperloglogsand theGeo-space (geospatial)Index RADIUS query. Redis has built-incopy (replication),Lua script (Lua scripting),LRU Drive Event (LRU eviction),transactions (transactions)and different levels ofdisk Persistence (persistence), and throughRedis Sentinel (Sentinel)and AutomaticPartitioning (Cluster)provides high availability (HI availability).

II. Introduction of installation Environment

Operating system: CentOS 6.5 (kernel version 2.6.32-431.el6.x86_64)

Cache database: Redis 3.0.7

Iii. installation of Redis

1. Create a tool catalogue (it is necessary to develop good habits)

[Email protected] ~]# mkdir-p/home/oldcat/tools

2. Create a Redis installation directory

[Email protected] ~]# mkdir-p/application/redis-3.0.7

3. Upload the downloaded Redis installation package to the tool directory (or download it directly to the tool directory using the wget command) and unzip

[Email protected] tools]# lsredis-3.0.7.tar.gz[[email protected] tools]# tar xf redis-3.0.7.tar.gz [[email protected] to ols]# CD Redis-3.0.7[[email protected] redis-3.0.7]# ls00-releasenotes BUGS contributing COPYING deps INSTALL Makefi Le MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils

3. Installing the Redis Dependency package

[email protected] redis-3.0.7]# Yum install-y gcc tcl

4. Compiling and installing Redis

[email protected] redis-3.0.7]# make ... Content omitted [[email protected] redis-3.0.7]# make install prefix=/application/redis-3.0.7/... Content omitted

5. Configure Soft Links

[Email protected] ~]# ln-s/application/redis-3.0.7//application/redis

Iv. Configuring Redis

1. Configure environment variables and take effect

[Email protected] bin]# echo "Path=/application/redis/bin: $PATH" >>/etc/profile[[email protected] bin]#. /etc/profile

2. Create a Redis profile directory and copy the relevant configuration file

[Email protected] bin]# mkdir/application/redis/conf[[email protected] bin]# cp/home/oldcat/tools/redis-3.0.7/ REDIS.CONF/APPLICATION/REDIS/CONF/6379.CONF # Redis Single-instance mode modified file name is not required

3. Modify the relevant parameters in the configuration file as follows:

[[email protected] ~]# vim/application/redis/conf/6379.conf daemonize Yes # modified here to Yes, run in daemon mode Pidfile/var/run/redis_ 6379.pid # Modify PID file name, add port number (same Single instance mode not required) logfile "/application/redis/logs/6379.log" # Add log directory and file name

4. Create Log storage Directory

[Email protected] ~]# mkdir/application/redis/logs/

5. Copy the Redis boot script to the/etc/init.d/directory and rename it to Redis

[Email protected] ~]# Cp/home/oldcat/tools/redis-3.0.7/utils/redis_init_script/etc/init.d/redis

6, modify the Redis startup script, the relevant parameters are as follows:

[[email protected] ~]# Vim/etc/init.d/redisredishome=/application/redis # declare redis home directory exec= $REDISHOME/bin/ redis-servercliexec= $REDISHOME/bin/redis-clipidfile=/var/run/redis_${redisport}.pidconf= "$REDISHOME/conf/${ redisport}.conf "# Specifies the directory where the configuration file is located

7. Complete configuration, start Redis and view process and port number

[[Email protected] ~]# /etc/init.d/redis startstarting redis server ... [[email protected] ~]# ps -ef|grep redisroot      5061      1  0 19:18 ?         00:00:00 /application/redis/bin/redis-server *:6379                             root      5065  1474  0 19:19 pts/0     00:00:00 grep redis[[email protected] ~]# ss -lntup|grep  6379tcp    listen     0      128                      *:6379                  *:*        users: (("Redis-server", 5061,5)) tcp    listen      0      128                    :::6379                  :::*       users: ((" Redis-server ", 5061,4))

8. Execute client commands and test

[[email protected] ~]# redis-cli127.0.0.1:6379> set num 100ok127.0.0.1:6379> get num "127.0.0.1:6379> incr" Num (integer) 101127.0.0.1:6379> decr num (integer) 100127.0.0.1:6379> del num (integer) 1127.0.0.1:6379> get num (nil)

9. Turn off Redis service

[Email protected] ~]#/etc/init.d/redis stopstopping ... Redis Stopped[[email protected] ~]# ps-ef|grep redisroot 5104 1474 0 19:26 pts/0 00:00:00 grep redis [[Email PR Otected] ~]# ss-lntup|grep 6379[[email protected] ~]#

The Redis installation configuration is complete.

Redis installation and configuration single-instance chapter

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.