hadoop-cdh: simplify package installation
Move the repository addition in a pre-install.d script, as that is the right place for such operations (no more need to manual `apt-get update` run), and switch it from curl to wget (already in use in that script); as a result, wget is now installed in pre-install.d. The above change makes the installation of hadoop-hdfs-namenode and hadoop-hdfs-datanode possible using the declarative package-installs way. As a side effect of installing packages before setting up the hadoop user and group, make sure to not create them if already present. The packaging as of today takes care of creating the hadoop group, so guard the setup in case it is not done anymore or will be done for the user too. Change-Id: I248872e77358f8388f4a66a54e53b2ffa727c7e3
This commit is contained in:
parent
113ccb320c
commit
e1c6b32d1e
|
@ -1,4 +1,4 @@
|
|||
curl:
|
||||
phase: post-install.d
|
||||
wget:
|
||||
phase: post-install.d
|
||||
phase: pre-install.d
|
||||
hadoop-hdfs-namenode:
|
||||
hadoop-hdfs-datanode:
|
||||
|
|
|
@ -10,50 +10,19 @@ fi
|
|||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
if [ "$DISTRO_NAME" != "ubuntu" ]; then
|
||||
echo "Distro $DISTRO_NAME not supported by CDH. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Hadoop CDH setup begins for $DISTRO_NAME"
|
||||
tmp_dir=/tmp/hadoop
|
||||
|
||||
echo "Creating hadoop user & group"
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
addgroup hadoop
|
||||
adduser --ingroup hadoop --disabled-password --gecos GECOS hadoop
|
||||
if ! getent group hadoop > /dev/null; then
|
||||
addgroup hadoop
|
||||
fi
|
||||
if ! getent passwd hadoop > /dev/null; then
|
||||
adduser --ingroup hadoop --disabled-password --gecos GECOS hadoop
|
||||
fi
|
||||
adduser hadoop sudo
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "CDH 4 will be injected into image. Starting the download"
|
||||
|
||||
# Here more versions of CDH could be supported by downloading the right repository package.
|
||||
wget -P $tmp_dir "http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "Could not find CDH 4.\nAborting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pin packages from cloudera repository
|
||||
cat >> /etc/apt/preferences.d/cloudera << EOF
|
||||
Package: *
|
||||
Pin: origin "archive.cloudera.com"
|
||||
Pin-Priority: 800
|
||||
EOF
|
||||
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
dpkg -i $tmp_dir/cdh4-repository_1.0_all.deb
|
||||
curl -s http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key | sudo apt-key add -
|
||||
sudo apt-get update
|
||||
# Here the script could be expanded to install all CDH packages and not only HDFS.
|
||||
install-packages hadoop-hdfs-namenode hadoop-hdfs-datanode
|
||||
;;
|
||||
esac
|
||||
rm -r $tmp_dir
|
||||
|
||||
echo "Pre-configuring Hadoop"
|
||||
|
||||
cat >> /home/hadoop/.bashrc <<EOF
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
# Here more versions of CDH could be supported by downloading the right repository package.
|
||||
wget -P /tmp "http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb"
|
||||
|
||||
# Pin packages from cloudera repository
|
||||
cat >> /etc/apt/preferences.d/cloudera << EOF
|
||||
Package: *
|
||||
Pin: origin "archive.cloudera.com"
|
||||
Pin-Priority: 800
|
||||
EOF
|
||||
|
||||
dpkg -i /tmp/cdh4-repository_1.0_all.deb
|
||||
rm /tmp/cdh4-repository_1.0_all.deb
|
||||
wget -O - http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key | sudo apt-key add -
|
||||
;;
|
||||
*)
|
||||
echo "Distro $DISTRO_NAME not supported by CDH. Exiting."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue