מדריכים בנושאי גנו/לינוקס, תוכנה חופשית וקוד-פתוח
Create and Move an Amazon EC2 AMI from us to eu region
How to create an Amazon EC2 image from a running instance in the U.S., and make it available in the E.U. region.
 
So...
 
Who are you? You are running a VPS server (AMI, image, running as an instance) in the US location, of the Amazon EC2 service. And you want to perform a simple task: have the instance run in the EU (European Union) location.
 
Why are you here? Because this 'simple task' can drive a normal person insane. There are bits of answers that are scattered all over the Internet, and you can't find your head from your tail in all that noise.
 
So, this user guide/ manual gives the needed stages for transferring a web server from the Amazon u.s. servers to the e.u. servers.

0. Prerequisites and tools that are good to have

- Some knowledge in managing a GNU/Linux server.

- A working instance of GNU/Linux, on which you will be performing all the work.

- The ElasticFox addon for Firefox.

- The S3 Organizer addon for Firefox.

- The Amazon API tools. You CAN use only the API tools, without the Firefox extensions, but why would you want to do that?


1. Create buckets in the USA and in Europe :-)

The buckets are folders in the Amazon S3 service. Yes, the guys and girls at Amazon sure don't like making things simple for you.

 

The easiest way to manage buckets and their content, is with the Firefox add-on called: S3 Organizer.


You'll need 2 'keys', that can be found in the AWS website, under 'Your account > Access identifiers'. Copy the Access Key and the Secret Key to the preferences, and that's that.


Then, when you browse the right pane, you can create a folder, which is actually a bucket. When you create the folder, make sure that you place the bucket in Europe, if this is your intention. We will have 2 buckets: eu-bucket and us-bucket

 

 

2. Deploy the API tools

Download the Amazon API tools. I suggest you deploy them in your home folder.

 

For example:

tar -C ~/ -zxvf API-tools.tar.gz

 

 

3. Prepare the environment

You need to have 2 files on your server: a private key (the file that starts with pk), and a certificate (the file that starts with cert). The private key can only be issued once! So when you create your certificate (only 1 per account), make sure that you save the PK file in a safe place. The cert file can be re-downloaded from the above-mentioned 'Access Identifiers' page.


If you want to re-create other AMIs later on, then you'd probably want to add the following lines to your ~/.bashrc file, instead of doing an EXPORT to each one of them every time:

export EC2_HOME=/root/ec2/ec2-api-tools-1.3-34128

export PATH=$PATH:$EC2_HOME/bin

export EC2_PRIVATE_KEY=/mnt/pk-ALONGNAMEWITHNOMEANING.pem

export EC2_CERT=/mnt/cert-ANEVENLONGERNAMEWITHNOMEANINGTOO.pem


Important notices:

- The AMI size is limited to 10GB. Bare it in mind, and use EBS volumes for high-storage mounting points, such as /home and others. Don't be tempted to use the default /mnt that is given, since it can't be duplicated like an EBS can.


- In RedHat/ CentOS/ Fedora distributions, edit the following file, and make sure you remark the line that starts with HWADDR since this line attaches the eth0 device to a specific MAC address. EC2 gives a new MAC address to each newly deployed AMI. This is the file:

/etc/sysconfig/network-scripts/ifcfg-eth0

 

 

4. Create (bundle) the AMI

The following ec2-bundle-vol command will create us the required files for a new AMI:


ec2-bundle-vol -d /mnt -k $EC2_PRIVATE_KEY -c $EC2_CERT -u xxxx-xxxx-xxxx -r i386 -p ourAMI


The different options are:

-d is the location in which the AMI will be created

-u is the Amazon account number that you see on the top-right corner after you log-in to the AWS site.

-r is your architecture

-p is the name of the AMI. This has to be unique.

-j is not an option, but it's nice to see that you're reading... Lighten up, you're almost there!

 


5. Upload the AMI to the US bucket

Use the following command ec2-upload-bundle:

ec2-upload-bundle -b us-bucket -m /mnt/ourAMI.manifest.xml -a ACCESS-KEY -s SECRET-KEY


Make sure you replace the access and secret keys with your own. It's in section 1...

 


6. Copy (migrate) it to the EU bucket

The action of copying an AMI between regions, is called migrating. Just like a migraine: long and painful. Just kidding! You just need to launch the ec2-migrate-image command, and wait for the files to be copied:

ec2-migrate-image ec2-migrate-image -o ACCESS-KEY -w SECRET-KEY --bucket us-bucket --destination-bucket eu-bucket --manifest ourAMI.manifest.xml  --location EU

 


7. Publish it as a private AMI in the EU

The ec2-register command will register your AMI as a private image.

ec2-register eu-bucket/ourAMI.manifest.xml --region eu-west-1


If you want to see the available regions, then run the command:

ec2-describe-regions


You can now activate (launch) your new AMI from the list of available images.

 

One extremely important notice: do not halt, shutdown or terminate your original AMI, until you're 100% sure that the newly copied AMI is working flawlessly. Once an AMI is terminated (halt and shutdown terminate it as well...), it can not be recovered. It is lost for ever and ever. No regrets.

 

Having said that...

 

That's it. Congratulations! Relax, and enjoy the extra-super-ordinaire song Yeah Yeah by Salsedo. You've earned it.

 

Dotan

 
גיבוי מקומי בעזרת rsync

הגיבוי הבא, הוא גיבוי מקומי באמצעות תוכנת rsync שמותקנת על כל מערכות היוניקס/לינוקס. גם אם היא איננה מותקנת, הרי שניתן להתקין אותה בקלות רבה. ישנם ברחבי הרשת מדריכים רבים על גיבוי דרך הרשת המקומית, דרך האינטרנט, במגוון פרוטוקולים, ואני מניח שניתן להתאים את קובץ הגיבוי כך שיעבוד גם בדרכים האחרות. להסבר מעולה על דרך העבודה של rsync ועל היכולות השונות שלו.

אחד הדברים היפים בגיבוי הזה, ואולי הדבר היפה ביותר בו, הוא העובדה שהגיבויים המתגלגלים מתבצעים באמצעות יצירת קישורים קשיחים (Hard Links) בין הגיבויים. המשמעות היא, שאם קובץ מסויים לא השתנה מאז הגיבוי האחרון, אז הגיבויים ישתמשו באותו עותק פיזי של הקובץ, וכך הוא תופס מקום רק פעם אחת. למעשה, מדובר רק בהוספת עוד רשומה ל- inode של הקובץ במערכת הקבצים. חשוב לציין בהקשר זה, שבמידה ואמצעי הגיבוי (בדרך כלל הדיסק הקשיח) ייפגם בנקודה מסויימת המאכלסת קובץ משותף שכזה, זה יגרום לפגיעה בקובץ בכל הגיבויים שמשתמשים בו. מצד שני, ברגע שיש בעיה פיזית באמצעי הגיבוי, אז הנתונים של הקובץ משתנים, והגיבוי הבא כבר לא ישתמש בו. לשיקולכם.

הקובץ הבא, יוצר גיבוי של תוכן הספריות שקבועות בשורה SOURCES אל הספריה שקבועה בשורה TARGET. מטרת המספר שבשורה ROTATIONS היא להגדיר את מספר העותקים שאנחנו מבקשים לשמור מהגיבוי. בנוסף, בשורה EXCLUDE_FILE מוגדר קובץ, אשר בו תופיע רשימה של ספריות שאותן אין לגבות.

למשל, אם נרצה לגבות את מחיצת הבית של משתמש בשם rani ואת ספריית ההגדרות של המחשב, אבל בלי לגבות את מחיצת האשפה של rani, ושלא יהיו יותר מ- 2 עותקים של גיבויים אלו יהיו המשתנים:

SOURCES="/home/rani /etc"

TARGET="/home/backups"

ROTATIONS=2 

EXCLUDE_FILE="/home/backups/exclude.txt"

כאשר התוכן של הקובץ ששמו exclude.txt יהיה:

 /home/rani/.Trash

חשוב לציין, שהקוד המקורי מגיע מכתובת זו, והדבר היחיד ששיניתי זה להחליף בשורה הראשונה את sh אל bash, וזאת בגלל שהפקודה let אינה נמצאת במעטפת sh. ניתן לראות טבלה של השוואה בין פקודות מעטפת, בקישור זה.


#!/bin/bash
# Author: Brice Burgess - כתובת דוא"ל זו מוגנת מפני spambots, יש לאפשר JavaScript על-מנת לראות את הכתובת
# multi_backup.sh -- backup to a local drive using rsync.
#         Uses hard-link rotation to keep multiple backups.

# Directories to backup. Seperate with a space. Exclude trailing slash!
SOURCES="/home/wendy /home/daisy /var/mail"

# Directory to backup to. This is where your backup(s) will be stored. No spaces in names!
# :: NOTICE :: -> Make sure this directory is empty or contains ONLY backups created by
#                            this script and NOTHING else. Exclude trailing slash!
TARGET="/mnt/usb-harddrive/backup"

# Set the number of backups to keep (greater than 1). Ensure you have adaquate space.
ROTATIONS=3

# Your EXCLUDE_FILE tells rsync what NOT to backup. Leave it unchanged if you want
# to backup all files in your SOURCES. If performing a FULL SYSTEM BACKUP, ie.
# Your SOURCES is set to "/", you will need to make use of EXCLUDE_FILE.
# The file should contain directories and filenames, one per line.
# A good example would be:
# /proc
# /tmp
# *.SOME_KIND_OF_FILE
EXCLUDE_FILE="/path/to/your/exclude_file.txt"

# Comment out the following line to disable verbose output
VERBOSE="-v"

#######################################
########DO_NOT_EDIT_BELOW_THIS_POINT#########
#######################################

# Set name (date) of backup.
BACKUP_DATE="`date +%F_%H-%M`"

if [ ! -x $TARGET ]; then
  echo "Backup target does not exist or you don't have permission!"
  echo "Exiting..."
  exit 2
fi

if [ ! $ROTATIONS -gt 1 ]; then
  echo "You must set ROTATIONS to a number greater than 1!"
  echo "Exiting..."
  exit 2
fi

#### BEGIN ROTATION SECTION ####

BACKUP_NUMBER=1
# incrementor used to determine current number of backups

# list all backups in reverse (newest first) order, set name of oldest backup to $backup
# if the retention number has been reached.
for backup in `ls -dXr $TARGET/*/`; do
    if [ $BACKUP_NUMBER -eq 1 ]; then
        NEWEST_BACKUP="$backup"
    fi
   
    if [ $BACKUP_NUMBER -eq $ROTATIONS ]; then
        OLDEST_BACKUP="$backup"
        break
    fi
   
    let "BACKUP_NUMBER=$BACKUP_NUMBER+1"
done

# Check if $OLDEST_BACKUP has been found. If so, rotate. If not, create new directory for this backup.
if [ $OLDEST_BACKUP ]; then
  # Set oldest backup to current one
  mv $OLDEST_BACKUP $TARGET/$BACKUP_DATE
else
    mkdir $TARGET/$BACKUP_DATE
fi

# Update current backup using hard links from the most recent backup
if [ $NEWEST_BACKUP ]; then
  cp -al $NEWEST_BACKUP. $TARGET/$BACKUP_DATE
fi
#### END ROTATION SECTION ####
 

# Check to see if rotation section created backup destination directory
if [ ! -d $TARGET/$BACKUP_DATE ]; then
  echo "Backup destination not available. Make sure you have write permission in TARGET!"
  echo "Exiting..."
  exit 2
fi

echo "Verifying Sources..."
for source in $SOURCES; do
    echo "Checking $source..."
    if [ ! -x $source ]; then
     echo "Error with $source!"
     echo "Directory either does not exist, or you do not have proper permissions."
     exit 2
   fi
done

if [ -f $EXCLUDE_FILE ]; then
    EXCLUDE="--exclude-from=$EXCLUDE_FILE"
fi

echo "Sources verified. Running rsync..."
for source in $SOURCES; do

  # Create directories in $TARGET to mimick source directory hiearchy
  if [ ! -d $TARGET/$BACKUP_DATE/$source ]; then
    mkdir -p $TARGET/$BACKUP_DATE/$source
  fi
 
  rsync $VERBOSE --exclude=$TARGET/ $EXCLUDE -a --delete $source/ $TARGET/$BACKUP_DATE/$source/

done

exit 0

--

דותן מזור, קובץ ליצירת גיבוי מקומי באמצעות פקודת rsync, במערכות גנו/לינוקס.

www.dotanmazor.com

 
Scalix Installation on CentOS 5 with Internal DNS

If you came here, it means that "something" is not working with your Scalix Community Edition installation on a Centos GNU/Linux machine. Well, this may be a good ending point. The tested Scalix version was Scalix 11.2.0 on a CentsOS 5 machine. This should be pretty much the same as installing on a RHEL 5 (Red Hat Enterprise Linux) server.

קרא עוד...
 
פתרון בעיית VFS error: Invalid parameters בתוכנת VMware

מדובר בפתרון לבעיה בהתקנת שרת ה- VMware דרך מנהל חבילות, כמו אובונטו לינוקס (Ubuntu) או סוסה לינוקס (Suse).

כאשר מעדכנים את החבילה שנקראת vmware-server היא דורסת קובץ קיים, שנקרא libpng12.so.0 עם קובץ שמגיע עם ההתקנה. אבל זה עוד בסדר, עד שהיא דורסת את הקובץ libgcc_s.so.1 שכל מי שמבין אפילו קצת, מבין שזה פתח לבעיות.

מה שקורה, זה שאחרי העדכון, כאשר פותחים בתוכנה חלון לצורך סיור במערכת הקבצים, מקבלים את ההודעה המאוד-לא-סימפטית הבאה:

The folder contents could not be displayed 

VFS error: Invalid parameters

קרא עוד...
 
הגדרת רשת בויסטה תחת VMWare על לינוקס

למעשה, מדובר בנושא אשר נפתר די בקלות, אבל נראה בתור כאב-ראש לא קטן בהתחלה.

המערכת: אתם מריצים מערכת הפעלה לינוקס. עליה, אתם מריצים את תוכנת הוירטואליזציה VMWare, בגרסת השרת, ובתוכה התקנתם את חלונות ויסטה.

קרא עוד...
 
<< התחלה < הקודם 1 2 3 הבא > סיום >>

דף 1 מתוך 3
דותן מזור, Powered by Joomla!; free resources by SG web hosting