2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ...}:
|
2021-10-28 06:52:43 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.hadoop;
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
imports = [ ./yarn.nix ./hdfs.nix ];
|
|
|
|
|
|
|
|
options.services.hadoop = {
|
|
|
|
coreSite = mkOption {
|
|
|
|
default = {};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
"fs.defaultFS" = "hdfs://localhost";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = "Hadoop core-site.xml definition";
|
|
|
|
};
|
|
|
|
|
|
|
|
hdfsSite = mkOption {
|
2021-10-28 06:52:43 +00:00
|
|
|
default = {
|
|
|
|
"dfs.namenode.rpc-bind-host" = "0.0.0.0";
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
"dfs.nameservices" = "namenode1";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = "Hadoop hdfs-site.xml definition";
|
|
|
|
};
|
|
|
|
|
|
|
|
mapredSite = mkOption {
|
2021-10-28 06:52:43 +00:00
|
|
|
default = {
|
|
|
|
"mapreduce.framework.name" = "yarn";
|
|
|
|
"yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}";
|
|
|
|
"mapreduce.map.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}";
|
|
|
|
"mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}";
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2021-10-28 06:52:43 +00:00
|
|
|
options.services.hadoop.mapredSite.default // {
|
|
|
|
"mapreduce.map.java.opts" = "-Xmx900m -XX:+UseParallelGC";
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = "Hadoop mapred-site.xml definition";
|
|
|
|
};
|
|
|
|
|
|
|
|
yarnSite = mkOption {
|
2021-10-28 06:52:43 +00:00
|
|
|
default = {
|
|
|
|
"yarn.nodemanager.admin-env" = "PATH=$PATH";
|
|
|
|
"yarn.nodemanager.aux-services" = "mapreduce_shuffle";
|
|
|
|
"yarn.nodemanager.aux-services.mapreduce_shuffle.class" = "org.apache.hadoop.mapred.ShuffleHandler";
|
|
|
|
"yarn.nodemanager.bind-host" = "0.0.0.0";
|
|
|
|
"yarn.nodemanager.container-executor.class" = "org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor";
|
|
|
|
"yarn.nodemanager.env-whitelist" = "JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,LANG,TZ";
|
|
|
|
"yarn.nodemanager.linux-container-executor.group" = "hadoop";
|
|
|
|
"yarn.nodemanager.linux-container-executor.path" = "/run/wrappers/yarn-nodemanager/bin/container-executor";
|
|
|
|
"yarn.nodemanager.log-dirs" = "/var/log/hadoop/yarn/nodemanager";
|
|
|
|
"yarn.resourcemanager.bind-host" = "0.0.0.0";
|
|
|
|
"yarn.resourcemanager.scheduler.class" = "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler";
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2021-10-28 06:52:43 +00:00
|
|
|
options.services.hadoop.yarnSite.default // {
|
|
|
|
"yarn.resourcemanager.hostname" = "''${config.networking.hostName}";
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = "Hadoop yarn-site.xml definition";
|
|
|
|
};
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
log4jProperties = mkOption {
|
|
|
|
default = "${cfg.package}/lib/${cfg.package.untarDir}/etc/hadoop/log4j.properties";
|
|
|
|
type = types.path;
|
|
|
|
example = literalExpression ''
|
|
|
|
"''${pkgs.hadoop}/lib/''${pkgs.hadoop.untarDir}/etc/hadoop/log4j.properties";
|
|
|
|
'';
|
|
|
|
description = "log4j.properties file added to HADOOP_CONF_DIR";
|
|
|
|
};
|
|
|
|
|
|
|
|
containerExecutorCfg = mkOption {
|
|
|
|
default = {
|
|
|
|
# must be the same as yarn.nodemanager.linux-container-executor.group in yarnSite
|
|
|
|
"yarn.nodemanager.linux-container-executor.group"="hadoop";
|
|
|
|
"min.user.id"=1000;
|
|
|
|
"feature.terminal.enabled"=1;
|
|
|
|
};
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
example = literalExpression ''
|
|
|
|
options.services.hadoop.containerExecutorCfg.default // {
|
|
|
|
"feature.terminal.enabled" = 0;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = "Yarn container-executor.cfg definition";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfDirs = mkOption {
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.path;
|
|
|
|
example = literalExpression ''
|
|
|
|
[
|
|
|
|
./extraHDFSConfs
|
|
|
|
./extraYARNConfs
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = "Directories containing additional config files to be added to HADOOP_CONF_DIR";
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.hadoop;
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "pkgs.hadoop";
|
2021-02-05 17:12:51 +00:00
|
|
|
description = "";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
(mkIf (builtins.hasAttr "yarn" config.users.users ||
|
|
|
|
builtins.hasAttr "hdfs" config.users.users) {
|
|
|
|
users.groups.hadoop = {
|
|
|
|
gid = config.ids.gids.hadoop;
|
|
|
|
};
|
2021-10-28 06:52:43 +00:00
|
|
|
environment = {
|
|
|
|
systemPackages = [ cfg.package ];
|
|
|
|
etc."hadoop-conf".source = let
|
|
|
|
hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/";
|
|
|
|
in "${hadoopConf}";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
];
|
|
|
|
}
|