Redis

連接到 redis 6.0+ 時,WRONGPASS 無效的使用者名-密碼對或使用者被禁用

  • January 19, 2022

我試圖連接 redis 6.0+,這是我現在配置的 Python celery redis 代理 url:

broker_url = redis://:default:123456@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5
celery_result_backend = redis://:default:123456@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5

但是當我使用這個命令啟動芹菜時:

root@pydolphin-service-6fc4b98f54-msfql:~/pydolphin# celery -A dolphin.tasks.tasks worker --loglevel=INFO -n worker2 -Q non_editor_pick_and_diff_pull --concurrency 2
/usr/local/lib/python3.9/site-packages/celery/platforms.py:834: SecurityWarning: You're running the worker with superuser privileges: this is
absolutely not recommended!

Please specify a different user using the --uid option.

User information: uid=0 euid=0 gid=0 egid=0

 warnings.warn(SecurityWarning(ROOT_DISCOURAGED.format(

-------------- celery@worker2 v5.1.2 (sun-harmonics)
--- ***** ----- 
-- ******* ---- Linux-3.10.0-1160.31.1.el7.x86_64-x86_64-with-glibc2.28 2021-08-08 20:45:35
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         tasks:0x7fb4f6c2dd90
- ** ---------- .> transport:   redis://:**@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5
- ** ---------- .> results:     redis://:**@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5
- *** --- * --- .> concurrency: 2 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
-------------- [queues]
               .> non_editor_pick_and_diff_pull exchange=non_editor_pick_and_diff_pull(direct) key=non_editor_pick_and_diff_pull
               

[tasks]
 . pydolphin.dolphin.tasks.cert-tasks
 . pydolphin.dolphin.tasks.tasks

[2021-08-08 20:45:35,540: ERROR/MainProcess] consumer: Cannot connect to redis://:**@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5: WRONGPASS invalid username-password pair or user is disabled..
Trying again in 2.00 seconds... (1/100)

[2021-08-08 20:45:37,547: ERROR/MainProcess] consumer: Cannot connect to redis://:**@cruise-redis-headless.reddwarf-cache.svc.cluster.local:6379/5: WRONGPASS invalid username-password pair or user is disabled..
Trying again in 4.00 seconds... (2/100)

^C
worker: Hitting Ctrl+C again will terminate all running tasks!

worker: Warm shutdown (MainProcess)

我確定使用者名和密碼正確,因為我可以使用該redis-cli命令登錄 redis。問題出在哪裡,我應該怎麼做才能解決它?

它可能是 URL 中使用者名之前的“:”。本來應該

redis://default:123456@cruise-redis...

您可能在 URL 中使用前導冒號的情況是使用密碼但沒有使用者名進行連接時。然後它看起來像這樣:

redis://:somepass@host...

引用自:https://dba.stackexchange.com/questions/297751