Skip to content

Instantly share code, notes, and snippets.

@mrmichalis
mrmichalis / getip.sh
Last active December 15, 2015 00:19
for IP in 201 202 247; do ssh root@$IP 'sh -s' < getip.sh >> /etc/hosts; done
#!/usr/bin/env bash
if [ $# -lt 1 ]; then
echo "usage: $0 [hosts list]" 1>&2
exit 1
fi
HOSTSLIST=$1
IPADDR=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
if [ -a $HOSTSLIST ]; then
#!/bin/bash
#
# createPXE.sh v.02
#
# You MUST edit variables to your environment
# or the deployment will be unsuccessful.
# READ script before executing!
# Note that the subnet variable is NOT your subnet MASK,
# rather the subnet (or network) on which the machine would reside.
@mrmichalis
mrmichalis / krb5conf.sh
Last active December 15, 2015 09:29
/etc/krb5.conf /var/kerberos/krb5kdc/kadm5.acl */admin@LUNIX.CO *
#!/usr/bin/env bash
#http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Security-Guide/cdh4sg_topic_3.html
#http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Managing-Clusters/cmmc_hadoop_security.html
#pre-req
yum install krb5-server krb5-workstation krb5-libs -y
echo "* Downloading Java Cryptography Extension (JCE) ..."
wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip -O /root/CDH/jce_policy-6.zip
[[ -d "/usr/java/default/jre/lib/security/" ]] && unzip -oj /root/CDH/jce_policy-6.zip -d /usr/java/default/jre/lib/security/
if [ $# -lt 1 ]; then
@mrmichalis
mrmichalis / rackId.py
Last active December 15, 2015 11:39
Cloudera Manager 4.5 compatible Update rackId for all hosts
#!/usr/bin/env python
from cm_api.api_client import ApiResource
from cm_api.endpoints.hosts import ApiHost
import json
def update_rackId(resource_root, host_id, rack_id=None):
resp = resource_root.put('%s/%s' % ("/hosts", host_id), data=json.dumps({"rackId":rack_id}))
return ApiHost.from_json_dict(resp, resource_root)
@mrmichalis
mrmichalis / jstackSeries.sh
Created April 2, 2013 10:03
Just run it like this: sh jstackSeries.sh [pid] [cq5serveruser] [count] [delay] For example: sh jstackSeries.sh 1234 cq5serveruser 10 3
#!/bin/bash
if [ $# -eq 0 ]; then
echo >&2 "Usage: jstackSeries <pid> <run_user> [ <count> [ <delay> ] ]"
echo >&2 " Defaults: count = 10, delay = 0.5 (seconds)"
exit 1
fi
pid=$1 # required
user=$2 # required
count=${3:-10} # defaults to 10 times
delay=${4:-0.5} # defaults to 0.5 seconds
.DS_Store
*.log
Gemfile.lock
@mrmichalis
mrmichalis / .bash_profile
Last active December 15, 2015 18:39
Get latest Hadoop CHD4
# Installations directory
export INSTALLS=$HOME/Work/installs
# CDH Apache Hadoop and Ecosystem
export HADOOP_PREFIX=$INSTALLS/hadoop-2.0.0
export HADOOP_MR1_HOME=$INSTALLS/mr1-2.0.0
export HADOOP_LOG_DIR=$HADOOP_PREFIX/logs
export HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop
#export HADOOP_MAPRED_HOME=$HADOOP_PREFIX/share/hadoop/mapreduce
#export HADOOP_YARN_HOME=$HADOOP_PREFIX/share/hadoop/mapreduce
@mrmichalis
mrmichalis / wordcount.sh
Created May 14, 2013 20:12
This script will download all of Shakespeare’s books from project, Gutenberg, upload them to HDFS and run a Map Reduce operation run a word count against the text.
#!/bin/bash
# curl -L "https://raw.github.com/sacharya/random-scripts/master/knife-rackspace-hadoop/wordcount.sh" | bash
set -x
hadoop fs -rmr /shakespeare
cd /tmp
wget http://homepages.ihug.co.nz/~leonov/shakespeare.tar.bz2
tar xjvf shakespeare.tar.bz2
now=`date +"%y%m%d-%H%M"`
hadoop fs -put /tmp/Shakespeare /shakespeare/$now/input
@mrmichalis
mrmichalis / hive-mysql-grants.sh
Last active December 17, 2015 08:19
WIP: shell to install hive metastore
for service in amon smon rman hmon nav hive; do
mysql -u root -e 'create database $service DEFAULT default character set utf8 collate utf8_general_ci;'
mysql -u root -e "grant all on $service.* TO '$service'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'192-168-1-109.lunix.co' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'%.lunix.co' IDENTIFIED BY 'password';"
done
mysql -u root -e 'show databases;'
@mrmichalis
mrmichalis / dotpath.sh
Last active December 17, 2015 19:38
Manage your PATH with a nice, one-directory-per-line file, rather than a gargantuan blob of colon-delimited text. https://gist.github.com/willurd/5648907
# Read the contents of ~/.path into $PATH, if ~/.path exists. ~/.path should be a file
# consisting of one path on each line, such as:
#
# ~$ cat ~/.path
# # vim: ft=sh
# ~/usr/bin
# /opt/local/bin
# ... etc ...
#
# Note that comments begin with a hash (#).