`
mryufeng
  • 浏览: 977461 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

erlang允许不同的节点有不同的cookie

阅读更多
节点间的认证是通过cookie运算挑战码再比较是否相同而决定节点间可否连接。

11.7 Security

Authentication determines which nodes are allowed to communicate with each other. In a network of different Erlang nodes, it is built into the system at the lowest possible level. Each node has its own magic cookie, which is an Erlang atom.

When a nodes tries to connect to another node, the magic cookies are compared. If they do not match, the connected node rejects the connection.

At start-up, a node has a random atom assigned as its magic cookie and the cookie of other nodes is assumed to be nocookie. The first action of the Erlang network authentication server (auth) is then to read a file named $HOME/.erlang.cookie. If the file does not exist, it is created. The UNIX permissions mode of the file is set to octal 400 (read-only by user) and its contents are a random string. An atom Cookie is created from the contents of the file and the cookie of the local node is set to this using erlang:set_cookie(node(), Cookie). This also makes the local node assume that all other nodes have the same cookie Cookie.

Thus, groups of users with identical cookie files get Erlang nodes which can communicate freely and without interference from the magic cookie system. Users who want run nodes on separate file systems must make certain that their cookie files are identical on the different file systems.

For a node Node1 with magic cookie Cookie to be able to connect to, or accept a connection from, another node Node2 with a different cookie DiffCookie, the function erlang:set_cookie(Node2, DiffCookie) must first be called at Node1. Distributed systems with multiple user IDs can be handled in this way.

The default when a connection is established between two nodes, is to immediately connect all other visible nodes as well. This way, there is always a fully connected network. If there are nodes with different cookies, this method might be inappropriate and the command line flag -connect_all false must be set, see erl(1).

The magic cookie of the local node is retrieved by calling erlang:get_cookie().

我过去以为你个erlang集群只能使用一个cookie但是实际上理解错误.
默认情况下和所有的节点通信都是用本地的cookie, 但是如果别的节点有不同的cookie, 我们可以erlang:set_cookie(Node2, DiffCookie),然后再connect_node().

注意Auth模块已经废弃了,请不要使用.

分享到:
评论
2 楼 mryufeng 2009-04-02  
有这个特性做p2p就方便多了
1 楼 litaocheng 2009-04-01  

哈哈,老大,我老早就发现拉哈哈。 erlang:set_cookie/2 可以指明要连接的node的cookie

相关推荐

    erlang学习笔记

    通过`set_cookie()`函数设置节点间的信任关系,从而实现跨节点的进程通信。此外,`register()`函数允许注册进程名称,便于其他进程通过名称查找和通信。 #### 6. Erlang的分布式计算 Erlang的分布式计算能力是其一...

    RabbitMQ服务端安装使用手册

    - **统一Erlang Cookie**:在所有节点上,确保`/var/lib/rabbitmq/.erlang.cookie`文件内容一致。 - **创建Cluster**: - 停止新节点的应用: ``` rabbitmqctl stop_app ``` - 加入现有集群: ``` ...

    RabbitMQ消息服务用户手册2

    - Erlang Cookie是集群认证的关键,所有节点需有相同的Cookie值。 - Cookie文件默认位于`/var/lib/rabbitmq/.erlang.cookie`或`/root/.erlang.cookie`。 9. **集群搭建步骤**: - 安装必要的依赖包,例如Erlang...

    erlang-cnode-example

    - 创建CNode时,需要初始化Erlang的`erl_interface`库,并指定节点名称、cookie等参数。 - 使用`ei`库来处理Erlang的数据类型,如erts编码和解码。 3. **与Erlang进程通信** - CNode可以像Erlang进程一样接收和...

    RabbitMQ消息服务用户手册.docx

    1. **Cookie 文件同步**:选择一个节点为主节点,并将该节点的 `.erlang.cookie` 文件同步至其他节点。 #### 八、集群组建步骤 1. **服务停止**:先停止所有节点上的服务。 2. **集群命令配置**:使用集群命令配置...

    Rabbitmq的安装和集群的搭建

    .erlang.cookie文件用于在Erlang节点间建立通信,每个节点通过此cookie值来验证彼此的身份。因此,需要将其中一个节点的cookie值复制到集群中所有节点的相同位置。 在加入节点到集群之前,需要停止应用(stop_app)...

    RabbitMQ-3.7.2安装手册

    首先,AMQP是一个开放标准的协议,它允许不同的编程语言之间进行消息传递。对于Java开发者来说,虽然MySQL数据库并不是用Java编写的,但Java可以通过特定的驱动程序来访问MySQL。同样,RabbitMQ也提供了驱动程序,...

    可集群的:准备将elixirerlang节点集群

    它允许Elixir进程在不同的节点间相互通信,就像它们在同一个进程中一样。这使得Elixir应用程序能够跨多台服务器无缝运行,从而提高系统的可靠性和可伸缩性。 **Elixir和Erlang集群的建立** 要创建Elixir/Erlang集群...

    Riak 学习文档

    每个数据项都有 N 个副本(N 可自定义),这些副本存储在不同的节点上,以防止单点故障。 2. **一致性哈希**:Riak 使用一致性哈希算法来确定数据的存储位置,这使得添加或移除节点时,对整个集群的影响最小化,...

    rabbitmq集群环境搭建

    - **复制cookie文件**:在每个集群节点之间需要复制`.erlang.cookie`文件,以确保节点间的通信一致性和安全性。 ```bash cat /var/lib/rabbitmq/.erlang.cookie # 或者 cat /root/.erlang.cookie ``` 将输出...

    rabbitmq安装包

    - 修改`erlang.cookie`文件,确保所有节点间通信的安全。 6. **验证安装** - 访问Web管理界面(默认为`http://localhost:15672`),输入默认用户名`guest`和密码`guest`(生产环境中应修改)。 - 通过命令行工具...

    rabbitMQ课件.zip

    4. 防火墙设置:开放所需端口,允许节点间通信。 5. 监控集群状态:通过Web管理界面或API检查集群的健康状况。 以上内容涵盖了RabbitMQ的基础知识、与Spring/SpringBoot的整合、高级特性以及安装和集群搭建,这些...

    RabbitMQ使用手册V1.0.0.pdf

    多机集群配置部分详细说明了如何设置和管理RabbitMQ的集群模式,这包括配置集群的主机名(hostname)、防火墙端口配置、复制.erlang.cookie文件、启动和停止RabbitMQ节点、加入集群、更改集群类型、脱离集群、设置...

    基于ARM64架构linux系统的RabbitMQ离线安装依赖包unixodbc_2.3.1-4.1-arm64.deb

    RabbitMQ使用.erlang.cookie作为节点间通信的安全凭据,也需要确保其安全性。 7. **服务启动与监控**:安装完成后,需要启动RabbitMQ服务,并使用`rabbitmqctl`工具进行监控和管理。例如,启动服务的命令可能是: ...

    rabbitmq-server-windows-3.7.24.zip

    4. **配置环境变量**: 为了方便使用,可以设置RABBITMQ_BASE环境变量指向RabbitMQ安装目录,并将RABBITMQ_SASL_PASSWORD和RABBITMQ_ERLANG_COOKIE设置为适当的值,以提高安全性。 5. **管理插件**: RabbitMQ提供了...

Global site tag (gtag.js) - Google Analytics