redis

编译安装命令

下载源码包

https://redis.io/download

# pwd
/usr/1ocal/src
# tar xf redis-5.0.3.tar.gz
# cd redis-5.0.3
# make PREFIX=/apps/redis insta11  #指定redis安装目录
# ll /usr/local/redis/
total 0
drwxr-xr-x2root root134 Dec 13 09:21 bin
# mkdir /apps/redis/{etc,1ogs,data,run}  #创建配置文件、日志、数据等目录
# cp redis.conf /usr/local/redis/etc/

ubuntu :
redis-6.2.2# sudo apt-get install libsystemd-dev
redis-6.2.2# make UE_SYSTEMD=yeS PREFIX=/apps/redis install

 解决告警:

1 tcp-backlog:

The backlog argument defines the maximum length to which the queue of pending connections for sockfdmay grow. lf a connection request arrives when the queue is ful, the client may receive an error with anindication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may beignored so that a later reattempt at connection succeeds
backlog参数控制的是三次握手的时候server端收到client ack确认号之后的队列值。

echo “net.core.somaxconn = 1024” >> /etc/sysctl.conf  
sysctl -p

2 vm.overcommit memory:
0、表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。1、表示内核允许分配所有的物理内存,而不管当前的内存状态如何。2、表示内核允许分配超过所有物理内存和交换空间总和的内存
未经授权禁止

wm.overcommit memory = 1

3 transparent hugepage:
大页内存动态分配,需要关闭让redis 负责内存管理。

echo never>/sys/kernel/mm/transparent_hugepage/enabled

 

4:编辑redis服务启动脚本:

[root@sl ~]# 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/bin/redis-server /etc/redis.conf --supervised systemdExecstart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd
ExecReload=/bin/ki11-S HUP $MAINPID
Execstop=/bin/ki11 -S QUIT $MAINPID
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Insta11]
wantedBy=multi-user.target

 

posted @ 2025-05-13 15:12  原味玉米烙  阅读(28)  评论(0)    收藏  举报