centos6.3 Installation Configuration Redis

Source: Internet
Author: User
Tags benchmark redis server

1. Download and install 1.1 download package

Note: In http://download.redis.io/releases query the version that needs to be downloaded

wget http://download.redis.io/releases/redis-3.2.1.tar.gz

1.2 Unzip the installation

TAR-XVF redis-3.2.1.tar.gz

CD redis-3.2.1

Make

Make install

The redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump is automatically copied to the/usr/local/bin directory after installation
Ls/usr/local/bin

    • Redis-server:redis Server Daemon Startup program
    • Redis-cli:redis command-line operation tool. Of course, you can also use Telnet to operate on its plain text protocol.
    • Redis-benchmark:redis Performance testing tools to test the read and write performance of Redis in your system and in your configuration
    • Redis-stat:redis Status Detection Tool to detect Redis current status parameters and delay status
2. Test Redis

CD src && make test

When executing the above command, the following information is available:

Installing TCL

Yum Install Tcl

CD src && make test or./runtest

3, configuration 3.1 set up cache directory

Create a dedicated folder to hold Redis files as a Redis cache folder

3.2 Configuring the Config file

Vim redis.conf

Modify Daemonize No to Yes, which means that Redis is set to run in the background and not run in the background by default.

Modify the Pidfile location to point to the Redis cache folder

Modify the logfile location to point to the Redis cache folder

Modify Dbfilename Name

Modify DIR (Dbfilename storage directory), point to Redis cache folder

The following are the meanings of the main configuration parameters of redis.conf:

    • Daemonize: Whether to run daemon mode later
    • Pidfile:pid File Location
    • Port: Port number for listening
    • Timeout: Request time-out
    • Loglevel:log Information level
    • Logfile:log File Location
    • Databases: number of open databases
    • Save *: How often the snapshot is saved, the first * indicates how long, and the third * indicates how many times the write operation is performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
    • Rdbcompression: Whether to use compression
    • Dbfilename: Data Snapshot file name (only file name, excluding directory)
    • Dir: Save directory for Data snapshot (this is the directory)
    • AppendOnly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
    • Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync per second, do not call Fsync wait for the system to synchronize itself)
4. Start and use Test 4.1 to specify the configuration file to start

Start the server redis-server/home/styuan/spinnaker/redis-3.2.1/redis.conf

4.2 Start the console program and use

4.3 Ways to detect whether Redis exists

Ps–ef | grep Redis

NETSTAT–LNTP | grep 6379

Stop Redis

REDIS-CLI shutdown

5. Set As System service

View current system-owned services

Chkconfig

At this point Redis is only available, but it needs to be started manually and is not friendly, so we need to set it up as a system service and boot.

5.1 Configuring Startup Scripts

It is recommended that you start the Redis service in a production environment using startup scripting. The startup script redis_init_script is located in the Redis /utils/ directory.

Modify the appropriate file configuration:

#大致浏览下该启动脚本, it is found that Redis habitually uses the port name of the listener as the configuration file, and we follow this convention later. #redis服务器监听的端口REDISPORT=6379#服务端所处位置, which is stored by default with '/usr/local/bin/redis-server ' after make install ' If you do not install it, you need to modify the path. EXEC=/usr/local/bin/redis-server# client location cliexec=/usr/local/bin/redis-cli#redis pid file location pidfile =/var/run/redis_${redisport}.pid# configuration file location, need to modify conf="/etc/redis/${redisport}.conf "

5.2 Configuration Profile Environment

5.2.1 According to the startup script requirements, the modified configuration file is copied to the specified directory as a port name. Need to use root user

mkdir /etc/rediscp redis.conf/etc/redis/6379. conf

5.2.2 Copy the startup script to the/ETC/INIT.D directory, this example names the startup script REDISD (usually ending with D as the background self-starting service)

CP REDIS_INIT_SCRIPT/ETC/INIT.D/REDISD

6. Set to boot from boot

This is directly configured to turn on self-booting will report chkconfig redisd on An error: service redisd does not support chkconfig

The problem is resolved as follows:

The following two lines of comments must be placed in the comments in front of the/etc/init.d/redis file:

# chkconfig:   2345# Description: Redis is  a persistent key-value Database

The above note means that the Redis service must be started or shut down at run level 2,3,4,5, the priority of the boot is 90, and the priority of the shutdown is 10.

Set it again to succeed.

#设置为开机自启动服务器chkconfig REDISD on# Open Service services REDISD start# shut down services service REDISD stop

7. Appendix 7.1 Linux Run Level

The runlevel is the functional level that the operating system is currently running. This level is from 0 to 6 and has different functions. These levels are specified in the/etc/inittab file. This file is the main file that the INIT program looks for, and the first service to run is those files that are placed in the/ETC/RC.D directory.

The different run levels are defined as follows: (refer to Linux/etc/inittab)

# The default run level, the level used by RHS is as follows:

0: Turn off the machine

1: Single-user mode

2: Multi-user mode with no network support

3: Multi-user mode with network support

4: reserved, not used

5: Multi-user mode with network support with X-window support

6: Reboot the system, that is, restart

A detailed explanation of the individual run levels:

0 for downtime, the machine shuts down.

1 is a single-user mode, similar to the safe mode under Win9x.

2 is multi-user mode, but there is no NFS support.

3 is the full multi-user mode and is the standard run level.

4 generally not, in some special cases you can use it to do something. For example, you can switch to this mode to do some setup when your laptop's battery is running out.

5 is X11, into the X Window System.

6 Restart, the init 6 machine will restart.

7.2 Chkconfig usage

The Chkconfig command can be used to check and set various services of the system

Use syntax:

chkconfig [--add][--del][--list][system service] or Chkconfig [--level < class Code >][system service][on/off/reset]

Parameter usage:

–add adds the specified system service, allows the CHKCONFIG directive to manage it, and adds relevant data to the system-initiated narrative file.

–del deletes the specified system service, is no longer managed by the Chkconfig directive, and deletes the relevant data within the system-initiated narrative file.

–level< Class code > Specify which execution level the system service should be opened or closed.

Examples of Use:

Chkconfig–list List of all system services

Chkconfig–add Redis Add Redis Service

Chkconfig–del Redis Remove Redis Service

Chkconfig–level Redis 2345 on enables Redis to be on at run Level 2, 3, 4, 5.

centos6.3 Installation Configuration Redis

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.