您的位置:首页 > 其它

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

2015-11-02 15:59 253 查看
如何调整和固化相关参数

前面提到,有些参数可以在创建集群时指定,这样在集群做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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: