Home > Database > Redis > How to install redis5.0.10 on centos7.8

How to install redis5.0.10 on centos7.8

WBOY
Release: 2023-05-30 23:34:04
forward
1672 people have browsed it

Preparation

  • One centos7.8 server

Modify the host name

# hostnamectl set-hostname redishost
Copy after login

Install redis

Download redis installation package

# cd /opt
# wget https://download.redis.io/releases/redis-5.0.10.tar.gz
Copy after login

Unzip the compressed package

# cd /opt
# tar -zxf redis-5.0.10.tar.gz
Copy after login

Compile and install

# cd /opt
# cd redis-5.0.10
## 安装gcc编译器
# yum install gcc
# make MALLOC=libc
# # make install
cd src && make install
make[1]: Entering directory `/opt/redis-5.0.10/src'


Hint: It's a good idea to run 'make test' ;)


    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/opt/redis-5.0.10/src
Copy after login

Modify system parameters

## 修改sysctl.conf
# (
cat <<EOF
net.core.somaxconn=1024
vm.overcommit_memory=1
EOF
) >> /etc/sysctl.conf
Copy after login

The above operations It is a durable solution to solve the first two warnings prompted by the default startup of redis-server. The two warning messages of the default startup of redis-server are as follows:

  • The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

  • ##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.

Modify the system startup parameters to turn off TCP

## 修改/etc/default/grub
## 在指定行加 transparent_hugepage=never
# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed &#39;s, release .*$,,g&#39; /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"


## 重新生成grub配置文件
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1127.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1127.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-385c7efe9475460c95c436866e593af3
Found initrd image: /boot/initramfs-0-rescue-385c7efe9475460c95c436866e593af3.img
done
Copy after login

The above operation is a long-lasting solution to solve the third warning of the default startup prompt of redis-server. Attached is the default startup of redis-server. The third warning message is as follows:

  • you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.

Write 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' according to the prompts to /etc/rc.local. It is actually useless. Change Modifying the grub startup file can take effect.

Start redis as a background process

Modify the configuration file redis.conf

# cd /opt/redis-5.0.10
# mkdir /etc/redis
# cp redis.conf /etc/redis/redis.conf
Copy after login

Modify the following 3 items in /etc/redis/redis.conf

  • Start as a background process

Modify daemonize no to daemonize yes

  • Set up redis remote connection

Comment out bind 127.0.0.1

  • Set redis connection password

##Change requirepass foobard to requirepass redis1234

Set systemctl startup program

/usr/lib/systemd/system/redis.service

[Unit]
Description=Redis 6379
After=syslog.target network.target
[Service]
Type=forking
PrivateTmp=yes
Restart=always
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
User=root
Group=root
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=100000
[Install]
WantedBy=multi-user.target
Copy after login
Configure automatic startup

systemctl daemon-reload  
systemctl enable redis
Copy after login

Startup command

systemctl enable redis 
systemctl start redis
systemctl restart redis
Copy after login

{{o.name }}

{{m.name}}

The above is the detailed content of How to install redis5.0.10 on centos7.8. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template