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

How to compile and install redisd

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article is about how to compile and install redisd. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Installation method: yum installation

View yum Warehouse redis version

[root@centos ~] # yum list redisLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileAvailable Packagesredis.x86_64 3.2.12-2.el7 myepelyum installation

[root@centos ~] # yum install redis-y

Start the service and set it to boot

[root@centos] # systemctl enable-- now redisCreated symlink from / etc/systemd/system/multi-user.target.wants/redis.service to / usr/lib/systemd/system/redis.service.

View redis port

[root@centos] # ss-ntlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1 ntlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 631 *: * LISTEN 0 100 127.0.1 LISTEN 25 *: * LISTEN 0 128 127.0.1 ntlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 6010 *: * LISTEN 0128 *: 54909 *: * LISTEN 0128 127.0.0.16379 *: * # this is the redis port LISTEN 0128 *: 111 *: * LISTEN 0 5 192.168.122.1 virtual 53 *: *

Test login to redis

[root@centos ~] # redis-cli127.0.0.1:6379 > info# Serverredis_version:3.2.12redis_git_sha1:00000000redis_git_dirty:0redis_build_id:7897e7d0e13773fredis_mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollgcc_version:4.8.5process_id:2914run_id:c75137717c54caa78bb05757d05c91471ef5817ftcp_port:6379uptime_in_seconds:175uptime_in_days:0hz:10lru_clock:4329484executable:/usr/bin / redis-serverconfig_file:/etc/redis.conf# Clientsconnected_clients:1client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0

Test use

127.0.1 value1 6379 > set key1 value1OK127.0.0.1:6379 > get key1 "value1"

Compilation and installation

Download the latest release version of redis source code package: http://download.redis.io/releases/

Compile installation command

Official installation command: https://redis.io/download

# Source package storage directory [root@centos ~] # cd / usr/local/src/# download source package [root@centos src] # wget http://download.redis.io/releases/redis-5.0.7.tar.gz--2020-02-11 10 root@centos 37 root@centos 54-http://download.redis.io/releases/redis-5.0.7.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: 1984203 (1.9m) [application/x-gzip] Saving to: 'redis-5.0.7.tar.gz'100% [= = >] 1984203 6.75KB/s in 3m 35s 2020-02-11 10:41:39 (9.02 KB/s) -' redis-5.0.7.tar.gz' saved [1984203 6.75KB/s in 1984203] # View the downloaded source package [root@centos src] # lltotal 1940 Muhammad Rafael-1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz

Decompress the source package

[root@centos src] # tar xf redis-5.0.7.tar.gz [root@centos src] # lltotal 1940drwxrwxr-x 6 root root 334 Nov 20 01:05 redis-5.0.7-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz

Create directories for configuration files, logs, data, etc.

[root@centos ~] # mkdir / apps/redis/ {etc,logs,data,run}-p# View directory structure [root@centos ~] # tree / apps//apps/ └── redis ├── data ├── etc ├── logs └── run

Go to the redis directory to compile and install

[root@centos ~] # cd / usr/local/src/redis-5.0.7/ [root@centos redis-5.0.7] # make PREFIX=/apps/redis installcd src & & make installmake [1]: Entering directory `/ usr/local/src/redis-5.0.7/src' CC Makefile.depmake [1]: Leaving directory` / usr/local/src/redis-5.0.7/src'make [1]: Entering directory `/ usr/local/src/redis-5.0 .7 / src' CC adlist.o/bin/sh: cc: command not foundmake [1]: * * [adlist.o] Error 127make [1]: Leaving directory `/ usr/local/src/redis-5.0.7/src'make: * [install] Error "the above error is caused by no gcc compiler # download gcc compiler [root@centos redis-5.0.7] # yum install gcc# remember to Delete the previous redis directory and re-extract [root@centos src] # rm-rf redis-5.0.7 [root@centos src] # tar xf redis-5.0.7.tar.gz # re-enter the directory to compile [root@centos src] # cd redis-5.0.7/ [root@centos redis-5.0.7] # make PREFIX=/apps/redis install # specify the installation directory cd src & & make installmake [1]: Entering directory `/ Usr/local/src/redis-5.0.7/src' CC Makefile.depmake [1]: Leaving directory `/ usr/local/src/redis-5.0.7/src'make [1]: Entering directory` / usr/local/src/redis-5.0.7/src'rm-rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof * .o * .gcda * .gcno * .gcov redis.info lcov-html Makefile.dep dict-benchmark (cd .. / deps & & make distclean) make [2]: Entering directory `/ usr/local/src/redis-5.0.7/deps' (cd hiredis & & make clean) > / dev/null | | true (cd linenoise & & make clean) > / dev/null | | true (cd lua & & make clean) > / dev/null | | true (cd jemalloc & & [- f Makefile] & & make distclean) > / dev/null | | true (rm-f. Make-*) make [2]: Leaving directory `/ usr/local/src/redis-5.0.7/deps' (rm-f. Make-*). (omit) Hint: It's a good idea to run 'make test';) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL installmake [1]: Leaving directory `/ usr/local/src/redis-5.0.7/src'# the final report is that the compilation is completed

Copy configuration fil

[root@centos redis-5.0.7] # ll total 276 root root Nov-1 root root 115100 Nov 20 01:05 00 Merle root root 11 11:32 deps-rw-rw-r-- 1 root root 11 Nov 20 01:05 BUGS-rw-rw-r-- 1 root root 2381 Nov 20 01:05 CONTRIBUTING-rw-rw-r-- 1 root root 1487 Nov 20 01:05 COPYINGdrwxrwxr-x 6 root root 11 11:32 deps-rw-rw-r-- 1 root root 11 Nov 20 01:05 INSTALL -rw-rw-r-- 1 root root 151Nov 20 01:05 Makefile-rw-rw-r-- 1 root root 6888 Nov 20 01:05 MANIFESTO-rw-rw-r-- 1 root root 20555 Nov 20 01:05 README.md-rw-rw-r-- 1 root root 61797 Nov 20 01:05 redis.conf-rwxrwxr-x 1 root root 275 Nov 20 01:05 runtest-rwxrwxr-x 1 root root Nov 20 01:05 runtest-cluster-rwxrwxr-x 1 root root 373 Nov 20 01:05 runtest -moduleapi-rwxrwxr-x 1 root root 281 Nov 20 01:05 runtest-sentinel-rw-rw-r-- 1 root root 9710 Nov 20 01:05 sentinel.confdrwxrwxr-x 3 root root 8192 Feb 11 11:33 srcdrwxrwxr-x 11 root root Nov 20 01:05 testsdrwxrwxr-x 8 root root 4096 Nov 20 01:05 utils [root@centos redis-5.0.7] # cp redis.conf / apps/redis/etc/

Start redis (this startup mode)

[root@centos redis-5.0.7] # / apps/redis/bin/redis-server / apps/redis/etc/redis.conf 8315 apps/redis/etc/redis.conf C 11 Feb 2020 11 apps/redis/etc/redis.conf 40 Feb 12.016 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo8315:C 11 Feb 2020 11 40V 12.016 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8315, just started8315:C 11 Feb 2020 11V 12.016 # Configuration loaded8315:M 11 Feb 2020 11L 40 12.017 * Increased maximum number of open files to 10032. _. _.-`. `_. '' -. _ Redis 5.0.7 (00000000Universe 0) 64 bit.-``.- ```. ```\ / _., _'-. _ (.-`|` ) Running in standalone mode | `-. _`...-.`` -. _ |'`_. -'| Port: 6379 |` -. _ `. _ / _. -'| PID: 8315` -. _ `-. _`. / _. -'_. -'| `-. _ _. -'| |` -. _ `. . -'_. -'| http://redis.io `-. _` -. _ `. _. -'. |` -. _ `. -'_. -'_. -'|` -. _ `-. -'_. -'_. -'. `-. _ _. -'` -. _ _.-'8315 Feb M 11 Feb 2020 11 40 Feb 12.017 # WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.8315 proc/sys/net/core/somaxconn is set to the lower value of 11 Feb 2020 11 The TCP backlog setting of 12.017 # Server initialized8315:M 11 Feb 2020 1140 12.017 # 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.8315:M 11 Feb 2020 11V 40V 12.017 # 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.8315:M 11 Feb 2020 11 Ready to accept connections 40 12.018 * Ready to accept connections

Resolve the current warning prompt

Tcp-backlog

The backlog argument defines the maximum length to which the queue of pending connections for sockfdmay grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.

The backlog parameter controls the queue value after the server side receives the client ack confirmation number during the three-way handshake.

[root@centos ~] # echo 511 > / proc/sys/net/core/somaxconnvm.overcommit_memory

0. Indicates that the kernel will check whether there is enough memory available for the application process; if there is enough memory available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process. 1. Indicates that the kernel allows all physical memory to be allocated, regardless of the current memory state. 2. Indicates that the kernel allows more than the sum of all physical memory and swap space to be allocated

[root@centos ~] # echo "vm.overcommit_memory = 1" > / etc/sysctl.conftransparent hugepage large page memory allocation needs to be turned off and redis is responsible for memory management. [root@centos ~] # echo never > / sys/kernel/mm/transparent_hugepage/enabled

Restart the service

# start the service again and the warning message is gone. [root@centos] # / apps/redis/bin/redis-server / apps/redis/etc/redis.conf 1847 apps/redis/etc/redis.conf C 13 Feb 2020 12 apps/redis/etc/redis.conf 03V 59.281 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1847:C 13 Feb 2020 12 V 03V 59.281 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1847, just started1847:C 13 Feb 2020 12 V 03V 59.281 # Configuration loaded1847:M 13 Feb 2020 12V 03V 59.282 * Increased maximum number of open files to 10032 (it was originally set to 1024). _. _.-`. `_. '' -. _ Redis 5.0.7 (00000000Universe 0) 64 bit.-``.- ```. ```\ / _., _'-. _ (.-`|` ) Running in standalone mode | `-. _`...-.`` -. _ |'`_. -'| Port: 6379 |` -. _ `. _ / _. -'| PID: 1847` -. _ `-. _`. / _. -'_. -'| `-. _ _. -'| |` -. _ `. . -'_. -'| http://redis.io `-. _` -. _ `. _. -'. |` -. _ `. -'_. -'_. -'|` -. _ `-. -'_. -'_. -'. `-. _. -''. _. -'` -. _. -'`-. _ _.-'1847 Feb M 13 Feb 2020 12 Feb 03DB loaded from disk 59.282 # Server initialized1847:M 2020 12 seconds1847:M 13 Feb 2020 1215 59.282 * Ready to accept connections

Edit the redis service startup script

[root@centos ~] # cat / usr/lib/systemd/system/ redis.service [Unit] Description=Redis persistent key-value databaseAfter=network.targetAfter=network-online.targetWants=network-online.target [Service] # ExecStart=/usr/bin/redis-server / etc/redis.conf-- supervised systemdExecStart=/apps/redis/bin/redis-server / apps/redis/etc/redis.conf-- supervised systemdExecReload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s QUIT $MAINPIDType=notifyUser=redisGroup=redisRuntimeDirectory=redisRuntimeDirectoryMode= 0755 [install] WantedBy=multi-user.target

Add redis user

# add users and groups [root@centos ~] # groupadd-g 1001 redis & & useradd-u 1001-g 1001 redis-s / sbin/nologin# data directory setting owner's group [root@centos ~] # chown redis.redis-R / apps/redis/system start test # enable redis and set to boot [root@centos ~] # systemctl enable-- now redisCreated symlink from / etc/systemd/system/multi-user.target.wants/redis.service to / Usr/lib/systemd/system/redis.service.# view port [root@centos ~] # ss-tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1 ss 631 *: * LISTEN 0 100 127.0.1 ss 25 *: * LISTEN 0128 127.0.1 ss 6010 *: * LISTEN 0128 127.0.0.1 tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 6011 *: * LISTEN 0128 *: 43108 *: * LISTEN 0511 127.0.0.1 LISTEN 6379 *: * # this is redis port LISTEN 0128 *: 111 *: * LISTEN 0 5 192.168.122.1 LISTEN 53 *: * LISTEN 0128 *: 22 *: * LISTEN 0128 [:: 1]: 631 [::]: * LISTEN 0100 [:: 1]: 25 [::]: * LISTEN 0128 [:: 1]: 6010 [::]: * LISTEN 0128 [:: 1]: 6011 [:]: * LISTEN 0128 [::]: 59279 [:]: * LISTEN 0128 [::]: 111[::]: * LISTEN 0128 [::]: 22 [::]: *

Client connection redis test

# this command has not been added to the PATH variable [root@centos ~] # / apps/redis/bin/redis-cli 127.0.0.1 apps/redis/bin/redis-cli apps/redis/bin/redis-cli 6379 > info# Serverredis_version:5.0.7redis_git_sha1:00000000redis_git_dirty:0redis_build_id:b0887378c143d6e9redis_mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollatomicvar_api:atomic-builtingcc_version:4.8.5process_id:2088run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924ctcp_port:6379

Create a command soft connection (you can also add this path to the PATH variable)

[root@centos ~] # ln-sv / apps/redis/bin/redis-* / usr/bin/'/usr/bin/redis-benchmark'->'/ apps/redis/bin/redis-benchmark''/usr/bin/redis-check-aof'->'/ apps/redis/bin/redis-check-aof''/usr/bin/redis-check-rdb'->'/ apps/redis/bin/redis-check-rdb''/usr/bin/redis-cli' ->'/ apps/redis/bin/redis-cli''/usr/bin/redis-sentinel'->'/ apps/redis/bin/redis-sentinel''/usr/bin/redis-server'->'/ apps/redis/bin/redis-server'# command connection test [root@centos ~] # redis-cli 127.0.0.1 redis-cli 6379 > info# Serverredis_version:5.0.7redis_git_sha1:00000000redis_git_dirty:0redis_build_id:b0887378c143d6e9redis _ mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollatomicvar_api:atomic-builtingcc_version:4.8.5process_id:2088run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924ctcp_port:6379uptime_in_seconds:755uptime_in_days: 0 [root @ centos ~] # ll / apps/redis/bin/total 32772-rwxr-xr-x 1 redis redis 4366824 Feb 11 11:33 redis-benchmark # redis performance Test tool-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-aof # AOF File Inspection tool-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-rdb # RDB File Inspection tool-rwxr-xr-x 1 redis redis 4807896 Feb 11 11:33 redis-cli # client tool lrwxrwxrwx 1 redis redis 12 Feb 11 11:33 redis-sentinel-> redis-server # Sentinel soft Connect to server-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-server # redis Service start command Thank you for reading! This is the end of this article on "how to compile and install redisd". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

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