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

- Bootable ISO image using GRUB (Linux)

- Java implementation of stacks and queues (Programming)

- Oracle users to automatically increase the partition table (Database)

- VMware Workstation + Ubuntu 10.04 Download the Android 2.2 source code (Linux)

- Android memory optimization of the optimal load Bitmap (Linux)

- Vi editor Introduction (Linux)

- MySQL configuration file my.cnf increase the log file parameter error (Database)

- Linux environment variables inside (Linux)

- To install Internet security firewall Raiders (Linux)

- Intrusion analysis and prevention tools Knark under Linux platform (Linux)

- How to improve the performance of Ruby On Rails (Linux)

- Oracle 11g tracking and monitoring system-level triggers to drop misuse (Database)

- Oracle multi-table query optimization (Database)

- Analysis of memory mapping process in Linux x86-64 mode (Linux)

- Linux Command-line MySQL summary (Database)

- Using Java to build micro-services (Server)

- OpenGL Superb Learning Notes - Depth Texture and Shadows (Programming)

- Solaris 11 forget the root password (Linux)

- Eclipse configuration GTK (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
unzip.

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

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

make
 
installation

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

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

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

daemonize no
 
pidfile

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

pidfile /var/run/redis_6379.pid
 
port

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

port 6379
 
loglevel

Set the logging level.

loglevel notice
 

logfile

Modify the log file path.

logfile /var/log/redis_6379.log
 
dir

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

dir / var / lib / redis / 6379
 
Safety

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
 
requirepass

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

requirepass "bTFBx1NYYWRMTUEyNHhsCg"
 

rename-command

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

CONFIG GET *
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

Snapshot

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.

[Unit]
Description = Redis on port 6379
[Service]
Type = forking
ExecStart = / etc / init.d / redis_6379 start
ExecStop = / etc / init.d / redis_6379 stop
[Install]
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.
     
         
         
         
  More:      
 
- Linux security settings (Linux)
- CentOS6 MongoDB connection solution can not break 1000 (Database)
- Win8 mount disk partitions under Ubuntu (Linux)
- Shell Scripting early experience (Programming)
- Get the Linux device PCI ID method (Linux)
- Linux environment variable configuration and save places (Linux)
- To modify the existing user ID and comments GPG key (Linux)
- Oracle Duplicate build DataGuard (Database)
- CentOS use wget (Linux)
- Linux Apache server configure to protect system security (Linux)
- MySQL common functions summary (Database)
- AngularJS - Custom instructions (Programming)
- Ubuntu GCC, G ++ and fortran Version Switch (Linux)
- Use HttpClient remote interface testing (Programming)
- How to ensure the Linux SSH login security with one-time password (Linux)
- Linux network monitoring tools ntopng installation (Linux)
- AppCode developed Mac OS X application or shared library experience summary (Programming)
- Windows Desktop use VNC remote connect Linux (Linux)
- How to install Unbound and DNSCrypt in Archlinux (Server)
- Bug tracking library after FastJson omitted the decimal point 0 (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.