nebula的本地账户和密码怎么持久化?

  • nebula 版本:3.0
  • 部署方式:单机
  • 安装方式:Docker
  • 是否为线上版本:Y
    具体描述:
    刚开始部署集群的时候修改过root密码,重启nebula docker集群后,root密码被重置,怎么把密码持久化?有没有具体的配置项或者相关配置文件

请问在 compose yaml 文件里 cmd 中是配置--enable_authorize 为 true,修改过的密码,重启集群,用改密码登录提示密码错误对么?

我刚做了测试,没有重现问题。

修改配置,开启 auth

diff --git a/docker-compose.yaml b/docker-compose.yaml
index 316a7d9..b369643 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -230,6 +230,7 @@ services:
       - --log_dir=/logs
       - --v=0
       - --minloglevel=0
+      - --enable_authorize=true
     depends_on:
       - storaged0
       - storaged1
@@ -266,6 +267,7 @@ services:
       - --log_dir=/logs
       - --v=0
       - --minloglevel=0
+      - --enable_authorize=true
     depends_on:
       - storaged0
       - storaged1
@@ -301,6 +303,7 @@ services:
       - --ws_http_port=19669
       - --log_dir=/logs
       - --v=0
+      - --enable_authorize=true
       - --minloglevel=0
     depends_on:
       - storaged0

重启 graphd

docker-compose up -d
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

nebula-docker-compose_metad1_1 is up-to-date
nebula-docker-compose_metad2_1 is up-to-date
nebula-docker-compose_metad0_1 is up-to-date
nebula-docker-compose_storaged2_1 is up-to-date
nebula-docker-compose_storaged1_1 is up-to-date
nebula-docker-compose_storaged0_1 is up-to-date
Recreating nebula-docker-compose_graphd2_1 ... done
Recreating nebula-docker-compose_graphd1_1 ... done
Recreating nebula-docker-compose_graphd_1  ... done
Recreating nebula-docker-compose_console_1 ... done

修改密码

❯ nebula-console-3.0 -addr nebula0 -port 9669 -user root -p nebula

Welcome to Nebula Graph!

(root@nebula) [(none)]> ALTER USER root WITH PASSWORD 'test';
Execution succeeded (time spent 1918/28389 us)

Thu, 17 Mar 2022 14:08:31 CST

(root@nebula) [(none)]>

Bye root!
Thu, 17 Mar 2022 14:08:34 CST

用错误密码登录

❯ nebula-console-3.0 -addr nebula0 -port 9669 -user root -p nebula
2022/03/17 14:08:36 Fail to create a new session from connection pool, fail to authenticate, error: Invalid password
panic: Fail to create a new session from connection pool, fail to authenticate, error: Invalid password

goroutine 1 [running]:
log.Panicf(0x10518fda3, 0x35, 0x14000105e28, 0x1, 0x1)
	/opt/hostedtoolcache/go/1.16.4/x64/src/log/log.go:361 +0xa8
main.main()
	/home/runner/work/nebula-console/nebula-console/main.go:541 +0x8a4

用正确密码登录

❯ nebula-console-3.0 -addr nebula0 -port 9669 -user root -p test

Welcome to Nebula Graph!

(root@nebula) [(none)]>

Bye root!
Thu, 17 Mar 2022 14:08:52 CST

杀掉旧的集群(但是数据还在,正常重启指的应该不是 down,而是stop,我这个做的更大)

docker-compose down
Stopping nebula-docker-compose_console_1   ... done
Stopping nebula-docker-compose_graphd_1    ... done
Stopping nebula-docker-compose_graphd1_1   ... done
Stopping nebula-docker-compose_graphd2_1   ... done
Stopping nebula-docker-compose_storaged0_1 ... done
Stopping nebula-docker-compose_storaged2_1 ... done
Stopping nebula-docker-compose_storaged1_1 ... done
Stopping nebula-docker-compose_metad0_1    ... done
Stopping nebula-docker-compose_metad1_1    ... done
Stopping nebula-docker-compose_metad2_1    ... done
Removing nebula-docker-compose_console_1   ... done
Removing nebula-docker-compose_graphd_1    ... done
Removing nebula-docker-compose_graphd1_1   ... done
Removing nebula-docker-compose_graphd2_1   ... done
Removing nebula-docker-compose_storaged0_1 ... done
Removing nebula-docker-compose_storaged2_1 ... done
Removing nebula-docker-compose_storaged1_1 ... done
Removing nebula-docker-compose_metad0_1    ... done

再起来

docker-compose up -d
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Creating network "nebula-docker-compose_nebula-net" with the default driver
Creating nebula-docker-compose_metad1_1 ... done
Creating nebula-docker-compose_metad2_1 ... done
Creating nebula-docker-compose_metad0_1 ... done
Creating nebula-docker-compose_storaged0_1 ... done
Creating nebula-docker-compose_storaged1_1 ... done
Creating nebula-docker-compose_storaged2_1 ... done
Creating nebula-docker-compose_graphd1_1   ... done
Creating nebula-docker-compose_graphd2_1   ... done
Creating nebula-docker-compose_graphd_1    ... done
Creating nebula-docker-compose_console_1   ... done

测试密码持久化

❯ nebula-console-3.0 -addr nebula0 -port 9669 -user root -p test

Welcome to Nebula Graph!

(root@nebula) [(none)]>

Bye root!
Thu, 17 Mar 2022 14:09:31 CST


~
❯ nebula-console-3.0 -addr nebula0 -port 9669 -user root -p test1
2022/03/17 14:09:32 Fail to create a new session from connection pool, fail to authenticate, error: Invalid password
panic: Fail to create a new session from connection pool, fail to authenticate, error: Invalid password

goroutine 1 [running]:
log.Panicf(0x100acfda3, 0x35, 0x140000a9e28, 0x1, 0x1)
	/opt/hostedtoolcache/go/1.16.4/x64/src/log/log.go:361 +0xa8
main.main()
	/home/runner/work/nebula-console/nebula-console/main.go:541 +0x8a4
3 个赞

试试上面 wey 的方式,如果你成功了,可以勾选他的回复为解决方案哈

从清蒸那里了解到您没有意识到 docker 里的配置写在 cmd 部份,这部份文档里在配置的地方有介绍,至于为什么这么配置,感兴趣可以看我的这个视频哈

好的,感谢您的解决方案

1 个赞

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。