Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing redis Database under centos system

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to install the redis database under the centos system, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The specific installation steps are as follows:

First, install redis

Step 1: download the redis installation package

[root@iZwz991stxdwj560bfmadtZ local] # wget http://download.redis.io/releases/redis-4.0.6.tar.gz--2017-12-13 12 root@iZwz991stxdwj560bfmadtZ local 35 root@iZwz991stxdwj560bfmadtZ local 12 http://download.redis.io/releases/redis-4.0.6.tar.gzResolving download.redis.io (download.redis.io). 109.74.203.151Connecting to download.redis.io (download.redis.io) | 109.74.203.151 |: 80. Connected.HTTP request sent, awaiting response... 200 OKLength: 1723533 (1.6m) [application/x-gzip] Saving to: 'redis-4.0.6.tar.gz'100% [= >] 1723533 608KB/s in 2.8s 2017-12-13 12:35:15 (608KB/s) -' redis-4.0.6.tar.gz' saved [1723533 amp 1723533]

Step 2: decompress the package

Tar-zxvf redis-4.0.6.tar.gz [root@iZwz991stxdwj560bfmadtZ local] # tar-zxvf redis-4.0.6.tar.gz

Step 3: yum install gcc dependency

Yum install gcc [root@iZwz991stxdwj560bfmadtZ local] # yum install gcc

When you encounter a choice, enter y.

Step 4: jump to the directory of redis decompression

Cd redis-4.0.6 [root@iZwz991stxdwj560bfmadtZ local] # cd redis-4.0.6

Step 5: compile and install

Make MALLOC=libc [root@iZwz991stxdwj560bfmadtZ redis-4.0.6] # make MALLOC=libc

Add the files under the / usr/local/redis-4.0.6/src directory to the / usr/local/bin directory

Cd src & & make install

[root@iZwz991stxdwj560bfmadtZ redis-4.0.6] # cd src & & make install CC Makefile.depHint: It's a good idea to run 'make test';) INSTALL install INSTALL install

2. Three ways to start redis

Change to the redis src directory first

[root@iZwz991stxdwj560bfmadtZ redis-4.0.6] # cd src

1. Start redis directly

. / redis-server

[root@iZwz991stxdwj560bfmadtZ src] #. / redis-server18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18685, just started18685:C 13 Dec 12:56:12.507 # Warning: no config file specified, using the default config. In order to specify a config file use. / redis-server / path/to/redis.conf _. _ _.-``_ _'-. _ _.-```. `_. '' -. _ Redis 4.0.6 (00000000Universe 0) 64 bit.-``.- ```. ```\ / _., _'-. _ (.-`|` ) Running in standalone mode | `-. _`...-.`` -. _ |'`_. -'| Port: 6379 |` -. _ `. _ / _. -'| PID: 18685` -. _ `-. _`. / _. -'_. -'| `-. `-. _` -'_. | | `-. _` -. _ _. -'_. -'| http://redis.io `-. _` -. _ _. -'. | | `-. _` -. _ `. -'_. -'| |` -. _ `-. -'_. -'. _. -'`-. _`. -'. 18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.18685:M 13 Dec 12:56:12.508 # Server initialized18685:M 13 Dec 12:56:12.508 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory=1' to / etc/sysctl.conf and then reboot or run the command' sysctl vm.overcommit_memory=1' for this to take effect.18685:M 13 Dec 1215 56 sysctl vm.overcommit_memory=1' for this to take effect.18685:M 12.508 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > / sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your / etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.18685:M 13 Dec 12 Ready to accept connections 56 Ready to accept connections 12.508

Such as the image above: redis started successfully, but this startup method needs to keep the window open all the time, so it is not convenient to do other operations.

Press ctrl + c to close the window.

2. Start redis by background process

Step 1: modify the redis.conf file

Set

Daemonize no

Modify to

Daemonize yes

Step 2: specify redis.conf file startup

. / redis-server / usr/local/redis-4.0.6/redis.conf [root@iZwz991stxdwj560bfmadtZ src] #. / redis-server / usr/local/redis-4.0.6/redis.conf 18713:C 13 Dec 13:07:41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18713:C 13 Dec 13:07:41.109 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18713, just started18713:C 13 Dec 13:07:41.109 # Configuration loaded

Step 3: shut down the redis process

First use ps-aux | grep redis to view the redis process

[root@iZwz991stxdwj560bfmadtZ src] # ps-aux | grep redisroot 18714 0.00.1 141752 2008? Ssl 13:07 0:00. / redis-server 127.0.0.1:6379root 18719 0.0 112644 968 pts/0 R + 13:09 0:00 grep-- color=auto redis

Use the kill command to kill the process

[root@iZwz991stxdwj560bfmadtZ src] # kill 18714

3. Set redis to boot automatically.

1. Create a new redis directory under the / etc directory

Mkdir redis [root@iZwz991stxdwj560bfmadtZ etc] # mkdir redis

2. Copy the / usr/local/redis-4.0.6/redis.conf file to the / etc/redis directory and name it 6379.conf

[root@iZwz991stxdwj560bfmadtZ redis] # cp / usr/local/redis-4.0.6/redis.conf / etc/redis/6379.conf

3. Make a copy of the startup script of redis and put it in the / etc/init.d directory

[root@iZwz991stxdwj560bfmadtZ init.d] # cp / usr/local/redis-4.0.6/utils/redis_init_script / etc/init.d/redisd

4. Set redis to boot automatically.

Change to the / etc/init.d directory first

Then execute the self-starting command

[root@iZwz991stxdwj560bfmadtZ init.d] # chkconfig redisd onservice redisd does not support chkconfig

Look, the result is that redisd does not support chkconfig

Solution:

Edit the redisd file using vim, add the following two lines of comments on the first line, and save and exit

# chkconfig: 2345 90 10# description: Redis is a persistent key-value database

The comment means that the redis service must be started or shut down at runtime level 2, 3, 4, 5, with a start priority of 90 and a shutdown priority of 10.

Execute the boot command again, successfully

[root@iZwz991stxdwj560bfmadtZ init.d] # chkconfig redisd on

Now you can start and shut down redis directly in the form of services.

Start:

Service redisd start [root@izwz991stxdwj560bfmadtz ~] # service redisd startStarting Redis server...2288:C 13 Dec 13 Dec 51 Dec 38.087 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo2288:C 13 Dec 1314 51mer 38.087 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2288, just started2288:C 13 Dec 13 Dec 13

Close:

Method 1:service redisd stop

[root@izwz991stxdwj560bfmadtz ~] # service redisd stopStopping... Redis stopped

Method 2:redis-cli SHUTDOWN

III. Reference materials

1. Http://blog.csdn.net/zc474235918/article/details/50974483

2. Http://blog.csdn.net/gxw19874/article/details/51992125

If the following problems occur:

[root@iZwz991stxdwj560bfmadtZ ~] # service redisd start/var/run/redis_6379.pid exists, process is already running or crashed above are all the contents of this article entitled "how to install redis database under centos system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report