2021-12-19 01:06:50 +00:00
|
|
|
{ config, lib, options, pkgs, ...}:
|
2021-10-28 06:52:43 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.hadoop;
|
2021-12-19 01:06:50 +00:00
|
|
|
opt = options.services.hadoop;
|
2021-10-28 06:52:43 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
with lib;
|
|
|
|
{
|
2022-08-12 12:06:08 +00:00
|
|
|
imports = [ ./yarn.nix ./hdfs.nix ./hbase.nix ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
Hadoop core-site.xml definition
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/core-default.xml>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
coreSiteInternal = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
internal = true;
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Internal option to add configs to core-site.xml based on module options
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
hdfsSiteDefault = mkOption {
|
2021-10-28 06:52:43 +00:00
|
|
|
default = {
|
|
|
|
"dfs.namenode.rpc-bind-host" = "0.0.0.0";
|
2022-03-30 09:31:56 +00:00
|
|
|
"dfs.namenode.http-address" = "0.0.0.0:9870";
|
|
|
|
"dfs.namenode.servicerpc-bind-host" = "0.0.0.0";
|
|
|
|
"dfs.namenode.http-bind-host" = "0.0.0.0";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Default options for hdfs-site.xml
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
hdfsSite = mkOption {
|
|
|
|
default = {};
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Additional options and overrides for hdfs-site.xml
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
hdfsSiteInternal = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
internal = true;
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Internal option to add configs to hdfs-site.xml based on module options
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
mapredSiteDefault = 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-12-19 01:06:50 +00:00
|
|
|
defaultText = literalExpression ''
|
|
|
|
{
|
|
|
|
"mapreduce.framework.name" = "yarn";
|
|
|
|
"yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
|
|
|
|
"mapreduce.map.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
|
|
|
|
"mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
|
|
|
|
}
|
|
|
|
'';
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Default options for mapred-site.xml
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
mapredSite = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2022-03-30 09:31:56 +00:00
|
|
|
{
|
2021-10-28 06:52:43 +00:00
|
|
|
"mapreduce.map.java.opts" = "-Xmx900m -XX:+UseParallelGC";
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Additional options and overrides for mapred-site.xml
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
yarnSiteDefault = 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";
|
2022-03-30 09:31:56 +00:00
|
|
|
"yarn.resourcemanager.scheduler.class" = "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Default options for yarn-site.xml
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
yarnSite = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.anything;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2022-03-30 09:31:56 +00:00
|
|
|
{
|
2021-10-28 06:52:43 +00:00
|
|
|
"yarn.resourcemanager.hostname" = "''${config.networking.hostName}";
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Additional options and overrides for yarn-site.xml
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-common/yarn-default.xml>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
yarnSiteInternal = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
internal = true;
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-30 09:31:56 +00:00
|
|
|
Internal option to add configs to yarn-site.xml based on module options
|
|
|
|
'';
|
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
httpfsSite = mkOption {
|
|
|
|
default = { };
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
"hadoop.http.max.threads" = 500;
|
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
Hadoop httpfs-site.xml definition
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/current/hadoop-hdfs-httpfs/httpfs-default.html>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
log4jProperties = mkOption {
|
|
|
|
default = "${cfg.package}/lib/${cfg.package.untarDir}/etc/hadoop/log4j.properties";
|
2021-12-19 01:06:50 +00:00
|
|
|
defaultText = literalExpression ''
|
|
|
|
"''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}/etc/hadoop/log4j.properties"
|
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
type = types.path;
|
|
|
|
example = literalExpression ''
|
|
|
|
"''${pkgs.hadoop}/lib/''${pkgs.hadoop.untarDir}/etc/hadoop/log4j.properties";
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc "log4j.properties file added to HADOOP_CONF_DIR";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2022-03-30 09:31:56 +00:00
|
|
|
"feature.mount-cgroup.enabled" = 1;
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
example = literalExpression ''
|
|
|
|
options.services.hadoop.containerExecutorCfg.default // {
|
|
|
|
"feature.terminal.enabled" = 0;
|
|
|
|
}
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
Yarn container-executor.cfg definition
|
2022-08-21 13:32:41 +00:00
|
|
|
<https://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/SecureContainer.html>
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfDirs = mkOption {
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.path;
|
|
|
|
example = literalExpression ''
|
|
|
|
[
|
|
|
|
./extraHDFSConfs
|
|
|
|
./extraYARNConfs
|
|
|
|
]
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc "Directories containing additional config files to be added to HADOOP_CONF_DIR";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
gatewayRole.enable = mkEnableOption (lib.mdDoc "gateway role for deploying hadoop configs");
|
2022-03-30 09:31:56 +00:00
|
|
|
|
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";
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc "";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
config = mkIf cfg.gatewayRole.enable {
|
|
|
|
users.groups.hadoop = {
|
|
|
|
gid = config.ids.gids.hadoop;
|
|
|
|
};
|
|
|
|
environment = {
|
|
|
|
systemPackages = [ cfg.package ];
|
|
|
|
etc."hadoop-conf".source = let
|
|
|
|
hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/";
|
|
|
|
in "${hadoopConf}";
|
|
|
|
variables.HADOOP_CONF_DIR = "/etc/hadoop-conf/";
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|