溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

centos7.8怎么安裝redis5.0.10

發(fā)布時間:2022-04-07 16:21:36 來源:億速云 閱讀:199 作者:iii 欄目:編程語言

本篇內容主要講解“centos7.8怎么安裝redis5.0.10”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“centos7.8怎么安裝redis5.0.10”吧!

準備

修改主機名

# hostnamectl set-hostname redishost

安裝redis

下載redis安裝包

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

 解壓壓縮包

# cd /opt
# tar -zxf redis-5.0.10.tar.gz

 編譯安裝

# 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

修改系統(tǒng)參數(shù)

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

以上操作是解決redis-server默認啟動提示的前兩個警告的持久方案,附redis-server默認啟動的兩個警告信息如下:

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

修改系統(tǒng)啟動參數(shù)關閉TCP

## 修改/etc/default/grub
## 在指定行加 transparent_hugepage=never
# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /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

以上操作是解決redis-server默認啟動提示的第三個警告的持久方案,附redis-server默認啟動的第三個警告信息如下:

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

根據(jù)提示將’echo never > /sys/kernel/mm/transparent_hugepage/enabled’ 寫入/etc/rc.local 其實并沒有用,換成修改grub啟動文件可以生效。

以后臺進程方式啟動redis

修改配置文件redis.conf

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

在/etc/redis/redis.conf中修改以下3項

  • 以后臺進程方式啟動

修改daemonize no 為daemonize yes

  • 設置redis遠程連接

注釋掉bind 127.0.0.1

  • 設置redis連接密碼

在requirepass foobard改為requirepass redis1234

設置systemctl啟動程序

/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

配置自動啟動

systemctl daemon-reload  
systemctl enable redis

啟動命令

systemctl enable redis 
systemctl start redis
systemctl restart redis

{{o.name}}

{{m.name}}

到此,相信大家對“centos7.8怎么安裝redis5.0.10”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI