温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos7.8怎么安装redis5.0.10

发布时间:2022-04-07 16:21:36 来源:亿速云 阅读:244 作者: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

修改系统参数

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

修改系统启动参数关闭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.

根据提示将’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”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI