首頁 > 資料庫 > Redis > centos7.8怎麼安裝redis5.0.10

centos7.8怎麼安裝redis5.0.10

WBOY
發布: 2023-05-30 23:34:04
轉載
1678 人瀏覽過

準備

  • centos7.8伺服器一台

修改主機名稱

# 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
登入後複製

修改系統參數

## 修改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!

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

修改系統啟動參數關閉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
    登入後複製
  • 以上操作是解決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. Red 是disabled.

根據提示將'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的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板