Add CentOS support

* As base image we use our own CentOS cloud image with preinstalled cloud-init
* Configuring that image
* Edit hadoop, mysql element for CentOS support and 'diskimage-create' script

Change-Id: If5570f31fd69c7cc809948dd2fa0249d00323f50
This commit is contained in:
iberezovskiy 2013-10-25 14:51:48 +04:00
parent 27c7f9beb6
commit 6b46f637fc
12 changed files with 122 additions and 33 deletions

View File

@ -0,0 +1,35 @@
This element setups our CentOS cloud image (http://savanna-files.mirantis.com/CentOS-6.4-cloud-init.qcow2):
1. Disable filesystem checks;
2. Use specifies for CentOS only map-package and install-package files;
3. Install redhat-lsb package for using command `lsb_release`.
For preparing your own CentOS cloud image with pre-installed cloud-init you should follow this guide:
`CentOS cloud image <http://docs.openstack.org/grizzly/openstack-image/content/centos-image.html>`_
In the end you should check installation of cloud-init packege.
You should mount your image and check some files. Follow this example to mount cloud image using qemu:
.. sourcecode:: bash
sudo modprobe nbd max_part=63
sudo qemu-nbd -c /dev/nbd0 CentOS_image_name.qcow2
sudo partprobe /dev/nbd0
sudo mount /dev/nbd0p1 /mnt/qemu
sudo chroot /mnt/qemu
Check files:
1. File '/etc/cloud/cloud.cfg' should contain these lines:
default_user:
name: cloud-user
lock_passwd: true
gecos: CentOS Cloud User
groups: [wheel, adm]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
Add them if they are not exist.
2. File '/etc/fstab'. Check that fifth and sixth fields contain value '0'.

View File

@ -1,7 +1,9 @@
Diskimage-builder script for creation cloud images
=================================================
==================================================
This scrtips builds Ubuntu and Fedora cloud images with default parameters.
This scrtips builds Ubuntu, Fedora, CentOS cloud images with default parameters.
NOTE: You should use Ubuntu or Fedora host OS for building images, CentOS as a host OS has not been tested well.
For users:

View File

@ -8,16 +8,27 @@ export DIB_HADOOP_VERSION="1.2.1"
export JAVA_DOWNLOAD_URL="http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
export ubuntu_image_name="ubuntu_savanna_latest"
export fedora_image_name="fedora_savanna_latest"
export centos_image_name="centos_savanna_latest"
export OOZIE_DOWNLOAD_URL="http://savanna-files.mirantis.com/oozie-4.0.0.tar.gz"
export HIVE_VERSION="0.11.0"
platform=$(head -1 /etc/os-release)
if [ $platform = 'NAME="Ubuntu"' ]; then
apt-get update -y
apt-get install qemu kpartx git -y
elif [ $platform = 'NAME=Fedora' ]; then
yum update -y
yum install qemu kpartx git -y
if [ -e /etc/os-release ]; then
platform=$(head -1 /etc/os-release)
if [ $platform = 'NAME="Ubuntu"' ]; then
apt-get update -y
apt-get install qemu kpartx git -y
elif [ $platform = 'NAME=Fedora' ]; then
yum update -y
yum install qemu kpartx git -y
fi
else
platform=$(head -1 /etc/system-release | grep CentOS)
if [ -z $platform ]; then
yum update -y
yum install qemu-kvm kpartx git -y
else
echo -e "Unknown Host OS. Impossible to build images.\nAborting"
fi
fi
TEMP=$(mktemp -d diskimage-create.XXXXXX)
@ -43,18 +54,23 @@ popd
ubuntu_elements_sequence="base vm ubuntu hadoop swift_hadoop oozie mysql hive"
fedora_elements_sequence="base vm fedora hadoop swift_hadoop oozie mysql hive"
centos_elements_sequence="vm rhel hadoop swift_hadoop oozie mysql hive redhat-lsb"
# Workaround for https://bugs.launchpad.net/diskimage-builder/+bug/1204824
if [ $platform = 'NAME="Ubuntu"' ]; then
# https://bugs.launchpad.net/savanna/+bug/1252684
if [ "$platform" = 'NAME="Ubuntu"' ]; then
echo "**************************************************************"
echo "WARNING: As a workaround for DIB bug 1204824, you are about to"
echo " create a Fedora image that has SELinux disabled. Do "
echo " not use this image in production. "
echo " create a Fedora and CentOS images that has SELinux "
echo " disabled. Do not use these images in production. "
echo "**************************************************************"
fedora_elements_sequence="$fedora_elements_sequence selinux-permissive"
centos_elements_sequence="$centos_elements_sequence selinux-permissive"
fedora_image_name="$fedora_image_name.selinux-permissive"
centos_image_name="$centos_image_name.selinux-permissive"
fi
# CentOS mirror will be added some later
if [ -n "$USE_MIRRORS" ]; then
mirror_element=" apt-mirror"
ubuntu_elements_sequence=$ubuntu_elements_sequence$mirror_element
@ -66,12 +82,21 @@ fi
disk-image-create $ubuntu_elements_sequence -o $ubuntu_image_name
# Creating Fedora cloud image
# Patameter 'DIB_IMAGE_SIZE' should be specified for Fedora only
# Patameter 'DIB_IMAGE_SIZE' should be specified for Fedora and CentOS
export DIB_IMAGE_SIZE="10"
disk-image-create $fedora_elements_sequence -o $fedora_image_name
# CentOS cloud image:
# - Disable including 'base' element for CentOS
# - Export link and filename for CentOS cloud image to download
export BASE_IMAGE_FILE="CentOS-6.4-cloud-init.qcow2"
export DIB_CLOUD_IMAGES="http://savanna-files.mirantis.com"
# Read Create_CentOS_cloud_image.rst to know how to create CentOS image in qcow2 format
disk-image-create $centos_elements_sequence -n -o $centos_image_name
mv $fedora_image_name.qcow2 ../
mv $ubuntu_image_name.qcow2 ../
mv $centos_image_name.qcow2 ../
popd # out of $TEMP
rm -rf $TEMP

View File

@ -60,7 +60,7 @@ Note: If you are building this image from Ubuntu or Fedora 18 OS host, you shoul
In this command 'DIB_HADOOP_VERSION' parameter is version of hadoop needs to be installed.
You can use 'JAVA_DOWNLOAD_URL' parameter to specify download link for JDK (tarball or bin).
'DIB_IMAGE_SIZE' is parameter that specifes a volume of hard disk of instance. You need to specify it because Fedora doesn't use all available volume.
'DIB_IMAGE_SIZE' is parameter that specifes a volume of hard disk of instance. You need to specify it because Fedora and CentOS don't use all available volume.
If you have already downloaded the jdk package, move it to "elements/hadoop/install.d/" and use its filename as 'JAVA_FILE' parameter.
In order of working EDP components with Savanna DIB images you need pre-installed Oozie libs.
Use OOZIE_DOWNLOAD_URL to specify link to Oozie archive (tar.gz). For example we have built Oozie libs here:

View File

@ -8,14 +8,14 @@ mkdir -p $JAVA_HOME
if [ -n "$JAVA_DOWNLOAD_URL" ]; then
install-packages wget
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" -P $JAVA_HOME $JAVA_DOWNLOAD_URL
JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" -O $JAVA_HOME/$JAVA_FILE $JAVA_DOWNLOAD_URL
if [ $? -eq 0 ]; then
echo "Java downloaded"
else
echo "Error downloading java. Exiting."
exit 1
fi
JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
elif [ -n "$JAVA_FILE" ]; then
install -D -g root -o root -m 0755 $(dirname $0)/$JAVA_FILE $JAVA_HOME
fi

View File

@ -32,10 +32,11 @@ case "$distro" in
augtool -s set /files/etc/ssh/sshd_config/RSAAuthentication yes
augtool -s set /files/etc/ssh/sshd_config/PubkeyAuthentication yes
;;
RedHatEnterpriseServer )
RedHatEnterpriseServer | CentOS )
sed -i 's/ssh_pwauth: 0/ssh_pwauth: 1/' /etc/cloud/cloud.cfg
augtool -s clear /files/etc/sudoers/Defaults[type=':nrpe']/requiretty/negate
augtool -s set /files/etc/ssh/sshd_config/SyslogFacility AUTH
augtool -s set /files/etc/ssh/sshd_config/PubkeyAuthentication yes
;;
* )
echo "Unknown distro: $distro. Exiting."

View File

@ -8,7 +8,7 @@
# https://issues.apache.org/jira/browse/HADOOP-9777
distro=$(lsb_release -is || :)
if [ ! "$distro" == "Fedora" -a ! "$distro" == "Ubuntu" -a ! "$distro" == "RedHatEnterpriseServer" ]; then
if [ ! "$distro" == "Fedora" -a ! "$distro" == "Ubuntu" -a ! "$distro" == "RedHatEnterpriseServer" -a ! "$distro" == "CentOS" ]; then
echo "Unknown distro: $distro. Exiting."
exit 1
fi
@ -23,7 +23,7 @@ case "$distro" in
adduser --ingroup hadoop --disabled-password --gecos GECOS hadoop
adduser hadoop sudo
;;
Fedora | RedHatEnterpriseServer )
Fedora | RedHatEnterpriseServer | CentOS )
adduser -G adm,wheel hadoop
;;
esac
@ -33,7 +33,7 @@ case "$distro" in
Ubuntu )
package="hadoop_$DIB_HADOOP_VERSION-1_x86_64.deb"
;;
Fedora | RedHatEnterpriseServer )
Fedora | RedHatEnterpriseServer | CentOS )
package="hadoop-$DIB_HADOOP_VERSION-1.x86_64.rpm"
;;
esac
@ -49,7 +49,7 @@ case "$distro" in
Ubuntu )
dpkg -i $tmp_dir/$package
;;
Fedora | RedHatEnterpriseServer )
Fedora | RedHatEnterpriseServer | CentOS )
if [ $(lsb_release -rs) = '19' ]; then
rpm -i $tmp_dir/$package --relocate /usr=/usr --replacefiles
else
@ -66,16 +66,17 @@ rm -r $tmp_dir
echo "Pre-configuring Hadoop"
# Find JAVA_HOME...
case "$distro" in
Ubuntu)
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
;;
Fedora | RedHatEnterpriseServer )
JAVA_HOME=$(rpm --eval '%{?java_home}')
;;
esac
JAVA_HOME=$(find $TARGET_ROOT/usr/java/ -maxdepth 1 -name "jdk*")
if [ -z "$JAVA_HOME" ]; then
JAVA_HOME=$(find $TARGET_ROOT/usr/java/ -maxdepth 1 -name "jdk*")
case "$distro" in
Ubuntu)
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
;;
Fedora | RedHatEnterpriseServer | CentOS )
JAVA_HOME=$(rpm --eval '%{?java_home}')
;;
esac
fi
cat >> /home/hadoop/.bashrc <<EOF
@ -87,3 +88,8 @@ sed -i -e "s,export JAVA_HOME=.*,export JAVA_HOME=$JAVA_HOME," \
-e "s,export HADOOP_LOG_DIR=.*,export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER," \
-e "s,export HADOOP_SECURE_DN_LOG_DIR=.*,export HADOOP_SECURE_DN_LOG_DIR=/mnt/log/hadoop/hdfs," \
/etc/hadoop/hadoop-env.sh
if [ "$distro" == "CentOS" ]; then
install -D -g root -o root -m 0755 $(dirname $0)/firstboot /etc/first-boot.d/firstboot
ln -s /etc/first-boot.d/firstboot /etc/rc3.d/S56firstboot
fi

View File

@ -0,0 +1,13 @@
#!/bin/bash
chown -R cloud-user:cloud-user /etc/hadoop
chown -R cloud-user:cloud-user /home/cloud-user
service iptables stop
chkconfig iptables off
chown root:root /mnt
mkdir -p /var/run/hadoop ; chown hadoop:hadoop /var/run/hadoop
mkdir -p /mnt/log/hadoop ; chown hadoop:hadoop /mnt/log/hadoop
rm -f /etc/rc3.d/S56firstboot
rm -f $0

View File

@ -1,10 +1,12 @@
#!/bin/sh
set -e
set -o xtrace
if [ $(lsb_release -is) = 'Fedora' ]; then
install-packages community-mysql community-mysql-libs community-mysql-server mysql-connector-java
mkdir -p /etc/mysql/conf.d
elif [ $(lsb_release -is) = 'RedHatEnterpriseServer' ]; then
elif [ $(lsb_release -is) = 'RedHatEnterpriseServer' -o $(lsb_release -is) = 'CentOS' ]; then
install-packages mysql mysql-libs mysql-server mysql-connector-java
mkdir -p /etc/mysql/conf.d
elif [ $(lsb_release -is) = 'Ubuntu' ]; then
@ -13,4 +15,5 @@ else
echo "Unknown distribution"
exit 1
fi
rm -rf /var/lib/mysql/ib_logfile*

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Disable startup MySQL on boot in Ubuntu
# Service mysqld doesn't start on boot in Fedora
# Service mysqld doesn't start on boot in Fedora and CentOS
# Delete config property 'bind-address' for remote mode (0.0.0.0)
if [ $(lsb_release -is) = 'Ubuntu' ]; then

View File

@ -1,6 +1,7 @@
#!/bin/bash
if [ $(lsb_release -is) = 'Ubuntu' ]; then
sudo service mysql start
elif [ $(lsb_release -is) = 'Fedora' ]; then
elif [ $(lsb_release -is) = 'Fedora' -o $(lsb_release -is) = 'CentOS' -o $(lsb_release -is) = 'RedHatEnterpriseServer' ]; then
sudo service mysqld start
fi

View File

@ -0,0 +1,3 @@
#!/bin/bash
install-packages redhat-lsb