Redis安装-单机
创始人
2024-11-14 18:04:41
0

Redis基础

Redis,全称(Remote Dictionary Server),遵循BSD协议。

官方网址

https://redis.io/ 

Redis典型应用场景

Session 共享:常见于 web 集群中的 Tomcat 或者 PHP 中多 web 服务器 session 共享 消息队列:ELK 的日志缓存、部分业务的订阅发布系统 计数器:访问排行榜、商品浏览数等和次数相关的数值统计场景 缓存:数据查询、电商网站商品信息、新闻内容 微博/微信社交场合:共同好友、点赞评论等 

Redis安装

yum安装略,需要epel源

编译安装

下载最新源码包

http://download.redis.io/releases/ 

解压,并编译安装

cd /usr/local/src  tar xvf  redis-4.0.14.tar.gz  cd redis-4.0.14   make PREFIX=/usr/local/redis install 

编译出错的解决

缺少gcc库

yum install  vim iotop bc gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel zip unzip zlib-devel  net-tools lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel bc  systemd-devel bash-completion traceroute -y  

fatal error: jemalloc/jemalloc.h: No such file or directory

make MALLOC=libc  PREFIX=/usr/local/redis install 

配置文件

[root@node17 redis]# pwd /usr/local/redis  # mkdir /usr/local/redis/etc # mkdir -pv /usr/local/redis/{etc,logs}  # cp /usr/local/src/redis-4.0.14/redis.conf ./etc/ # sed -i 's@logfile ""@logfile "/usr/local/redis/logs/redis.log"@' ./etc/redis.conf   测试前台启动 # ./bin/redis-server ./etc/redis.conf  

解决警告提示

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

backlog 参数控制的是三次握手的时候 server 端收到 client ack 确认号之后的队列值。 [root@node17 ~]# vim /etc/sysctl.conf  net.core.somaxconn = 512 [root@node17 ~]# sysctl -p net.core.somaxconn = 512 

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.

[root@node17 ~]# vim /etc/sysctl.conf  [root@node17 ~]# sysctl -p net.core.somaxconn = 512 vm.overcommit_memory = 1 

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.

执行命令 # echo never > /sys/kernel/mm/transparent_hugepage/enabled  每次开机重启都执行 echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local   chmod +x /etc/rc.local  

服务脚本

[root@s1 ~]# cat /usr/lib/systemd/system/redis.service [Unit] Description=Redis persistent key-value database After=network.target After=network-online.target Wants=network-online.target [Service] ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf --supervised systemd ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID Type=notify User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target 

创建用户

[root@node17 ~]# groupadd -g 2019 redis && useradd -g redis -u 2019 redis [root@node17 ~]# id redis uid=2019(redis) gid=2019(redis) groups=2019(redis) 

授权

[root@node17 ~]# chown redis:redis /usr/local/redis/ -R 

创建软链接

[root@node17 redis]# ln -sv ./bin/* /usr/bin/ ‘/usr/bin/redis-benchmark’ -> ‘./bin/redis-benchmark’ ‘/usr/bin/redis-check-aof’ -> ‘./bin/redis-check-aof’ ‘/usr/bin/redis-check-rdb’ -> ‘./bin/redis-check-rdb’ ‘/usr/bin/redis-cli’ -> ‘./bin/redis-cli’ ‘/usr/bin/redis-sentinel’ -> ‘./bin/redis-sentinel’ ‘/usr/bin/redis-server’ -> ‘./bin/redis-server’ 

启动服务

systemctl start redis 

相关内容

热门资讯

房卡必备教程“微信金花链接在哪... 新八戒是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:160470940许多玩家在游戏中会购买房卡来...
微信群牛牛房卡去哪买/有没有玩... 牛牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡来享受...
微信群金花房卡哪里可以买/购买... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来享受...
一分钟了解“买房卡的金花房代理... 先锋大厅是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡来...
微信群金花房卡链接如何获得/牛... 牛牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来享受...
微信金花链接房卡平台/微信炸金... 微信炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡...
炸金花房卡专卖店联系方式/新二... 炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:8488009许多玩家在游戏中会购买房卡来享受...
终于找到“微信群金花房卡哪里可... 神皇大厅是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡来...
微信玩牛牛房卡链接/牛魔王大厅... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:33903369许多玩家在游戏中会购买房卡来享受...
一分钟推荐“可以一起创房的牛牛... 新518牛牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:160470940许多玩家在游戏中会购买...
斗牛微信房卡怎么购买/毛豆大厅... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:55051770许多玩家在游戏中会购买房卡来享受...
在微信里怎么开炸金花房间/微信... 炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:8488009许多玩家在游戏中会购买房卡来享受...
一分钟推荐“金花房卡在哪里能弄... 悠悠大厅是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡来...
微信群链接炸金花房卡/战神大厅... 炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:33903369许多玩家在游戏中会购买房卡来享...
正版授权“怎样创建微信金花链接... 海贝之城是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡来...
微信里面炸金花房卡在哪买/新人... 炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:55051770许多玩家在游戏中会购买房卡来享...
终于找到“金花房卡一手货源/斗... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡来享受...
微信里炸金花房卡一张多少钱/微... 炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:8488009许多玩家在游戏中会购买房卡来享受...
金花房卡专卖店联系方式/哪里有... 微信炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡...
安卓6.1系统好用吗,体验流畅... 你有没有听说安卓6.1系统最近在圈子里火了起来?不少朋友都在问我,这个系统到底好不好用。今天,我就来...