如何调整和固化Azure HDInsight相关参数

如何调整和固化相关参数

前面提到,有些参数可以在创建集群时指定,这样在集群做ReImage 时这些参数还是会生效而不会改回为默认值。但有些参数,比如之前提到的关于Topology结构的参数,在创建集群的时候是不能指定的,这就需要人为去调整这些参数。
一种办法是RDP到NameNode,直接修改相关参数后再重启相应的服务。但这种做法最大的问题是当HDInsight 做ReImage 后这些参数会恢复为原来值。

如何固化这些参数?可以借助HDInsight 的Script Action 的功能来实现:

1.准备一个PowerShell 脚本: HDConfigureChange.ps1, 如下所示:

param ()
# Download config action module from a well-known directory.
$CONFIGACTIONURI = "https://hdiconfigactions.blob.core.windows.net/configactionmodulev05/HDInsightUtilities-v05.psm1";
$CONFIGACTIONMODULE = "C:\apps\dist\HDInsightUtilities.psm1";
$webclient = New-Object System.Net.WebClient;
$webclient.DownloadFile($CONFIGACTIONURI, $CONFIGACTIONMODULE);

# (TIP) Import config action helper method module to make writing config action easy.
if (Test-Path ($CONFIGACTIONMODULE))
{ 
    Import-Module $CONFIGACTIONMODULE;
} 
else
{
    Write-Output "Failed to load HDInsightUtilities module, exiting ...";
    exit;
}

#Loading Core-site.xml file
$coreSiteConfigFileLocation = "$env:HADOOP_HOME\etc\hadoop\core-site.xml";
[xml]$configFile = Get-Content $coreSiteConfigFileLocation

#Looking up for the property file.
$existingproperty = $configFile.configuration.property | where {$_.Name -eq "topology.script.file.name"}

if ($existingproperty) 
{
    $existingproperty.Value = ""
} 
else 
{
    Write-Host "Config Not Found"
    exit    
}

#Saving Core-site.xml file after changes.
$configFile.Save($coreSiteConfigFileLocation)

#Restarting all running services
$services = Get-HDIServicesRunning
foreach ($service in $services)
{
    Restart-Service $service.Name    
}

2.将该PowerShell 脚本上传到存储账号的一个Container,
这个Container要设置为Public blob Access (允许对该Blob 进行只读访问)
3.在创建HDInsight 的脚本中增加下面的代码,在创建HDInsight 集群时会执行该段脚本。

$config = Add-AzureHDInsightScriptAction -Config $config –Name TestScriptAction1 –Uri "https://publicstorage.blob.core.windows.net/hdconfig/HDConfigureChange.ps1" -ClusterRoleCollection HeadNode
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值