Difference between revisions of "Aws-create"
From Bashlinux
Line 171: | Line 171: | ||
</nowiki></pre> |
</nowiki></pre> |
||
− | # Install the rest of the packages using the DVD as repository: |
+ | # Install the rest of the packages using the DVD as repository, try to get done by parts, in case something goes wrong: |
<pre><nowiki> |
<pre><nowiki> |
||
yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall mysql editors system-tools text-internet gnome-desktop |
yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall mysql editors system-tools text-internet gnome-desktop |
||
yum --installroot=/mnt/EC2-FS clean all |
yum --installroot=/mnt/EC2-FS clean all |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall ftp-server |
+ | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall ftp-server network-server |
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall network-server |
||
yum --installroot=/mnt/EC2-FS clean all |
yum --installroot=/mnt/EC2-FS clean all |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall java |
+ | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall java java-development base-x graphics web-server |
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall java-development |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall base-x |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall graphics |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall web-server |
||
yum --installroot=/mnt/EC2-FS clean all |
yum --installroot=/mnt/EC2-FS clean all |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall smb-server |
+ | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall smb-server mail-server server-cfg sound-and-video |
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall mail-server |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall server-cfg |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall sound-and-video |
||
yum --installroot=/mnt/EC2-FS clean all |
yum --installroot=/mnt/EC2-FS clean all |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall admin-tools |
+ | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall admin-tools development-tools graphical-internet |
+ | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS -y install mod_auth_mysql php-mysql vim-X11 festival createrepo audit mrtg amanda-client iptraf lynx kexec-tools device-mapper-multipath vnc-server xorg-x11-server-Xnest xorg-x11-server-Xvfb libsane-hpaio tomcat5-admin-webapps php-pear tomcat5-webapps mod_auth_mysql tomcat5 dnsmasq ruby ruby-rdoc ruby-devel ruby-ri ruby-docs mysql-devel php-mysql php-bcmath php-gd php-mcrypt php-soap php-xml imake memtest86+ compat-libstdc++-33 compat-libstdc++-296 yum-cron libmcrypt |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall development-tools |
||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall graphical-internet |
||
− | |||
− | yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS -y install mod_auth_mysql php-mysql vim-X11 festival createrepo audit mrtg amanda-client iptraf lynx kexec-tools device-mapper-multipath vnc-server xorg-x11-server-Xnest xorg-x11-server-Xvfb libsane-hpaio tomcat5-admin-webapps php-pear tomcat5-webapps mod_auth_mysql tomcat5 dnsmasq ruby ruby-rdoc ruby-devel ruby-ri ruby-docs mysql-devel php-mysql php-bcmath php-gd php-mcrypt php-soap php-xml imake memtest86+ compat-libstdc++-33 compat-libstdc++-296 yum-cron libmcrypt |
||
</nowiki></pre> |
</nowiki></pre> |
||
− | Due compatibility issues with |
+ | Due compatibility issues with `glib` package, `nautilus-sendto` package should be excluded. |
+ | * Restore yum repositories |
||
− | <!-- # Install uWink packages using uWink repository --> |
||
+ | |||
− | {noformat} |
||
+ | <pre><nowiki> |
||
− | yum -c /root/tmp-yum/uWink-Base.repo --installroot=/mnt/EC2-FS2 -y install uwink-puppet uwink-system uwink-other uwink-api uwink-menu uwink-volante |
||
+ | # mv /root/tmp-yum/* /etc/yum.repos.d/ |
||
− | {noformat} |
||
+ | </nowiki></pre> |
||
− | |||
− | * Restore yum repositories* |
||
− | {noformat} |
||
− | <!-- # mv /root/tmp-yum/* /etc/yum.repos.d/ --> |
||
− | {noformat} |
||
− | h2. Configure the Operating System |
||
+ | == Configure the Operating System == |
||
After successfully installing the the base operating system, you mus configure the networking and hard drives to work in the Amazon EC2 environment. |
After successfully installing the the base operating system, you mus configure the networking and hard drives to work in the Amazon EC2 environment. |
||
− | * Configure the operating system |
+ | * Configure the operating system |
− | + | * Create _/mnt/EC2-FS/etc/sysconfig/network-scripts/ifcfg-eth0_ and make sure it contains at least the following information: |
|
+ | |||
− | {noformat} |
||
+ | <pre><nowiki> |
||
− | DEVICE=eth0 |
||
+ | DEVICE=eth0 |
||
− | BOOTPROTO=dhcp |
||
+ | BOOTPROTO=dhcp |
||
− | ONBOOT=yes |
||
+ | ONBOOT=yes |
||
− | TYPE=Ethernet |
||
+ | TYPE=Ethernet |
||
− | USERCTL=yes |
||
− | + | USERCTL=yes |
|
+ | PEERDNS=yes |
||
− | IPV6INIT=no |
||
+ | IPV6INIT=no |
||
− | {noformat} |
||
+ | </nowiki></pre> |
||
− | {note:title=Note}The Amazon EC2 DHCP server ignores hostname requests. If you set _DHCP_HOSTNAME_, the local hostname will be set on the instance but not externally. Additionally, the local hostname will be the same for all instances of the AMI, which might be confusing. |
||
− | {note} |
||
− | <!-- # Ensure that networking starts by making sure the following line appears in the _/mnt/EC2-FS/etc/sysconfig/network_ file: --> |
||
− | {noformat} |
||
− | NETWORKING=yes |
||
− | {noformat} |
||
− | <!-- # Create _/etc/hosts_ file with default configuration --> |
||
− | {noformat} |
||
− | <!-- # echo "127.0.0.1 localhost.localdomain localhost" > /mnt/EC2-FS/etc/hosts --> |
||
− | {noformat} |
||
− | <!-- # Ensure that SELinux is disabled --> |
||
− | {noformat} |
||
− | <!-- # perl -pi -e 's/SELINUX=enforcing/SELINUX=disabled/' /mnt/EC2-FS/etc/selinux/config --> |
||
− | {noformat} |
||
− | <!-- # Ensure that local disk storage on _/dev/sda2_ and swap space on _/dev/sda3_ are mounted at system startup by adding the following lines to _/mnt/EC2-FS/etc/fstab_: --> |
||
− | {noformat} |
||
− | /dev/sda2 /mnt ext3 defaults 0 0 |
||
− | /dev/sda3 swap swap defaults 0 0 |
||
− | {noformat} |
||
− | {note:title=Note}The _/dev/sda2_ and _/dev/sda3_ storage locations only apply to small instances. For more information on instance storage, see [http://docs.amazonwebservices.com/AWSEC2/2008-02-01/DeveloperGuide/instance-storage.html] |
||
− | {note} |
||
− | <!-- # Change base root to _/mnt/EC2-FS{_}{noformat} --> |
||
− | <!-- # chroot /mnt/EC2-FS --> |
||
− | {noformat} |
||
− | <!-- # Make sure all of your required services start at system startup by allocating them appropriate system run levels: --> |
||
− | {noformat} |
||
− | <!-- # chkconfig --level 2345 sshd on --> |
||
− | <!-- # chkconfig --level 345 monit --> |
||
− | {noformat} |
||
− | <!-- # In order to setup MySQL first startup the network, then fire up MySQL --> |
||
− | {noformat} |
||
− | <!-- # /etc/init.d/network start --> |
||
− | <!-- # /etc/init.d/mysqld start --> |
||
− | {noformat} |
||
− | <!-- # Run post-install scripts, create a file on _/root/ks-post.sh_ and add the following commands: --> |
||
− | {code:java|bgColor=#FFFFCE} |
||
− | <!-- #!/bin/bash --> |
||
+ | |||
− | <!-- # Setup user group and passwords --> |
||
+ | <pre><nowiki>#!wiki note |
||
− | cat >> /etc/passwd << 'EOF' |
||
+ | '''Note''' |
||
− | brent:x:501:501:brent:/home/brent:/bin/bash |
||
+ | The Amazon EC2 DHCP server ignores hostname requests. If you set _DHCP_HOSTNAME_, the local hostname will be set on the instance but not externally. Additionally, the local hostname will be the same for all instances of the AMI, which might be confusing. |
||
− | rizwank:x:502:502:rizwank:/home/rizwank:/bin/bash |
||
+ | </nowiki></pre> |
||
− | steve:x:503:503:steve:/home/steve:/bin/bash |
||
− | manuel:x:504:504::/home/manuel:/bin/bash |
||
− | EOF |
||
+ | # Ensure that networking starts by making sure the following line appears in the `/mnt/EC2-FS/etc/sysconfig/network` file: |
||
− | cat >> /etc/shadow << 'EOF' |
||
+ | |||
− | brent:$1$5jZxoSH.$2Iq7IKFN3J3Ub5uidQ2Oz0:13929:0:99999:7::: |
||
+ | <pre><nowiki> |
||
− | rizwank:$1$79SO1kRt$VLH/kiLyhrN9JuGDq7bAJ/:13929:0:99999:7::: |
||
+ | NETWORKING=yes |
||
− | steve:$1$.XHDDPhz$4J1LkjQoqDeLk1grLMlSN.:13929:0:99999:7::: |
||
+ | </nowiki></pre> |
||
− | manuel:$1$5WLy6Uzj$YmXXpbAKfCN2Q3SSSa3F91:14043:0:99999:7::: |
||
− | EOF |
||
+ | # Create `/etc/hosts` file with default configuration |
||
− | cat >> /etc/group << 'EOF' |
||
+ | |||
− | brent:x:501: |
||
+ | <pre><nowiki> |
||
− | rizwank:x:502: |
||
+ | # echo "127.0.0.1 localhost.localdomain localhost" > /mnt/EC2-FS/etc/hosts |
||
− | steve:x:503: |
||
+ | </nowiki></pre> |
||
− | manuel:x:504: |
||
− | EOF |
||
+ | # Ensure that SELinux is disabled |
||
− | cat >> /etc/gshadow << 'EOF' |
||
+ | |||
− | brent:!!:: |
||
+ | <pre><nowiki> |
||
− | rizwank:!!:: |
||
+ | # perl -pi -e 's/SELINUX=enforcing/SELINUX=disabled/' /mnt/EC2-FS/etc/selinux/config |
||
− | steve:!!:: |
||
+ | </nowiki></pre> |
||
− | manuel:!:: |
||
− | EOF |
||
+ | # Ensure that local disk storage on `/dev/sda2` and swap space on `/dev/sda3` are mounted at system startup by adding the following lines to `/mnt/EC2-FS/etc/fstab`: |
||
− | <!-- # Home dirs --> |
||
+ | |||
− | mkdir -p /home/brent |
||
+ | <pre><nowiki> |
||
− | mkdir -p /home/rizwank |
||
+ | /dev/sda2 /mnt ext3 defaults 0 0 |
||
− | mkdir -p /home/steve |
||
+ | /dev/sda3 swap swap defaults 0 0 |
||
− | mkdir -p /home/manuel |
||
+ | </nowiki></pre> |
||
− | chown -R 501:501 /home/brent |
||
− | chown -R 502:502 /home/rizwank |
||
− | chown -R 503:503 /home/steve |
||
− | chown -R 504:504 /home/manuel |
||
+ | |||
− | <!-- # Add users to sudoers --> |
||
+ | <pre><nowiki>#!wiki note |
||
− | cat >> /etc/sudoers << 'EOF' |
||
+ | '''Note''' |
||
− | brent ALL=(ALL) ALL |
||
+ | The `/dev/sda2` and `/dev/sda3` storage locations only apply to small instances. For more information on instance storage, see [[http://docs.amazonwebservices.com/AWSEC2/2008-02-01/DeveloperGuide/instance-storage.html]] |
||
− | rizwank ALL=(ALL) ALL |
||
+ | </nowiki></pre> |
||
− | steve ALL=(ALL) ALL |
||
− | manuel ALL=(ALL) ALL |
||
− | EOF |
||
+ | # Change base root to `/mnt/EC2-FS` |
||
− | JAVA_HOME=/usr/java/jre1.6.0_05 |
||
+ | |||
− | /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 100 \ |
||
+ | <pre><nowiki> |
||
− | --slave /usr/bin/rmiregistry rmiregistry ${JAVA_HOME}/bin/rmiregistry \ |
||
+ | # chroot /mnt/EC2-FS |
||
− | --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 ${JAVA_HOME}/man/man1/rmiregistry.1 \ |
||
+ | </nowiki></pre> |
||
− | --slave /usr/share/man/man1/rmiregistry.1.gz rmiregistry.1.gz ${JAVA_HOME}/man/man1/rmiregistry.1.gz |
||
− | alternatives --set java ${JAVA_HOME}/bin/java |
||
+ | # Make sure all of your required services start at system startup by allocating them appropriate system run levels: |
||
− | <!-- ##################################### --> |
||
+ | |||
+ | <pre><nowiki> |
||
+ | # chkconfig --level 2345 sshd on |
||
+ | # chkconfig --level 345 monit |
||
+ | </nowiki></pre> |
||
+ | # In order to setup MySQL first startup the network, then fire up MySQL |
||
− | cat > /root/configure.sh << 'EOF' |
||
+ | |||
− | <!-- #!/bin/sh --> |
||
+ | <pre><nowiki> |
||
− | echo "Setting server up as node: $1" |
||
+ | # /etc/init.d/network start |
||
− | hostname $1 |
||
+ | # /etc/init.d/mysqld start |
||
− | echo "export NODE=$1" >> /etc/profile |
||
+ | </nowiki></pre> |
||
− | IPADDR=`ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | tr -d "addr:"` |
||
− | echo "$IPADDR $1.uwink.com $1" >> /etc/hosts |
||
− | echo "$IPADDR local.uwink.com local" >> /etc/hosts |
||
− | echo "$1" > /etc/hostname |
||
− | <!-- #TODO HOSTNAME might not be in sysconfig/network --> |
||
− | perl -pi -e 's/HOSTNAME=.*/HOSTNAME=$1/g' /etc/sysconfig/network |
||
− | EOF |
||
− | chmod +x /root/configure.sh |
||
+ | # Create your user account: |
||
− | <!-- ##################################### --> |
||
+ | |||
− | <!-- # Database settings --> |
||
+ | <pre><nowiki> |
||
− | echo "Setting up database" |
||
+ | # useradd myuser |
||
+ | # passwd myuser |
||
+ | </nowiki></pre> |
||
+ | # Stop services and umount the image: |
||
− | mysqladmin create bistro |
||
+ | |||
− | mysql -e "GRANT ALL ON bistro.* TO 'root'@'localhost' IDENTIFIED BY 'root'" |
||
+ | <pre><nowiki> |
||
− | mysql -u root -proot -e "GRANT SELECT,UPDATE,INSERT ON bistro.* TO 'etluser'@'dsl093-116-242.lax1.dsl.speakeasy.net' IDENTIFIED BY '34td4t4' REQUIRE SSL" |
||
+ | # /etc/init.d/mysqld stop |
||
− | mysql -u root -proot -e "GRANT SELECT,UPDATE,INSERT ON bistro.* TO 'etluser'@'eotu.uwink.com' IDENTIFIED BY '34td4t4' REQUIRE SSL" |
||
+ | # /etc/init.d/network stop |
||
− | mysql -u root -proot -e "GRANT SELECT,UPDATE,INSERT ON bistro.* TO etluser@'10.%' identified by '34td4t4' REQUIRE SSL" |
||
+ | # umount /mnt/EC2-FS/proc |
||
− | mysql -u root -proot -e "GRANT ALL ON bistro.* TO 'root'@'10.%' IDENTIFIED BY '34td4t4'" |
||
+ | # umount -d /mnt/EC2-FS |
||
− | mysql -u root -proot -e "GRANT ALL ON bistro.* TO 'root'@'local.uwink.com' IDENTIFIED BY '34td4t4'" |
||
+ | </nowiki></pre> |
||
− | mysqladmin --user=root --password=root flush-privileges |
||
− | |||
− | <!-- # Media directory settings --> |
||
− | mkdir -p /opt/uwink/media |
||
− | mkdir -p /opt/uwink/apps |
||
− | mkdir -p /opt/uwink/archive |
||
− | mkdir -p /opt/uwink/share/customerphotos |
||
− | mkdir -p /var/log/uwink |
||
− | ln -s /opt/uwink/media /var/www/html/media |
||
− | ln -s /opt/uwink/apps /var/www/html/apps |
||
− | chown bistro /opt/uwink/media |
||
− | |||
− | <!-- # php.ini memory_limit to 128 --> |
||
− | perl -pi -e 's/memory_limit = \d*M/memory_limit = 128M/' /etc/php.ini |
||
− | |||
− | <!-- #Set UTF-8 as the default encoding --> |
||
− | perl -pi -e 's/;mbstring.internal_encoding = EUC-JP/mbstring.internal_encoding = UTF-8/' /etc/php.ini |
||
− | |||
− | <!-- # OFF for test network, on for restaurants --> |
||
− | <!-- #TODO remove this ultimately --> |
||
− | chkconfig --level 345 actionqueue off |
||
− | service actionqueue stop |
||
− | |||
− | <!-- #set evil symlinks for volante --> |
||
− | <!-- #ln -s /usr/lib/libstdc++-libc6.2-2.so.3 /usr/lib/libstdc++-libc6.1-1.so.2 --> |
||
− | |||
− | <!-- #configure vncserver... TODO shouldn't be root --> |
||
− | perl -pi -e 's/# VNCSERVERS="2:myusername"/VNCSERVERS="1:root"/' /etc/sysconfig/vncservers |
||
− | |||
− | <!-- #add our favicon --> |
||
− | wget http://www.uwink.com/images/favicon.ico -O /var/www/html/favicon.ico |
||
− | |||
− | <!-- # Disable asking to accept ssh key --> |
||
− | echo -e "\tStrictHostKeyChecking no" >> /etc/ssh/ssh_config |
||
− | |||
− | <!-- #Setup emailing to admin --> |
||
− | perl -pi -e "s/^#root:\s*marc/root:\t\tadmin\@uwink.com/" /etc/aliases |
||
− | newaliases |
||
− | |||
− | <!-- #TODO activate monit in proper run levels and turn on --> |
||
− | <!-- #chkconfig --level 345 monit on --> |
||
− | <!-- #service monit start --> |
||
− | |||
− | <!-- #until puppet goes into KS, allowing updates to happen is dangerous --> |
||
− | rm /etc/cron.daily/yum.cron /etc/cron.weekly/yum.cron |
||
− | |||
− | <!-- #prep puppet config. Doesn't handle hostname yet --> |
||
− | perl -pi -e 's/#PUPPET_SERVER=puppet/PUPPET_SERVER=puppet.uwink.com/' /etc/sysconfig/puppet |
||
− | perl -pi -e 's/#PUPPET_LOG/PUPPET_LOG/' /etc/sysconfig/puppet |
||
− | {code} |
||
− | <!-- # Stop services and umount the image: --> |
||
− | {noformat} |
||
− | <!-- # /etc/init.d/mysqld stop --> |
||
− | <!-- # /etc/init.d/network stop --> |
||
− | <!-- # umount /mnt/EC2-FS/proc --> |
||
− | <!-- # umount -d /mnt/EC2-FS --> |
||
− | {noformat} |
Revision as of 02:20, 18 June 2010
Creating a CentOS AMI through a Loopback File
The image created here is based on CentOS Linux.
Create a File to Host the CentOS AMI
A base CentOS Linux installation requires about 1.2 GB, but custom installation for a server environment might require up to 3.0 GB.
- Create a location to place the CentOS AMI
# mkdir -p /usr/local/src/EC2
- Create a file to host the CentOS AMI
# dd if=/dev/zero of=/usr/local/src/EC2/bashlinux-server.fs bs=1M count=3072 3072+0 records in 3072+0 records out 3221225472 bytes (3.2 GB) copied, 118.687 seconds, 27.1 MB/s
Create a Root File System Inside the File
Create an ext3 file system
mke2fs -F -j /usr/local/src/EC2/bashlinux-server.fs mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 393216 inodes, 786432 blocks 39321 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=805306368 24 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Mount the File through Loopback
- Create a mount point in the file system where the image will be attached:
# mkdir -p /mnt/EC2-FS
- Mount the file system image:
mount -o loop /usr/local/src/EC2/bashlinux-server.fs /mnt/EC2-FS/
Prepare for the Installation
- Create a `/dev` directory and populate it with a minimal set of devices. You can ignore the errors in the output
# mkdir -p /mnt/EC2-FS/dev # MAKEDEV -d /mnt/EC2-FS/dev -x console # MAKEDEV -d /mnt/EC2-FS/dev -x null # MAKEDEV -d /mnt/EC2-FS/dev -x zero
- Create the `/etc` directory
# mkdir -p /mnt/EC2-FS/etc
- Create the `fstab` file within the `/mnt/EC2-FS/etc` directory and add the following:
/dev/sda1 / ext3 defaults 1 1 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0
- Create a temporary yum configuration file `/usr/local/src/EC2/yum-ec2.conf`
[base] name=CentOS-5.1 - Base mirrorlist=http://mirrorlist.centos.org/?release=5.1&arch=i386&repo=os baseurl=http://mirror.centos.org/centos/5.1/os/i386/ gpgcheck=0 [updates] name=CentOS-5.1 - Updates mirrorlist=http://mirrorlist.centos.org/?release=5.1&arch=i386&repo=updates baseurl=http://mirror.centos.org/centos/5.1/updates/i386/ gpgcheck=0
This ensures all the required basic packages and utilities are installed. This file can be located on image location `/usr/local/src/EC2`, and is used only during installation
- Hide system repositories for AMI installation
# mkdir /root/tmp-yum # mv /etc/yum.respos.d/* /root/tmp-yum/
This avoids the use of system repositories that requires a specific value for `$releasever` and `$basearch`, also avoids the duplicated repository error messages.
- Mount the `proc` filesystem manually
# mkdir -p /mnt/EC2-FS/proc # mount -t proc none /mnt/EC2-FS/proc
- Create log folder
# mkdir -p /mnt/EC2-FS/var/log
Install the Operating System
- Install the Base operating system
# yum -c /usr/local/src/EC2/yum-ec2.conf --installroot=/mnt/EC2-FS --exclude=sysreport -y groupinstall Core Base Core Base Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Setting up Group Process Setting up repositories extras 100% |=========================| 1.1 kB 00:00 updates 100% |=========================| 951 B 00:00 base 100% |=========================| 1.1 kB 00:00 addons 100% |=========================| 951 B 00:00 yumgroups.xml 100% |=========================| 9.7 kB 00:00 comps.xml 100% |=========================| 912 kB 00:05 Setting up repositories Reading repository metadata in from local files primary.xml.gz 113 kB 00:02 ################################################## 421/421 primary.xml.gz 100% |=========================| 278 kB 00:01 ################################################## 502/502 primary.xml.gz 100% |=========================| 834 kB 00:06 ################################################## 2400/2400 primary.xml.gz 100% |=========================| 157 B 00:00 Excluding Packages in global exclude list ... Complete!
Due compatibility errors with `sos` package, `sysreport` package should be excluded.
- Install the packages and files needed for a server
To do a fast installation try to use the "CentOS 5.1 Final" DVD and the CentOS-Media repository locate in the temporary location we set at `/root/tmp-yum`. To have done this do as follows:
- Insert "CentOS 5.1 Final" DVD
- If the sytem didn't mount automatically the DVD under `/media` folder, then run the command:
# mount /dev/cdrom /media/CentOS_5.1_Final
- Install the rest of the packages using the DVD as repository, try to get done by parts, in case something goes wrong:
yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall mysql editors system-tools text-internet gnome-desktop yum --installroot=/mnt/EC2-FS clean all yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall ftp-server network-server yum --installroot=/mnt/EC2-FS clean all yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall java java-development base-x graphics web-server yum --installroot=/mnt/EC2-FS clean all yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall smb-server mail-server server-cfg sound-and-video yum --installroot=/mnt/EC2-FS clean all yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS --exclude=sysreport --exclude=nautilus-sendto -y groupinstall admin-tools development-tools graphical-internet yum -c /root/tmp-yum/CentOS-Media.repo --installroot=/mnt/EC2-FS -y install mod_auth_mysql php-mysql vim-X11 festival createrepo audit mrtg amanda-client iptraf lynx kexec-tools device-mapper-multipath vnc-server xorg-x11-server-Xnest xorg-x11-server-Xvfb libsane-hpaio tomcat5-admin-webapps php-pear tomcat5-webapps mod_auth_mysql tomcat5 dnsmasq ruby ruby-rdoc ruby-devel ruby-ri ruby-docs mysql-devel php-mysql php-bcmath php-gd php-mcrypt php-soap php-xml imake memtest86+ compat-libstdc++-33 compat-libstdc++-296 yum-cron libmcrypt
Due compatibility issues with `glib` package, `nautilus-sendto` package should be excluded.
- Restore yum repositories
# mv /root/tmp-yum/* /etc/yum.repos.d/
== Configure the Operating System ==
After successfully installing the the base operating system, you mus configure the networking and hard drives to work in the Amazon EC2 environment.
- Configure the operating system
- Create _/mnt/EC2-FS/etc/sysconfig/network-scripts/ifcfg-eth0_ and make sure it contains at least the following information:
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes TYPE=Ethernet USERCTL=yes PEERDNS=yes IPV6INIT=no
#!wiki note '''Note''' The Amazon EC2 DHCP server ignores hostname requests. If you set _DHCP_HOSTNAME_, the local hostname will be set on the instance but not externally. Additionally, the local hostname will be the same for all instances of the AMI, which might be confusing.
- Ensure that networking starts by making sure the following line appears in the `/mnt/EC2-FS/etc/sysconfig/network` file:
NETWORKING=yes
- Create `/etc/hosts` file with default configuration
# echo "127.0.0.1 localhost.localdomain localhost" > /mnt/EC2-FS/etc/hosts
- Ensure that SELinux is disabled
# perl -pi -e 's/SELINUX=enforcing/SELINUX=disabled/' /mnt/EC2-FS/etc/selinux/config
- Ensure that local disk storage on `/dev/sda2` and swap space on `/dev/sda3` are mounted at system startup by adding the following lines to `/mnt/EC2-FS/etc/fstab`:
/dev/sda2 /mnt ext3 defaults 0 0 /dev/sda3 swap swap defaults 0 0
#!wiki note '''Note''' The `/dev/sda2` and `/dev/sda3` storage locations only apply to small instances. For more information on instance storage, see [[http://docs.amazonwebservices.com/AWSEC2/2008-02-01/DeveloperGuide/instance-storage.html]]
- Change base root to `/mnt/EC2-FS`
# chroot /mnt/EC2-FS
- Make sure all of your required services start at system startup by allocating them appropriate system run levels:
# chkconfig --level 2345 sshd on # chkconfig --level 345 monit
- In order to setup MySQL first startup the network, then fire up MySQL
# /etc/init.d/network start # /etc/init.d/mysqld start
- Create your user account:
# useradd myuser # passwd myuser
- Stop services and umount the image:
# /etc/init.d/mysqld stop # /etc/init.d/network stop # umount /mnt/EC2-FS/proc # umount -d /mnt/EC2-FS