CentOS Installation Python-redis

Source: Internet
Author: User
Tags lua install redis redis server

1. Yum Install Redis

Yum Install Redis

The current version of Redis on Yum is 3.0.6

2. Yum Install/update python

CentOS basically system comes with Python, update can

Installation: Yum Install Python

The latest version of Python on Yum is now 2.6.6

3. Installing the Python module

    • wget--no-check-certificate https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz
    • TAR-ZVXF redis-2.8.0.tar.gz
    • MV redis-2.8.0 python-redis-2.8.0
    • CD python-redis-2.8.0
    • Python setup.py Install

4. Modify the configuration file

After the end, configure the redis.conf file, set the "Daemonize" property to "yes", indicating that we will start the Redis service as a background process, and set the "Port" property to the specified port, where the default is "6379"; "LogFile" property is set to the specified log path, and the remaining properties can remain the default.

5. View Redis Logs

This handsome icon is the Redis logo.

6, execute the client command, verify the service is normal:

7, the Redis configuration file parameter detailed

Property

Description

Daemonize

If the value is "yes", the service is started as a daemon, and if the value is "no", the opposite

Pidfile

Specify the file path where the Redis process number is stored

Port

Specifies the port for the current Redis service, which defaults to 6379

Tcp-backlog

This parameter determines the length of the completed queue (after three handshake) in a TCP connection, which must not be less than the Linux system-defined/proc/sys/net/core/somaxconn value, which is 511 by default, and the default parameter value for Linux is 128. When the system concurrency is large and the client is slow, the two parameters can be referenced together.

Timeout

The connection time-out between the client and the Redis server, which defaults to 0, means that it never times out.

Tcp-keepalive

If the value is not 0, the unit is seconds, indicating that it will periodically use so_keepalive to detect whether the client is still in a healthy state, to prevent the server from blocking, the official recommended value is 60S.

LogLevel

Redis supports a total of four levels: Debug, verbose, notice, warning.

Debug: Record a lot of information for development and testing;

Varbose: Useful information, unlike debug will record so much;

Notice: Common verbose, often used in production environment;

Warning: Only very important or serious information will be recorded in the log;

The default is the notice level.

LogFile

Storage path for logs

Databases

The number of databases available, the default value is 16, the default database is 0, and the database range is between 0-(database-1), and individuals feel that the concept of DB is similar to a namespace

Save

Save the database snapshot information to disk, the corresponding value of two, such as Save 300 10 means: 300 seconds, at least 300 keys are changed, triggering the event of saving information to disk.

Stop-writes-on-bgsave-error

Whether to continue to provide write service after persistence error occurs

Rdbcompression

When persisting to an RDB file, compression is suppressed, "yes" is compressed, "no" is otherwise

Rdbchecksum

Whether the CRC64 checksum is supported when reading and writing, which is enabled by default

Dbfilename

The name of the image file

Dir

The current working directory, configuration files and image files are all in this directory

Masterauth

Set the password to access the master server

Slave-serve-stale-data

When the slave server and master server lose connectivity, or when the data is being copied for transmission, if this parameter value is set "Yes", the slave server can continue to accept the client's request, otherwise it will be returned to the requested client with the following information "SYNC with the master in Progress

Slave-read-only

Whether to allow slave server nodes to provide only read services

Repl-disable-tcp-nodelay

Specifies whether to disable the No_delay option for the socket when synchronizing data to slave. When configured as "Yes", No_delay is disabled, and the TCP stack consolidates packet unification, which reduces the number of packets between master and slave nodes and saves bandwidth, but increases the time that data is synchronized to slave. If configured as "No", indicating that No_delay is enabled, the TCP stack does not delay the timing of packets, which reduces the latency of data synchronization, but requires greater bandwidth. Typically, you should configure No to reduce the synchronization delay, but you can configure yes if the network load between master and slave nodes is already high.

Slave-priority

Specifies the priority of the slave. In a deployment environment where more than 1 slave exist, Redis Sentinel promotes the slave with the lowest priority value to master when Master is down. It is important to note that if the configuration item is 0, the corresponding slave will never be promoted to master automatically.

AppendOnly

When append only mode is turned on, Redis appends every write request received to the Appendonly.aof file, and when Redis restarts, the previous state is recovered from the file. However, this will cause the appendonly.aof file to be too large, so Redis also supports the bgrewriteaof directive, and re-organizes the appendonly.aof. Default is not turned on.

Appendfilename

The default is appendonly.aof.

Appendfsync

Set the AOF synchronization frequency, there are three kinds of choices always, everysec, no, the default is everysec means to synchronize once per second.

No-appendfsync-on-rewrite

Specifies whether to call Fsync during background aof file rewrite, which defaults to No, indicating that you want to invoke Fsync (regardless of whether the background has child processes in the brush disk). When Redis writes an RDB file or rewrites a Afo file in the background, there is a lot of disk IO, and in some Linux systems, calling Fsync may block.

Auto-aof-rewrite-percentage

Specifies the condition for Redis overriding the AoF file, which defaults to 100, which indicates that AFO background is triggered when the current aof file grows more than 100% of the last rewrite file size compared to the last rewrite aof file size. If configured to 0, automatic rewrite is disabled

Auto-aof-rewrite-min-size

Specifies the size of the aof file that triggers rewrite. If the aof file is less than this value, automatic rewrite is not triggered even if the current file's increment ratio reaches the Auto-aof-rewrite-percentage configuration value. The rewrite is triggered when both configuration items are met at the same time.

Lua-time-limit

The maximum execution time for a LUA script, in milliseconds, or 0 or negative for infinite execution time, default to 5000

Notify-keyspace-events

See reference 3, Key notification events

Aof-rewrite-incremental-fsync

AoF The rewrite process, whether to take an incremental file synchronization policy, the default is "Yes." Rewrite process, the file synchronization of every 32M data, which can reduce the number of aof large file write to disk operations

Successful deployment, write code verification

import redisclient =  redis.StrictRedis(host=‘localhost‘, port=6379)print client.ping()

CentOS Installation Python-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.