Ottomata has uploaded a new change for review.
https://gerrit.wikimedia.org/r/237423
Change subject: Move hdfs balancer cron command into a script to be sure stdout
and stderr are properly redirected
......................................................................
Move hdfs balancer cron command into a script to be sure stdout and stderr are
properly redirected
Change-Id: I64b804a849bff53190725f4b813e3ecaf24c3f3c
---
A files/hadoop/hdfs-balancer
M manifests/role/analytics/hadoop.pp
2 files changed, 33 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/23/237423/1
diff --git a/files/hadoop/hdfs-balancer b/files/hadoop/hdfs-balancer
new file mode 100755
index 0000000..e210774
--- /dev/null
+++ b/files/hadoop/hdfs-balancer
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# NOTE: This file is managed by Puppet.
+
+#
+# Runs hdfs balancer as long as another is not already running.
+#
+
+(
+ # make sure balancer is not already running.
+ lockfile-check /tmp/hdfs-balancer && \
+ echo "$(date \'+\%y/\%m/\%d \%H:\%M:\%S\') WARN Not starting hdfs
balancer, it is already running (or the lockfile exists)."
+) || \
+(
+ # Create a lockfile
+ lockfile-create /tmp/hdfs-balancer && \
+ # Set the balancer bandwidth
+ hdfs dfsadmin -setBalancerBandwidth $((40*1048576)) && \
+ # Run the hdfs balancer.
+ /usr/bin/hdfs balancer
+
+ # Remove the lockfile
+ lockfile-remove /tmp/hdfs-balancer
+)
diff --git a/manifests/role/analytics/hadoop.pp
b/manifests/role/analytics/hadoop.pp
index 100390a..104205d 100644
--- a/manifests/role/analytics/hadoop.pp
+++ b/manifests/role/analytics/hadoop.pp
@@ -718,8 +718,15 @@
class role::analytics::hadoop::balancer {
Class['role::analytics::hadoop::client'] ->
Class['role::analytics::hadoop::balancer']
- cron {'hdfs-balancer':
- command => '(lockfile-check /tmp/hdfs-balancer && echo "$(date
\'+\%y/\%m/\%d \%H:\%M:\%S\') WARN Not starting hdfs balancer, it is already
running (or the lockfile exists)." >> /var/log/hadoop-hdfs/balancer.log) ||
(lockfile-create /tmp/hdfs-balancer && hdfs dfsadmin -setBalancerBandwidth
$((40*1048576)) && /usr/bin/hdfs balancer 2>&1 >>
/var/log/hadoop-hdfs/balancer.log; lockfile-remove /tmp/hdfs-balancer)',
+ file { '/usr/local/bin/hdfs-balancer':
+ source => 'puppet:///files/hadoop/hdfs-balancer',
+ mode => '754',
+ owner => 'hdfs',
+ group => 'hdfs',
+ }
+
+ cron { 'hdfs-balancer':
+ command => '/usr/local/bin/hdfs-balancer >>
/var/log/hadoop-hdfs/balancer.log 2>&1',
user => 'hdfs',
# Every day at 6am UTC.
minute => 0,
--
To view, visit https://gerrit.wikimedia.org/r/237423
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I64b804a849bff53190725f4b813e3ecaf24c3f3c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits