Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ How to Install Redis server on CentOS 7     - Python objects (Programming)

- Stunning exclamation point at the Linux command line (Linux)

- Linux Monitoring Command (Linux)

- Use Git in Eclipse (Linux)

- Oracle 11g on Linux system boot from the startup settings (Database)

- HBase table data processing tab (Database)

- Linux System Getting Started Learning: the local time in between Perl and UNIX timestamp conversion (Linux)

- CentOS replaces update source and Linux kernel compilation summary (Linux)

- HomeKit User Interface Guidelines (Linux)

- Gnu Linux - Ubuntu System Clean-term consolidation (Linux)

- How to troubleshoot Windows and Ubuntu dual system time is not synchronized (Linux)

- Linux installation Jetty deployment under RedHat5 8 (Linux)

- Java inner classes (Programming)

- Install Java 8 on Ubuntu using PPA (Linux)

- Linux landing problem (Linux)

- Based on Python: OpenCV simple image manipulation (Programming)

- C language binary tree counts words (Programming)

- Linux Shell debugging (Programming)

- Linux deploy Tutorial (Linux)

- Examples of RAID levels and achieve Operational Details (Linux)

  How to Install Redis server on CentOS 7
  Add Date : 2017-01-08      
  Hello everyone, the theme of this article is Redis, we're going to install it on CentOS 7. Compile the source code, install the binary files, create the installation file. After installing its components, we will configure redis, just configure the operating system parameters, the goal is to make redis run more reliably and quickly.

Redis server

Redis is an open source multi-platform data storage software, written in ANSI C, direct memory usage in the data set, enabling it to achieve very high efficiency. Redis supports multiple programming languages, including Lua, C, Java, Python, Perl, PHP and many other languages. Redis code amount is very small, only about 30,000 lines, it is only "little" thing, but doing well. Although work is in memory, but the data persistence preservation is still there, and redis reliability is high, also supports clusters, which can be a good guarantee your data security.

Construction Redis

redis currently no official RPM package, we need to compile from source code, but you need to install in order to compile Make and GCC.

If not installed GCC and Make, then use yum to install.

yum install gccmake
Downloaded from the official website of the tar archive.

curl http://download.redis.io/releases/redis-3.0.4.tar.gz -o redis-3.0.4.tar.gz

tar zxvf redis-3.0.4.tar.gz
Enter the unpacked directory.

cd redis-3.0.4
Make use to compile the source file.


Enter the directory of the source file.

cd src
Copy Redis server and client to / usr / local / bin.

cp redis-server redis-cli / usr / local / bin
At best the sentinel, benchmark and check copy past.

cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump / usr / local / bin
Create redis configuration folder.

mkdir / etc / redis
Create a directory of valid data stored in / var / lib / redis

mkdir -p / var / lib / redis / 6379

System parameters

To make redis work properly you need to configure some kernel parameters.

Configure vm.overcommit_memory 1, which prevents data is truncated, as detailed here.

sysctl-w vm.overcommit_memory = 1
Modify the maximum number of connections exceeds the backlog redis.conf the tcp-backlog value, which is the default value of 511. You can find more information about the ip based sysctl network tunnel at kernel.org.

sysctl-w net.core.somaxconn = 512
Cancel support for transparent huge page memory (transparent huge pages), as this will cause delay and redis use to generate memory access issue.

echo never> / sys / kernel / mm / transparent_hugepage / enabled

redis.conf is redis configuration files, but you will see the name of this file is 6379.conf, and this figure is redis monitor network ports. If you want to run more than one instance of redis, it recommended the use of such names.

Copy the example of redis.conf to /etc/redis/6379.conf.

cp redis.conf /etc/redis/6379.conf
Now edit this file and configuration parameters.

vi / etc / redis / 6379.conf


Daemonize set to no, systemd need it to run in the foreground, otherwise redis suddenly hang.

daemonize no

Setting pidfile to /var/run/redis_6379.pid.

pidfile /var/run/redis_6379.pid

If you are not using the default port, you can be modified.

port 6379

Set the logging level.

loglevel notice


Modify the log file path.

logfile /var/log/redis_6379.log

Set the directory to / var / lib / redis / 6379

dir / var / lib / redis / 6379

Here are a few you can improve the security of the operation.

Unix sockets

In many cases, the client program and the server program is running on the same machine, so no listening socket on the network. If you use this and similar situations, you can use an alternative unix socket network socket, for this you need to configure the port to 0, and then configure the following options to enable unix socket.

Unix socket set socket file.

unixsocket /tmp/redis.sock
Restrict permissions socket file.

unixsocketperm 700
Now in order to make redis-cli can access, you should use the -s parameter to point to the socket file.

redis-cli -s /tmp/redis.sock

You might need remote access, if it is, then you should set a password before each operation like this requires a password.

requirepass "bTFBx1NYYWRMTUEyNHhsCg"


Imagine the following output instruction. Yes, it will output the configuration of the server, so you should refuse such access under any possible circumstances.

In order to limit or even prohibit this or he can use the command rename-command command. You must supply a command name and alternative name. To disable then need to set up an alternative name for the empty string, which prohibits any person to guess the name of the command would be more secure.

rename-command FLUSHDB "FLUSHDB_MY_SALT_G0ES_HERE09u09u"
rename-command FLUSHALL ""
rename-command CONFIG "CONFIG_MY_S4LT_GO3S_HERE09u09u"

Unix socket by using a password to access and modify the command


By default, redis periodically to dump the data set we set dump.rdb file directory under. You can use the save command dumps the configuration of frequency, its first parameter is the time frame in seconds, and the second parameter is the number of modifications in the data file.

Least every 15 minutes and modified key again.

save 9001
Every 5 minutes and a minimum of 10 times the modified key.

save 30010
Every 1 minute and least modified 10,000 bond.

save 6010000
/var/lib/redis/6379/dump.rdb File contains the dump data from memory since the last save data sets. Since it first creates a temporary file and then replace the previous dump file, data corruption problem does not exist here, and do not worry, you can directly copy the file.

When you start the boot

You can use systemd to add redis system boot list.

Copy the sample files to the init_script /etc/init.d, note the name of the script represents the port number.

cp utils / redis_init_script /etc/init.d/redis_6379
Now we want to use systemd, so create a file named redis_6379.service unit under / etc / systems / system.

vi / etc / systemd / system / redis_6379.service
Fill in the following, details visible systemd.service.

Description = Redis on port 6379
Type = forking
ExecStart = / etc / init.d / redis_6379 start
ExecStop = / etc / init.d / redis_6379 stop
WantedBy = multi-user.target
Now add the option before I /etc/sysctl.conf modified in your memory overcommit and backlog maximum.

vm.overcommit_memory = 1
net.core.somaxconn = 512
Support for transparent huge page memory, and there is no direct sysctl command can control, you need the following command into the end of /etc/rc.local.

echo never> / sys / kernel / mm / transparent_hugepage / enabled
to sum up

This can be started by setting these options you can deploy redis service to many simple scene, but there are many redis options redis.conf complex environment to prepare. In some cases, you can use replication to increase availability and Sentinel, or data is distributed across multiple servers to create a server cluster.
- Installation JDK 1.8 under CentOS7 (Linux)
- Linux daemon (Linux)
- Linux kernel socket protocol stack routing lookup cache mechanism (Linux)
- Build Docker based MongoDB replication cluster environment (Database)
- Java NIO in the world (Programming)
- Linux and SELinux Exploration Program Manager (Linux)
- Log4cplus logging facility configuration, installation, testing (Linux)
- Linux data recovery software efficiently practical application extundelete (Linux)
- Number JavaScript type system (Programming)
- MySQL Basic tutorial: About varchar (N) (Database)
- Linux to achieve a simple cp command (Linux)
- libnet list of functions (Programming)
- Fedora10 use Git version Configuration Management (Linux)
- BusyBox making the file system (Linux)
- Cross server / client backup command: rsync use (Server)
- Getting Started with Linux: Learn how to upgrade Docker in Ubuntu (Server)
- Using IntelliJ IDEA Import Spark Spark latest source code and compile the source code (Linux)
- C ++ pointer of the (error-prone model) (Programming)
- Good wireless network security information spread in the air (Linux)
- Build their own recursive DNS server (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.