编译安装redis,systemtcl配置redis自启动,系统并发调优

编译安装redis,systemtcl配置redis自启动,系统并发调优

1、编译安装redis

wget https://download.redis.io/releases/redis-7.4.2.tar.gz
tar -zxf redis-7.4.2.tar.gz
cd redis-7.4.2/
make
make install/usr/local/bin/redis-server -v

2、systemtcl配置redis自启动

[Unit]
Description=Redis In-Memory Data Store
After=network.target[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli -a 1234qwer shutdown
Restart=always
Type=simple[Install]
WantedBy=multi-user.target

注意:

(1)如果在命令行里复制粘贴,可能会丢失前四个字母。

可通过systemd-analyze verify /etc/systemd/system/redis.service验证语法是否正确

[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl enable redis
Failed to execute operation: Bad message
# 检验/etc/systemd/system/redis.service文件格式
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemd-analyze verify /etc/systemd/system/redis.service
[/etc/systemd/system/redis.service:1] Assignment outside of section. Ignoring.
[/etc/systemd/system/redis.service:2] Assignment outside of section. Ignoring.
[/etc/systemd/system/redis.service:3] Assignment outside of section. Ignoring.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemd-analyze verify /etc/systemd/system/redis.service
[root@iZ8vb45ie77v5ybgcemxysZ ~]#

(2)如果redis配置了密码,停止命令要加上redis-cli -a <密码> [操作参数]

# 无密码关闭
ExecStop=/usr/local/bin/redis-cli shutdown
# 有密码关闭
ExecStop=/usr/local/bin/redis-cli -a 1234qwer shutdown

3、权限不足导致redis无法重启的问题

配置完redis.service还没有完,redis会操作三个系统文件或目录:

/var/run/redis_6379.pid 存放当前redis进程的进程号,配置:pidfile /var/run/redis_6379.pid

/var/lib/redis/(目录) 存放redis持久化数据库,配置:dir /var/lib/redis

/var/log/redis/redis.log 存放redis运行日志,配置:logfile /var/log/redis/redis.log

需要将/var/run/redis_6379.pid/、/var/lib/redis/目录和/var/log/redis/目录赋予redis用户操作权限

(1)解决redis_6379.pid文件写权限问题
# 根据打印Failed to write PID file: Permission denied[root@iZ8vb45ie77v5ybgcemxysZ ~]# touch /var/run/redis_6379.pid
[root@iZ8vb45ie77v5ybgcemxysZ ~]# chown redis:redis /var/run/redis_6379.pid# 
# #logfile ""
logfile /var/log/redis/redis.log
(2)解决log文件缺失问题
# 根据提示(error) ERR Errors trying to SHUTDOWN. Check logs.
# 先设置log目录权限
chown redis:redis /var/log/redis

修改/etc/redis/redis.conf配置项

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
#logfile ""logfile /var/log/redis/redis.log
(3)解决db文件写权限问题
# 根据redis.log中的报错
9518:M 20 Mar 2025 12:16:54.936 # Failed opening the temp RDB file temp-9518.rdb (in server root dir /) for saving: Permission denied
9518:M 20 Mar 2025 12:16:54.936 # Error trying to save the DB, can't exit.
9518:M 20 Mar 2025 12:16:54.936 # Errors trying to shut down the server. Check the logs for more information.# 创建相应路径并赋予权限
chown redis:redis /var/lib/redis

修改/etc/redis/redis.conf配置项

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
#dir ./dir /var/lib/redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis      898     1  0 11:34 ?        00:00:03 /usr/local/bin/redis-server 0.0.0.0:6379
root      1502  1416  0 11:54 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status reids
Unit reids.service could not be found.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 11:34:43 CST; 19min agoMain PID: 898 (redis-server)CGroup: /system.slice/redis.service└─898 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:C 20 Mar 2025 11:34:43.508 * Configuration loaded
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # You requested maxclients of 10000 requi...ptors.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # Server can't set maximum open files to ...itted.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # Current maximum open files is 4096. max...t -n'.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 * monotonic clock: POSIX clock_gettime
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 # Failed to write PID file: Permission denied
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 * Running mode=standalone, port=6379.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 # WARNING: The TCP backlog setting of 511...f 128.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.514 * Server initialized
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.517 * Ready to accept connections tcp
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# touch /var/run/redis_6379.pid
[root@iZ8vb45ie77v5ybgcemxysZ ~]# chown redis:redis /var/run/redis_6379                                                                     .pid
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 12:05:30 CST; 1min 12s agoProcess: 5032 ExecStop=/usr/local/bin/redis-cli shutdown (code=exited, status=0/SUCCESS)Main PID: 5575 (redis-server)CGroup: /system.slice/redis.service└─5575 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:C 20 Mar 2025 12:05:30.760 * Redis version=7.4.2, bits=64, commit=0...arted
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:C 20 Mar 2025 12:05:30.760 * Configuration loaded
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # You requested maxclients of 10000 requ...tors.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # Server can't set maximum open files to...tted.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # Current maximum open files is 4096. ma... -n'.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 * monotonic clock: POSIX clock_gettime
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Running mode=standalone, port=6379.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 # WARNING: The TCP backlog setting of 51... 128.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Server initialized
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Ready to accept connections tcp
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis     5575     1  0 12:05 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root      6189  1416  0 12:07 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
5575
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli shutdown
(error) NOAUTH Authentication required.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(error) ERR Errors trying to SHUTDOWN. Check logs.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  ping
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
PONG
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli
127.0.0.1:6379> auth
(error) ERR wrong number of arguments for 'auth' command
127.0.0.1:6379> auth 1234qwer
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> SHUTDOWN
(error) ERR Errors trying to SHUTDOWN. Check logs.
127.0.0.1:6379> kill -9 5575
(error) ERR unknown command 'kill', with args beginning with: '-9' '5575'
127.0.0.1:6379> quit
[root@iZ8vb45ie77v5ybgcemxysZ ~]# kill -9 5575
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis     9518     1  0 12:16 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root      9549  1416  0 12:16 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
9518
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(error) ERR Errors trying to SHUTDOWN. Check logs.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# kill -9 9518
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    11057     1  0 12:20 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     11094  1416  0 12:20 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
11057
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli shutdown
(error) NOAUTH Authentication required.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    11240     1  0 12:20 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     11289  1416  0 12:21 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl daemon-reload
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl stop redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: inactive (dead) since Thu 2025-03-20 12:23:14 CST; 5s agoProcess: 12130 ExecStop=/usr/local/bin/redis-cli -a 1234qwer  shutdown (code=exited, status=0/SUCCESS)Process: 11240 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)Main PID: 11240 (code=exited, status=0/SUCCESS)Mar 20 12:20:54 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Started Redis In-Memory Data Store.
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Stopping Redis In-Memory Data Store...
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ redis-cli[12130]: Warning: Using a password with '-a' or '-u' option on the command line in... safe.
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Stopped Redis In-Memory Data Store.
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
root     12196  1416  0 12:23 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl start redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 12:23:31 CST; 4s agoProcess: 12130 ExecStop=/usr/local/bin/redis-cli -a 1234qwer  shutdown (code=exited, status=0/SUCCESS)Main PID: 12239 (redis-server)CGroup: /system.slice/redis.service└─12239 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 12:23:31 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Started Redis In-Memory Data Store.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    12368     1  0 12:23 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     12423  1416  0 12:23 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    12456     1  0 12:24 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     12475  1416  0 12:24 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]#
(4)解决内存过度分配(Memory Overcommit)未启用问题
11057:C 20 Mar 2025 12:20:26.509 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. 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.

从日志信息来看,Redis 提示 内存过度分配(Memory Overcommit)未启用,这可能会导致在低内存条件下后台保存(RDB 快照)或复制失败。Redis 建议启用内存过度分配以避免此类问题。


什么是内存过度分配(Memory Overcommit)?

内存过度分配是 Linux 内核的一种机制,允许系统分配比实际物理内存更多的内存。Redis 依赖于这种机制来确保在内存不足时仍能正常工作(例如,执行 RDB 快照或复制操作)。

默认情况下,Linux 内核的内存过度分配策略可能是保守的(vm.overcommit_memory = 0),这会导致 Redis 在某些情况下无法分配足够的内存。

为了永久启用内存过度分配,需要修改 /etc/sysctl.conf 文件:

  1. 打开 /etc/sysctl.conf 文件:
sudo vi /etc/sysctl.conf
  1. 在文件末尾添加以下内容:
vm.overcommit_memory = 1
  1. 保存并退出编辑器。

  2. 应用更改:

sudo sysctl -p
(5) TCP 连接队列的最大长度(即 backlog 队列)不足问题,提高系统并发性能
31867:M 20 Mar 2025 13:18:00.467 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

这个警告信息表明 Redis 在启动时尝试设置 TCP 连接的 backlog 参数为 511,但操作系统内核的 /proc/sys/net/core/somaxconn 参数值被设置为 128,低于 Redis 的配置值,因此 Redis 无法生效其配置。

:::

什么是 backlog

backlog 是 TCP 连接队列的长度,用于存储等待被 Redis 接受的客户端连接。如果连接请求的数量超过了 backlog 的值,新的连接请求可能会被拒绝。

Redis 默认的 backlog 值是 511

操作系统内核的 somaxconn 参数限制了 backlog 的最大值。
:::
:::

什么是 **somaxconn**

net.core.somaxconn 是 Linux 内核参数,用于控制 TCP 连接队列的最大长度(即 backlog 队列)。当客户端尝试连接到服务器时,如果服务器正在处理其他连接,新的连接请求会被放入 backlog 队列中,等待服务器接受。

默认值通常是 128

如果 backlog 队列已满,新的连接请求会被拒绝,客户端可能会收到 Connection refused 或超时错误。
:::

永久设置
  1. 编辑 /etc/sysctl.conf 文件:
sudo nano /etc/sysctl.conf
  1. 添加或修改以下行:
net.core.somaxconn=1024
  1. 保存并退出,然后应用更改:
sudo sysctl -p
  1. 验证修改:
cat /proc/sys/net/core/somaxconn

centos操作命令


[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis      898     1  0 11:34 ?        00:00:03 /usr/local/bin/redis-server 0.0.0.0:6379
root      1502  1416  0 11:54 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status reids
Unit reids.service could not be found.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 11:34:43 CST; 19min agoMain PID: 898 (redis-server)CGroup: /system.slice/redis.service└─898 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:C 20 Mar 2025 11:34:43.508 * Configuration loaded
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # You requested maxclients of 10000 requi...ptors.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # Server can't set maximum open files to ...itted.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 # Current maximum open files is 4096. max...t -n'.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.509 * monotonic clock: POSIX clock_gettime
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 # Failed to write PID file: Permission denied
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 * Running mode=standalone, port=6379.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.511 # WARNING: The TCP backlog setting of 511...f 128.
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.514 * Server initialized
Mar 20 11:34:43 iZ8vb45ie77v5ybgcemxysZ redis-server[898]: 898:M 20 Mar 2025 11:34:43.517 * Ready to accept connections tcp
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# touch /var/run/redis_6379.pid
[root@iZ8vb45ie77v5ybgcemxysZ ~]# chown redis:redis /var/run/redis_6379                                                                                      .pid
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 12:05:30 CST; 1min 12s agoProcess: 5032 ExecStop=/usr/local/bin/redis-cli shutdown (code=exited, status=0/SUCCESS)Main PID: 5575 (redis-server)CGroup: /system.slice/redis.service└─5575 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:C 20 Mar 2025 12:05:30.760 * Redis version=7.4.2, bits=64, commit=0...arted
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:C 20 Mar 2025 12:05:30.760 * Configuration loaded
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # You requested maxclients of 10000 requ...tors.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # Server can't set maximum open files to...tted.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 # Current maximum open files is 4096. ma... -n'.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.760 * monotonic clock: POSIX clock_gettime
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Running mode=standalone, port=6379.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 # WARNING: The TCP backlog setting of 51... 128.
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Server initialized
Mar 20 12:05:30 iZ8vb45ie77v5ybgcemxysZ redis-server[5575]: 5575:M 20 Mar 2025 12:05:30.761 * Ready to accept connections tcp
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis     5575     1  0 12:05 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root      6189  1416  0 12:07 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
5575
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli shutdown
(error) NOAUTH Authentication required.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(error) ERR Errors trying to SHUTDOWN. Check logs.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  ping
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
PONG
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli
127.0.0.1:6379> auth
(error) ERR wrong number of arguments for 'auth' command
127.0.0.1:6379> auth 1234qwer
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> SHUTDOWN
(error) ERR Errors trying to SHUTDOWN. Check logs.
127.0.0.1:6379> kill -9 5575
(error) ERR unknown command 'kill', with args beginning with: '-9' '5575'
127.0.0.1:6379> quit
[root@iZ8vb45ie77v5ybgcemxysZ ~]# kill -9 5575
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis     9518     1  0 12:16 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root      9549  1416  0 12:16 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
9518
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(error) ERR Errors trying to SHUTDOWN. Check logs.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# kill -9 9518
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    11057     1  0 12:20 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     11094  1416  0 12:20 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /var/run/redis_6379.pid
11057
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli shutdown
(error) NOAUTH Authentication required.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# redis-cli -a 1234qwer  shutdown
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    11240     1  0 12:20 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     11289  1416  0 12:21 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl daemon-reload
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl stop redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: inactive (dead) since Thu 2025-03-20 12:23:14 CST; 5s agoProcess: 12130 ExecStop=/usr/local/bin/redis-cli -a 1234qwer  shutdown (code=exited, status=0/SUCCESS)Process: 11240 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)Main PID: 11240 (code=exited, status=0/SUCCESS)Mar 20 12:20:54 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Started Redis In-Memory Data Store.
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Stopping Redis In-Memory Data Store...
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ redis-cli[12130]: Warning: Using a password with '-a' or '-u' option on the command line in... safe.
Mar 20 12:23:14 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Stopped Redis In-Memory Data Store.
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
root     12196  1416  0 12:23 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl start redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl status redis
● redis.service - Redis In-Memory Data StoreLoaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2025-03-20 12:23:31 CST; 4s agoProcess: 12130 ExecStop=/usr/local/bin/redis-cli -a 1234qwer  shutdown (code=exited, status=0/SUCCESS)Main PID: 12239 (redis-server)CGroup: /system.slice/redis.service└─12239 /usr/local/bin/redis-server 0.0.0.0:6379Mar 20 12:23:31 iZ8vb45ie77v5ybgcemxysZ systemd[1]: Started Redis In-Memory Data Store.
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    12368     1  0 12:23 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     12423  1416  0 12:23 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# ps -ef|grep redis
redis    12456     1  0 12:24 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379
root     12475  1416  0 12:24 pts/0    00:00:00 grep --color=auto redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# sysctl -p
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0
vm.overcommit_memory = 1
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]# sysctl -p
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0
vm.overcommit_memory = 1
net.core.somaxconn = 1024
[root@iZ8vb45ie77v5ybgcemxysZ ~]# cat /proc/sys/net/core/somaxconn
1024
[root@iZ8vb45ie77v5ybgcemxysZ ~]# systemctl restart redis
[root@iZ8vb45ie77v5ybgcemxysZ ~]#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/37657.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

鸿蒙HarmonyOS NEXT应用崩溃分析及修复

鸿蒙HarmonyOS NEXT应用崩溃分析及修复 如何保证应用的健壮性&#xff0c;其中一个指标就是看崩溃率&#xff0c;如何降低崩溃率&#xff0c;就需要知道存在哪些崩溃&#xff0c;然后对症下药&#xff0c;解决崩溃。那么鸿蒙应用中存在哪些崩溃类型呢&#xff1f;又改如何解决…

K8S-etcd服务无法启动问题排查

一、环境、版本信息说明 k8s&#xff1a;v1.19.16 etcdctl version: 3.5.1 3台etcd&#xff08;10.xxx.xx.129、10.xxx.xx.130、10.xxx.xx.131&#xff09;组成的集群。 二、问题根因 129节点的etcd数据与其他两台数据不一致&#xff0c;集群一致性校验出错导致无法加入集…

【视觉提示学习】3.21论文随想

. . Frontiers of Information Technology & Electronic Engineering. 2024, 25(1): 42-63 https://doi.org/10.1631/FITEE.2300389 中文综述&#xff0c;根据里面的架构&#xff0c;把视觉提示学习分成两类&#xff0c;一类是单模态提示学习&#xff08;以vit为代表&…

基于SpringBoot的“校园招聘网站”的设计与实现(源码+数据库+文档+PPT)

基于SpringBoot的“校园招聘网站”的设计与实现&#xff08;源码数据库文档PPT) 开发语言&#xff1a;Java 数据库&#xff1a;MySQL 技术&#xff1a;SpringBoot 工具&#xff1a;IDEA/Ecilpse、Navicat、Maven 系统展示 系统整体功能图 局部E-R图 系统首页界面 系统注册…

爱普生晶振FC2012AA汽车ADAS主控制系统的理想选择

在汽车智能化的浪潮中&#xff0c;先进驾驶辅助系统&#xff08;ADAS&#xff09;正迅速成为现代汽车的核心技术之一。ADAS 系统通过集成多种传感器、摄像头和高性能芯片&#xff0c;实现对车辆周围环境的实时监测和智能决策&#xff0c;为驾驶者提供全方位的安全保障。而在这一…

基于 ABAP RESTful 应用程序编程模型开发 OData V4 服务

一、概念 以个人图书管理为例&#xff0c;创建一个ABAP RESTful 应用程序编程模型项目。最终要实现的效果&#xff1a; 用于管理书籍的程序。读取、修改和删除书籍。 二、Data Model-数据模型 2.1 创建项目基础数据库表 首先&#xff0c;创建一个图书相关的表&#xff0c;点…

阿里云平台服务器操作以及发布静态项目

目录&#xff1a; 1、云服务器介绍2、云服务器界面3、发布静态项目1、启动nginx2、ngixn访问3、外网访问测试4、拷贝静态资源到nginx目录下并重启nginx 1、云服务器介绍 2、云服务器界面 实例详情&#xff1a;里面主要显示云服务的内外网地址以及一些启动/停止的操作。监控&…

注意力机制,本质上是在做什么?

本文以自注意机制为例&#xff0c;输入一个4*4的矩阵 如下&#xff1a; input_datatorch.tensor([[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16] ],dtypetorch.float) 得到Q和K的转置如下。 此时&#xff0c;计算QK^T ,得到如下结果 第一行第一个位置就是第一条样本和第…

C语言-数组指针和指针数组

指针 数组指针与指针数组 数组指针 定义 概念&#xff1a;数组指针是指向数组的指针&#xff0c;本质上还是指针 特点&#xff1a; ①先有数组&#xff0c;后有指针 ②它指向的是一个完整的数组 一维数组指针 语法&#xff1a; 数据类型 (*指针变量名)[容量]; 案例&a…

【前四届会议均已完成独立出版及EI检索 | 河南大学、河南省科学院主办,多高校单位承协办】第五届信号图像处理与通信国际学术会议(ICSIPC 2025)

第五届信号图像处理与通信国际学术会议&#xff08;ICSIPC 2025&#xff09; 2025 5th International Conference on Signal Image Processing and Communication&#xff08;ICSIPC 2025&#xff09; 会议官网&#xff1a;http://www.icsipc.org 【论文投稿】 会议时间&…

AI 时代的通信新范式:MCP(模块化通信协议)的优势与应用

文章目录 引言 1. 传统 API 的局限性2. MCP&#xff08;模块化通信协议&#xff09;的核心优势2.1 更好的模块化支持2.2 低耦合性与灵活性2.3 高性能数据传输2.4 适配分布式 AI 计算架构 3. AI 时代的 MCP 应用案例4. 结论&#xff1a;AI 时代的通信新范式 引言 在 AI 驱动的现…

Linux 文件系统的日志模式与性能影响

在 Linux 文件系统中&#xff0c;**日志模式&#xff08;Journaling Mode&#xff09;** 是文件系统保证数据一致性和快速恢复的核心机制&#xff0c;但不同的日志模式会对性能产生显著影响。以下是详细分析及优化建议&#xff1a; --- ### **一、日志模式的核心分类** Linux…

TISAX认证注意事项的详细介绍

TISAX&#xff08;Trusted Information Security Assessment Exchange&#xff09;认证的注意事项犹如企业在信息安全领域航行时必须遵循的灯塔指引&#xff0c;至关重要且不容忽视。以下是对TISAX认证注意事项的详尽阐述&#xff1a; 首先&#xff0c;企业需深入研读并理解TI…

Nodejs 项目打包部署方式

方式一&#xff1a;PM2 一、准备工作 确保服务器上已安装 Node.js 环境建议使用 PM2 进行进程管理&#xff08;需要额外安装&#xff09; 二、部署步骤 1.首先在服务器上安装 PM2&#xff08;推荐&#xff09;&#xff1a; npm install -g pm22.将项目代码上传到服务器&…

springboot整合modbus实现通讯

springboot整合modbus4j实现tcp通讯 前言 本文基于springboot和modbus4j进行简单封装&#xff0c;达到开箱即用的目的&#xff0c;目前本方案仅实现了tcp通讯。代码会放在最后&#xff0c;按照使用方法操作后就可以直接使用 介绍 在使用本方案之前&#xff0c;有必要对modb…

【论文阅读】Contrastive Clustering Learning for Multi-Behavior Recommendation

论文地址&#xff1a;Contrastive Clustering Learning for Multi-Behavior Recommendation | ACM Transactions on Information Systems 摘要 近年来&#xff0c;多行为推荐模型取得了显著成功。然而&#xff0c;许多模型未充分考虑不同行为之间的共性与差异性&#xff0c;以…

C/C++蓝桥杯算法真题打卡(Day6)

一、P8615 [蓝桥杯 2014 国 C] 拼接平方数 - 洛谷 方法一&#xff1a;算法代码&#xff08;字符串分割法&#xff09; #include<bits/stdc.h> // 包含标准库中的所有头文件&#xff0c;方便编程 using namespace std; // 使用标准命名空间&#xff0c;避免每次调用…

纯vue手写流程组件

前言 网上有很多的vue的流程组件&#xff0c;但是本人不喜欢很多冗余的代码&#xff0c;喜欢动手敲代码&#xff1b;刚开始写的时候&#xff0c;确实没法下笔&#xff0c;最后一层一层剥离&#xff0c;总算实现了&#xff1b;大家可以参考我写的代码&#xff0c;可以拿过去定制…

[特殊字符][特殊字符][特殊字符][特殊字符][特殊字符][特殊字符]壁紙 流光染墨,碎影入梦

#Cosplay #&#x1f9da;‍♀️Bangni邦尼&#x1f430;. #&#x1f4f7; 穹妹 Set.01 #后期圈小程序 琼枝低垂&#xff0c;霜花浸透夜色&#xff0c;风起时&#xff0c;微光轻拂檐角&#xff0c;洒落一地星辉。远山隐于烟岚&#xff0c;唯余一抹青黛&#xff0c;勾勒出天光水…

kafka压缩

最近有幸公司参与kafka消息压缩&#xff0c;背景是日志消息量比较大。kafka版本2.4.1 一、确认压缩算法 根据场景不同选择不同。如果是带宽敏感患者推荐高压缩比的zstd&#xff0c;如果是cpu敏感患者推荐lz4 lz4和zstd底层都使用的是lz77算法&#xff0c;具体实现逻辑不同&am…