編譯安裝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.pswp.cn/web/73002.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/73002.shtml
英文地址,請注明出處:http://en.pswp.cn/web/73002.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

firefly經典藍牙和QProcess、QFileSystemWatcher記錄

QProcess 默認不會啟動一個 shell 來解析命令,而是直接調用操作系統的系統調用來啟動外部程序。也就是通過fork一個子線程或者exec一個子進程來執行命令。 QProcess的參數模式 QProcess 需要明確指定命令的可執行文件路徑或參數列表。 如果命令是一個可執行文件的路徑…

Java定時任務的三重境界:從單機心跳到分布式協調

《Java定時任務的三重境界&#xff1a;從單機心跳到分布式協調》 本文將以生產級代碼標準&#xff0c;揭秘Java定時任務從基礎API到分布式調度的6種實現范式&#xff0c;深入剖析ScheduledThreadPoolExecutor與Quartz Scheduler的線程模型差異&#xff0c;并給出各方案的性能壓…

QT QML實現音頻波形圖進度條,可點擊定位或拖動進度

前言 本項目實現了使用QT QML創建一個音頻波形圖進度條的功能。用戶可以在界面上看到音頻波形圖&#xff0c;并且可以點擊進度條上的位置進行定位&#xff0c;也可以拖動進度條來調整播放進度。可以讓用戶更方便地控制音頻的播放進度&#xff0c;并且通過音頻波形圖可以直觀地…

高速網絡包處理,基礎網絡協議上內核態直接處理數據包,XDP技術的原理

文章目錄 預備知識TCP/IP 網絡模型&#xff08;4層、7層&#xff09;iptables/netfilterlinux網絡為什么慢 DPDKXDPBFPeBPFXDPXDP 程序典型執行流通過網絡協議棧的入包XDP 組成 使用 GO 編寫 XDP 程序明確流程選擇eBPF庫編寫eBPF代碼編寫Go代碼動態更新黑名單 預備知識 TCP/IP…

[每周一更]-(第137期):Go + Gin 實戰:Docker Compose + Apache 反向代理全流程

文章目錄 **1. Go 代碼示例&#xff08;main.go&#xff09;****2. Dockerfile 多段構建**3.構建 Docker 鏡像**4. docker-compose.yml 直接拉取鏡像****5. 運行容器****6. 測試 API**7、配置域名訪問**DNS解析&#xff1a;將域名轉換為IP地址****DNS尋址示例** 8.錯誤記錄 訪問…

SpringMVC基本使用

SpringMVC是什么&#xff1f; Spring MVC 是 Spring 框架中的一個模塊&#xff0c;用于構建基于 MVC&#xff08;Model-View-Controller&#xff09;設計模式的 Web 應用程序。它分離了應用程序的業務邏輯、用戶界面和用戶輸入&#xff0c;使開發更加模塊化和易于維護。 核心…

Qt之MVC架構MVD

什么是MVC架構&#xff1a; MVC模式&#xff08;Model–view–controller&#xff09;是軟件工程中的一種軟件架構模式&#xff0c;把軟件系統分為三個基本部分&#xff1a;模型&#xff08;Model&#xff09;、視圖&#xff08;View&#xff09;和控制器&#xff08;Controll…

Stream 流中 flatMap 方法詳解

&#x1f3af; 1. flatMap() 到底是啥&#xff1f; flatMap() 是 Stream 里的中間操作&#xff0c;它的作用可以分兩步理解&#xff1a; 第一步&#xff1a;對流里的每個元素&#xff0c;先**映射&#xff08;轉換&#xff09;**成一個 Stream。第二步&#xff1a;把多個子流…

(C語言)理解 回調函數 和 qsort函數

一. 回調函數 1. 什么是回調函數&#xff1f; 回調函數&#xff08;Callback Function&#xff09;是通過 函數指針 調用的函數。其本質是&#xff1a; 將函數作為參數傳遞給另一個函數&#xff0c;并在特定條件下被調用&#xff0c;實現 反向控制。 2. 回調函數的使用 回調函…

vscode記錄

vs code 下載安裝&#xff0c;git 配置&#xff0c;插件安裝_vscode安裝git插件-CSDN博客 手把手教你在VS Code中使用 Git_vscode如何輸入git命令-CSDN博客 VS Code | 如何快速重啟VS Code&#xff1f;_vscode 怎么一鍵全部重啟-CSDN博客 1&#xff0c;安裝插件與git集成 2&am…

唯品會商品詳情頁架構設計與實現:高并發場景下的技術實踐?

引言 唯品會作為國內領先的電商平臺&#xff0c;其商品詳情頁需要應對海量用戶的高并發訪問&#xff0c;同時保證低延遲和高可用性。本文將從架構設計、數據庫優化、緩存策略、前端渲染等方面&#xff0c;結合代碼示例&#xff0c;深入解析唯品會商品詳情頁的技術實現。 一、…

大數據學習(80)-數倉分層

&#x1f34b;&#x1f34b;大數據學習&#x1f34b;&#x1f34b; &#x1f525;系列專欄&#xff1a; &#x1f451;哲學語錄: 用力所能及&#xff0c;改變世界。 &#x1f496;如果覺得博主的文章還不錯的話&#xff0c;請點贊&#x1f44d;收藏??留言&#x1f4dd;支持一…

數智讀書筆記系列021《大數據醫療》:探索醫療行業的智能變革

一、書籍介紹 《大數據醫療》由徐曼、沈江、余海燕合著&#xff0c;由機械工業出版社出版 。徐曼是南開大學商學院副教授&#xff0c;在大數據驅動的智能決策研究領域頗有建樹&#xff0c;尤其在大數據驅動的醫療與健康決策方面有著深入研究&#xff0c;曾獲天津優秀博士論文、…

SpringSecurity——前后端分離登錄認證

SpringSecurity——前后端分離登錄認證的整個過程 前端&#xff1a; 使用Axios向后端發送請求 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>登錄</title><script src"https://cdn…

qt下載和安裝教程國內源下載地址

qt不斷在更新中&#xff0c;目前qt6日漸成熟&#xff0c;先前我們到官方下載或者國內鏡像直接可以下載到exe文件安裝&#xff0c;但是最近幾年qt官方似乎在逐漸關閉舊版本下載通道&#xff0c;列為不推薦下載。但是qt5以其廣泛使用和穩定性&#xff0c;以及積累大量代碼使得qt5…

Mysql架構理論部分

Mysql架構是什么&#xff1f;實際可以理解為執行一條sql語句所要經歷的階段有哪些&#xff01; 1.連接層 &#xff08;1&#xff09;客戶端發起連接 客戶端通過TCP/IP、Unix Socket或命名管道等方式向Mysql服務器發起鏈接請求 想要了解tcp與udp的區別&#xff0c;可以參考這…

架構師面試(十九):IM 架構

問題 IM 系統從架構模式上包括 【介紹人模式】和 【代理人模式】。介紹人模式也叫直連模式&#xff0c;消息收發不需要服務端的參與&#xff0c;即客戶端之間直連的方式&#xff1b;代理人模式也叫中轉模式&#xff0c;消息收發需要服務端進行中轉。 下面關于這兩類模式描述的…

【服務器】RAID0、RAID1、RAID5、RAID6、RAID10異同與應用

目錄 ?編輯 一、RAID概述 1.1 磁盤陣列簡介 1.2 功能 二、RAID級別 2.1 RAID 0&#xff08;不含校驗與冗余的條帶存儲&#xff09; 2.2 RAID1&#xff08;不含校驗的鏡像存儲&#xff09; 2.3 RAID 5 &#xff08;數據塊級別的分布式校驗條帶存儲&#xff09; 4、RAI…

MySQL身份驗證的auth_socket插件

在Ubuntu 20.04 LTS上&#xff0c;MySQL 8.0默認使用auth_socket插件進行身份驗證&#xff0c;可能存在意想不到的情況。 一、auth_socket插件 在使用sudo mysql或通過sudo切換用戶后執行任何MySQL命令時&#xff0c;不需要輸入密碼或錯誤密碼都可以正常登入mysql數據庫&…

小程序開發中的用戶反饋收集與分析

我們在開發小程序的過程中根據開發過程中的代碼及業務場景,以下是針對需求管理系統的用戶反饋收集與分析方案設計: 需求管理系統用戶反饋收集與分析方案 一、反饋數據模型設計 // 新增Feedback模型(app/admin/model/Feedback.php) namespace app\admin\model; use think\…