Ubuntu (Specific) Server

From QwikITedia

Jump to: navigation, search

Contents



APACHE Virtual Hosts - Ubuntu Configuration

Purpose

Named Based Virtual Hosting

Configuration

Enable Vhosting within Apache

vi /etc/apache2/apache2.conf
:
NameVirtualHost 12.0.0.124:80

Setup each Virtual Apache Server

<VirtualHost 12.0.0.124:80>
        ServerName myserver-A.com
        ServerAlias www.myserver-A.com
        ServerAdmin webmaster@myserver-A.com
        DocumentRoot /var/www/www.myserver-A.com

        ErrorLog /var/log/apache2/myserver-A-error.log
        CustomLog /var/log/apache2/myserver-A-access.log combined

</VirtualHost>
<VirtualHost 12.0.0.124:80>
        ServerName myserver-B.com
        ServerAlias www.myserver-B.com
        ServerAdmin webmaster@myserver-B.com
        DocumentRoot /var/www/www.myserver-B.com

        ErrorLog /var/log/apache2/myserver-B-error.log
        CustomLog /var/log/apache2/myserver-B-access.log combined

</VirtualHost>

Activate the Virtual Hosts

cd /etc/apache2/sites-enabled/
ln -s ../sites-available/www.myserver-A.com .
ln -s ../sites-available/www.myserver-B.com .
cd /etc/apache2/sites-enabled/
sudo a2ensite www.myserver-A.com
sudo a2ensite www.myserver-B.com
  1. Stop and Start the server - drastic( sudo shutdown -r now )
  2. Stop and Start Apache - overkill( sudo /etc/init.d/apache2 stop and then start )
  3. Restart Apache - perfectly reasonable( sudo /etc/init.d/apache2 restart )
  4. Leave Apache Running and reload its config on the fly - perfect( sudo /etc/init.d/apache2 reload )
sudo /etc/init.d/apache2 restart

Problems

Deactivate a Virtual Host

cd /etc/apache2/sites-enabled/
sudo a2dissite www.myserver-A.com
sudo a2dissite www.myserver-B.com
cd /etc/apache2/sites-enabled/
unlink ../sites-available/www.myserver-A.com .
unlink ../sites-available/www.myserver-B.com .
sudo /etc/init.d/apache2 restart


Generic (Headless) Ubuntu Server Build

sudo apt-get install <pacakge below in brackets>
sudo useradd –d /home/<user> -m <user>
sudo adduser <user> admin
sudo apt-get install make
sudo apt-get install sun-java6-jdk
sudo update-alternatives --config editor
Select 1 for vi
sudo apt-get install subversion


Setup iSCSI SAN Volume

Install Open-iSCSI Initiator

root@myserver1:~# apt-get install open-iscsi

Configure Open-iSCSI

root@myserver1:~# ln -s /etc/{iscsid.conf,initiatorname.iscsi} /etc/iscsi/
ln: creating symbolic link `/etc/iscsi/iscsid.conf': File exists
ln: creating symbolic link `/etc/iscsi/initiatorname.iscsi': File exists
root@myserver1:~# vi /etc/iscsi/iscsid.conf
#*****************
# Startup settings
#*****************

# To request that the iscsi initd scripts startup a session set to "automatic".
# node.startup = automatic
#
# To manually startup the session set to "manual". The default is manual.
# node.startup = manual

# iscsi setup for Myserver + SAN
node.startup = automatic
node.session.auth.username = ''
node.session.auth.password = ''
discovery.sendtargets.auth.username = ''
discovery.sendtargets.auth.password = ''
node.session.timeo.replacement_timeout = 120
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.noop_out_interval = 10
node.conn[0].timeo.noop_out_timeout = 15
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.conn[0].iscsi.MaxRecvDataSegmentLength = 65536
root@myserver1:~# /etc/init.d/open-iscsi restart

Create a volume on SAN


Discover SAN from Server

root@myserver1:~# iscsiadm -m discovery -t sendtargets -p 10.7.10.10
12.x.y.z:3260,1 iqn.2001-05.com.equallogic:0-8a0906-bd12dbf02-caa000001b84ac28-myserver-a
root@myserver1:~# 
root@myserver1:~# iscsiadm --mode node --targetname iqn.2001-05.com.equallogic:0-8a0906-bd12dbf02-caa000001b84ac28-myserver-a --portal 12.a.b.c:3260 --login
iscsiadm: no records found!
root@myserver1:/etc/network# /etc/init.d/open-iscsi restart

Format iSCSI Volume

root@myserver1:/etc/network# tail -f /var/log/messages

You'll see something akin to:

Sep 29 14:27:47 myserver1 kernel: [ 9322.654601]  sdb: sdb1
Sep 29 14:27:47 myserver1 kernel: [ 9322.668096] sd 4:0:0:0: [sdb] Attached SCSI disk
Sep 29 14:27:47 myserver1 kernel: [ 9322.668139] sd 4:0:0:0: Attached scsi generic sg3 type 0
root@myserver1:~# fdisk -l

Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000080

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       17043   136897866   83  Linux
/dev/sda2           17044       17769     5831595    5  Extended
/dev/sda5           17044       17769     5831563+  82  Linux swap / Solaris

Disk /dev/sdb: 1073.7 GB, 1073747066880 bytes
255 heads, 63 sectors/track, 130542 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table
root@myserver1:~# 

So we need to partition /dev/sdb/ .. Let's make it Linux format...ext3:

root@myserver1:/# fdisk /dev/sdb

The number of cylinders for this disk is set to 130542.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130542, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130542, default 130542): 
Using default value 130542

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@myserver1:/# mkfs.ext3 /dev/sdb1
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65544192 inodes, 262144645 blocks
13107232 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
8001 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mount file system

root@myserver1:~# mkdir /iscsi
root@myserver1:~# mount /dev/sdb1 /iscsi
root@myserver1:/# fdisk -l

Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000080

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       17043   136897866   83  Linux
/dev/sda2           17044       17769     5831595    5  Extended
/dev/sda5           17044       17769     5831563+  82  Linux swap / Solaris

Disk /dev/sdb: 1073.7 GB, 1073747066880 bytes
255 heads, 63 sectors/track, 130542 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x020a585e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      130542  1048578583+  83  Linux
root@myserver1:/# 


Update /etc/fstab file

root@myserver1:/# vi /etc/fstab
# /dev/sdb - SAN unit
/dev/sdb1               /iscsi           ext3    defaults        1 2

(optional)Label the Partition

root@myserver1:/# e2label /dev/sdb1 /MyServer-A
LABEL=/Myserver-A /iscsi ext3 defaults 1 2

Upgrade an Ubuntu Server from cli

sudo vi /etc/apt/sources.list
:1,$s/gutsy/hardy/g
or
:%s/gutsy/hardy/g
:wq!
sudo apt-get update
sudo apt-get dist-upgrade

Virtualization - Ubuntu JeOS

mkdir /virtual-machines
cd /virtual-machines
mkdir server-A
mkdir server-B

sudo ubuntu-vm-builder kvm hardy --arch amd64 --mem 3000 --rootsize 60000 --swapsize 6000 --kernel-flavour server --hostname server-B --domain usa --mirror http://archive.ubuntu.com/ubuntu --components main,universe,restricted --name 'James Smith' --user jsmith --pass changeme --ip 12.x.x.w --mask 255.255.255.0 --net 12.x.x.0 --bcast 12.x.x.255 --gw 12.x.x.254 --dns 12.x.x.2 --addpkg vim --addpkg openssh-server --libvirt qemu:///system
  virsh --connect qemu:///system
virsh # list --all
 Id Name                 State
----------------------------------
  - server-A           shut off
  - server-A_          shut off
  - server-A__         shut off
  - server-B             shut off
  - server-B_            shut off
  - server-B__           shut off

virsh # list --all
 Id Name                 State
----------------------------------
  3 server-A         running
  4 server-B         running
  - server-A_        shut off
  - server-A__       shut off
  - server-B_        shut off
  - server-B__       shut off

virsh # undefine server-A_
Domain server-A_ has been undefined

virsh # list --all
 Id Name                 State
----------------------------------
  3 server-A         running
  4 server-B         running
  - server-A__       shut off
  - server-B_        shut off
  - server-B__       shut off
virsh#start server-A
Domain server-A started
virsh#start server-B
Domain server-B started
virsh -c qemu:///system start server-B
virsh -c qemu:///system shutdown server-B
SERVER-A Config :: USA domain
sudo ubuntu-vm-builder kvm hardy --arch amd64 --mem 3000 --rootsize 60000 --swapsize 6000 --kernel-flavour server --hostname server-A --domain usa --mirror http://archive.ubuntu.com/ubuntu --components main,universe,restricted --name 'James Smith' --user jsmith --pass changeme --ip 12.x.x.y --mask 255.255.255.0 --net 12.x.x.0 --bcast 12.x.x.255 --gw 12.x.x.254 --dns 12.x.x.2 --addpkg vim --addpkg openssh-server --libvirt qemu:///system



SERVER-B - Config :: USA domain
sudo ubuntu-vm-builder kvm hardy --arch amd64 --mem 3000 --rootsize 60000 --swapsize 6000 --kernel-flavour server --hostname server-B --domain usa --mirror http://archive.ubuntu.com/ubuntu --components main,universe,restricted --name 'James Smith' --user jsmith --pass changeme --ip 12.x.x.w --mask 255.255.255.0 --net 12.x.x.0 --bcast 12.x.x.255 --gw 12.x.x.254 --dns 12.x.x.2 --addpkg vim --addpkg openssh-server --libvirt qemu:///system


Personal tools
Namespaces
Variants
Actions
Richard Esmonde.com
Wiki Navigation
Toolbox