You need to enable JavaScript to run this app.
文档中心
E-MapReduce

E-MapReduce

复制全文
下载 pdf
RayCluster 使用
Ray GCS 使用指导
复制全文
下载 pdf
Ray GCS 使用指导

前提条件

  1. 已创建Redis实例且已设置密码,如未创建请参考创建实例
  2. 已创建EMR Ray集群,创建Ray集群请参考创建虚拟集群
  3. EMR Ray 集群与 Redis 处于相同网络且 Ray 集群所在网络在 Redis 实例的白名单中。
  4. Redis 实例中的disabled-commands参数需移除 keys 以允许执行 keys 命令。

创建 GCS HA Ray cluster

  1. 服务列表中单击 Ray 进入部署拓扑页面。
  1. 点击添加RayCluster,在添加RayCluster界面打开GCS高可用,并选择对应的Redis实例,填写对应的Redis密码,点击**确定,**创建 RayCluster。

验证

在 Ray Head Pod 中创建两个 python 文件

detached_actor.py

import ray

@ray.remote(num_cpus=1)
class Counter:
    def __init__(self):
        self.value = 0

    def increment(self):
        self.value += 1
        return self.value

ray.init(namespace="default_namespace")
Counter.options(name="counter_actor", lifetime="detached").remote()

increment_counter.py

import ray

ray.init(namespace="default_namespace")
counter = ray.get_actor("counter_actor")
print(ray.get(counter.increment.remote()))

创建 actor

python3 detached_actor.py
2025-01-21 21:48:55,351 INFO worker.py:1461 -- Using address 127.0.0.1:6379 set in the environment variable RAY_ADDRESS
2025-01-21 21:48:55,351 INFO worker.py:1601 -- Connecting to existing Ray cluster at address: 10.1.0.134:6379...
2025-01-21 21:48:55,357 INFO worker.py:1777 -- Connected to Ray cluster. View the dashboard at http://10.1.0.134:8265 

python3 increment_counter.py

2025-01-21 21:49:18,140 INFO worker.py:1461 -- Using address 127.0.0.1:6379 set in the environment variable RAY_ADDRESS
2025-01-21 21:49:18,141 INFO worker.py:1601 -- Connecting to existing Ray cluster at address: 10.1.0.134:6379...
2025-01-21 21:49:18,146 INFO worker.py:1777 -- Connected to Ray cluster. View the dashboard at http://10.1.0.134:8265 
1

终止 GCS 服务

ps aux | grep gcs_server | grep -v grep | awk '{print $2}' | xargs kill -9

head 恢复后查看 actor 值

返回值为2,符合预期。

python3 increment_counter.py
2025-01-21 21:53:12,456 INFO worker.py:1461 -- Using address 127.0.0.1:6379 set in the environment variable RAY_ADDRESS
2025-01-21 21:53:12,456 INFO worker.py:1601 -- Connecting to existing Ray cluster at address: 10.1.0.134:6379...
2025-01-21 21:53:12,462 INFO worker.py:1777 -- Connected to Ray cluster. View the dashboard at http://10.1.0.134:8265 
2
最近更新时间:2025.05.15 17:20:35
这个页面对您有帮助吗?
有用
有用
无用
无用