hadoop集群中的map任务中是否可以启动特定的进程?

p5fdfcr1  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(409)

我使用一个hadoop&yarn集群和一个节点。所有hadoop和yarn守护进程都在此节点中启动。我还使用ApacheNutch1.15分布式爬网启动了一个获取步骤,成功完成了注入和生成步骤。
我尝试在Map任务中运行firefox浏览器,该任务在yarnchild容器上运行,使用selenium3.149.54firefoxdriver。firefox进程启动,但弹出一个窗口,指出firefox配置文件丢失或无法访问,并且map任务被阻止,直到我关闭窗口。
selenium 3.141.54 firefoxdriver使用geckodriver启动firefox,从容器userlog的stderr日志中的geckodriver输出,我看到它试图使用以下命令运行firefox:

1557726792743   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.0dQXae46ZwUd" "-foreground" "-no-remote"

我注意到的是,在一个map任务中,我可以从主机本地文件系统访问二进制文件,比如/usr/bin/firefox,但是当firefoxdriver在map任务中启动firefox时,使用位于主机本地文件系统中的geckodriver,使用上面的命令,firefox进程无法看到位于主机本地fs/tmp中的“/tmp/rust\u mozprofile.0dqxae46zwud”目录。
我尝试设置firefoxdriver使用hdfs中的一个配置文件,该配置文件与/tmp中的临时配置文件具有相同的信息,但是仍然会出现表示该配置文件丢失或无法访问的窗口。
我已经尝试从map任务中使用hadoop localfilesystem api从主机本地fs/tmp读取一个文件,我可以读取它,因此我可以从map任务访问本地fs。
知道了这些,我不明白为什么geckodriver不能使用/tmp中的配置文件启动firefox。
下面的代码是在从getprotocoloutput、从fetcherthread(在fetcherrunMap器中启动)调用的嵌套函数中运行的主代码。简单地说,以下代码在Map器中启动的特定线程中运行:

profile = new FirefoxProfile();
    boolean enableFlashPlayer = conf.getBoolean("selenium.firefox.enable.flash", false);
    int loadImage = conf.getInt("selenium.firefox.load.image", 1);
    int loadStylesheet = conf.getInt("selenium.firefox.load.stylesheet", 1);
    System.setProperty("webdriver.gecko.driver", conf.get("webdriver.gecko.driver"));

    profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", enableFlashPlayer);
    profile.setPreference("permissions.default.stylesheet", loadImage);
    profile.setPreference("permissions.default.image", loadStylesheet);
    profile.setPreference("marionette", false);
    profile.setAcceptUntrustedCertificates(true);

    long firefoxBinaryTimeout = conf.getLong("selenium.firefox.binary.timeout", 45);
    binary = new FirefoxBinary();
    binary.setTimeout(TimeUnit.SECONDS.toMillis(firefoxBinaryTimeout));

    binary.addCommandLineOptions("-profile", "/home/iulian/firefox.profile");

    options = new FirefoxOptions(); 
    options.setBinary(binary).setProfile(profile);

    driver = new FirefoxDriver(options); // the execution stop here and the window appears, which says that firefox profile is missing or is inaccessible 
    System.out.println("Finished starting driver.");
    long pageLoadWait = conf.getLong("libselenium.page.load.delay", 10);
    driver.manage().timeouts().pageLoadTimeout(pageLoadWait, TimeUnit.SECONDS);

你认为问题出在哪里?如何以简单的方式调试对/tmp的访问?
提前谢谢!

euoag5mw

euoag5mw1#

我设法找到了问题所在。
启动firefox浏览器时,此浏览器需要具有有效home env变量路径目录的环境,这意味着home目录应与启动浏览器的当前用户相对应,以便创建firefox配置文件相关文件。
hadoop的map任务的问题,在我的例子中,是home env变量,它只是“home=/home/”。我对执行Map任务的用户没有此目录的写入权限,并且隐式地对firefox浏览器没有写入权限。因此,每次出现的弹出窗口都是因为firefox浏览器无法在主目录中创建与概要文件相关的文件。

相关问题