Just a simple post to remind me how to do this in the future.
I needed to copy a new image to sixty (60) client directories, and symlinking like we would normally do was not an option. Thankfully xargs came to the rescue once again. I found my answer here, but I wasn't going to type out the full paths for each of the sixty directories.
# echo /somedir/*/pub/product/images/ | xargs -n 1 cp -va preview_unavailable.png
Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts
Friday, September 20, 2013
Friday, October 21, 2011
Installing and Configuring ZendServer Community Edition (CE) on CentOS 5 / 6
The quick and the dirty:
Download the Zend Server (DEB/RPM Installer Script) from zend.com. (An account is required).
un-pack the the tarball (tar -xzfv ZendServer-5.5.0-RepositoryInstaller-linux.tar.gz)
Run ./install_zs.sh 5.3 ce or ./install_zs.sh 5.2 ce depending on which version of PHP you want to run.
Edit your iptables (you are running iptables right?) vi /etc/sysconfig/iptables
Add in a line for the ZendServer lighthttpd server (-A INPUT -m state --state NEW -m tcp -p tcp --dport 10081 -j ACCEPT)
Restart iptables (/sbin/service iptables restart)
Visit (http://YOURSERVERHERE.com:10081/ZendServer/) in a web browser to accept the EULA and set a password.
Alternatively run (/usr/local/zend/bin/zs-setup accept-eula) and (/usr/local/zend/bin/zs-setup set-password YOURSECUREPASSWORD )
If you need to restart Zend Server run /sbin/service zend-server restart. This will restart both apache (httpd) and the LightHTTPD Zend Server gui.
Some important notes before heading off into the wonderful world of Zend Server:
Be sure that your distribution's PHP isn't installed as well as the Zend Server, including the CLI, as it will mess with running php from the command line and who knows what else.
The php binary is located at /usr/local/zend/bin/php, which can be verified by running which php. As such if you need to run php from cron be sure to add this to your path. (I have PATH=$PATH:$HOME/bin:/usr/local/zend/bin in my ~/.bash_profile).
If you need to modify a setting in php.ini you will find it at /usr/local/zend/etc/php.ini. Remember to restart zend server for any changes to take effect.
Beyond those things there isn't too much difference between running zend server and running php from your distribution.
Some important notes before heading off into the wonderful world of Zend Server:
Be sure that your distribution's PHP isn't installed as well as the Zend Server, including the CLI, as it will mess with running php from the command line and who knows what else.
The php binary is located at /usr/local/zend/bin/php, which can be verified by running which php. As such if you need to run php from cron be sure to add this to your path. (I have PATH=$PATH:$HOME/bin:/usr/local/zend/bin in my ~/.bash_profile).
If you need to modify a setting in php.ini you will find it at /usr/local/zend/etc/php.ini. Remember to restart zend server for any changes to take effect.
Beyond those things there isn't too much difference between running zend server and running php from your distribution.
Tuesday, September 27, 2011
System Activity Report (sar) and You
sar is an acronym for System Activity Report. It takes a snapshot of the system periodically. On most distributions it comes with the sysstat package. On Redhat and derived distributions the package will install a set of cron jobs in /etc/cron.d/sysstat. There are two cron jobs to take note of. The first one runs every ten minutes as root. It runs the script /usr/lib/sa/sa1 -S Disk 1 1. This script saves its output in report files. The files are written to /var/log/sa/sar[dd], where [dd] is the two digit date for today's date. (e.g. Today is 8/26/2011. The log file is /var/log/sa/sar26)
The second cron job runs at 23:53. This cron job summarizes the days activity. Both of the reports are saved as binary data, so normal tools are useless here.
There are many flags to use with sar when running it interactivly. Some of the flags have additional atguments that are required when used. One example of thses flags is -n which al requires an additional argement suach as DEV or NFS ro IP. This specific example has eightteen (18) potential arguments, not including ALL.
With sar liberal use of the man pages are highly suggested. Not only are the flags and any arguments documented, but the headers for each one and what they represent are explained as well. This comes in handy if you get overzealous with flags and aren't quite sure what you're looking at.
I'm only going to cover some of the most notable flags, what they show and their headers. Be careful however as some flags exist in both upper and lower case and report vastly different metrics. One example of the is -b which reports on I/O transfer but -B reports on paging stats.
First off the plate is -b which as I've already stated reports on I/O transfer stats and has the following headers:
tps: Transfers per second to a physical device.
rtps: Read transfers per second to a physical device.
wtps: Write transfers per second to a physical device.
bread/s: Blocks (since kernel 2.4 = sectors = 512 bytes) read from devices per second.
bwrtn/s: Blocks written to devices per second.
Example output from a production server running: sar -b 1 1
Linux 2.6.18-274 el5PAE (server.domain.com) 8/26/2011
09:23:57 PM tps rtps wtps bread/s bwrtn/s
09:23:58 PM 7829.00 133.00 7696.00 1528.00 76960.00
Average: 7829.00 133.00 7696.00 1528.00 76960.00
-B will report paging stats. Some metrics / headers are only available in kernels 2.5 and newer.
pgpgin/s: Kilobytes paged in from disk per second.
pgpgout/s: Kilobytes paged out from disk per second.
magflt/s: Major faults per second (hits to disk, this is a bad thing...)
-c Process creation stats.
proc/s: Processes created per second.
-d Activity for each block device.
tps: Transfers per second
rd_sec/s: Sectors (512 bytes) read from block device per second.
wr_sec/s: Sectors (512 bytes) written to block device per second.
avgrq-sz: Average # of sectors
avgqu-sz: Average queue length
await: Average time in milliseconds for queue + servicing request.
svctm: Average servicing time.
%util: CPU percentage while I/O requests where issued. Close to 100% = device saturation.
-n DEV Network interface stats.
IFACE: Interface Name
rxpck/s: Packets received per second.
tcpck/s: Packets sent per second.
rxbyt/s: Bytes received per second.
txbyt/s: Bytes sent per second.
rxcmp/s: Compressed packets received per second.
txcmp/s: Compressed packets sent per second.
rxmcst/s: Multicast packets received per second.
-P ALL Per processor (or core) stats
-p Print pretty device names
Shows block devices as sda instead of dev8-0. Has no effect on Network device names.
-A same as: -bBcdqrRuvwWy -I SUM -I XALL -n ALL -P ALL
After you install the sysstat package you really need to let it run for a while and gather stats to see the real beauty of it all. However you can run it interactively if required. When running sar interactively the syntax is sar -FLAGS Interval Duration. (e.g. sar -b 2 60) runs I/O stats every two seconds for a minute. This is very hand to run if you're troubleshooting a slow system or watching it under load.
The second cron job runs at 23:53. This cron job summarizes the days activity. Both of the reports are saved as binary data, so normal tools are useless here.
There are many flags to use with sar when running it interactivly. Some of the flags have additional atguments that are required when used. One example of thses flags is -n which al requires an additional argement suach as DEV or NFS ro IP. This specific example has eightteen (18) potential arguments, not including ALL.
With sar liberal use of the man pages are highly suggested. Not only are the flags and any arguments documented, but the headers for each one and what they represent are explained as well. This comes in handy if you get overzealous with flags and aren't quite sure what you're looking at.
I'm only going to cover some of the most notable flags, what they show and their headers. Be careful however as some flags exist in both upper and lower case and report vastly different metrics. One example of the is -b which reports on I/O transfer but -B reports on paging stats.
First off the plate is -b which as I've already stated reports on I/O transfer stats and has the following headers:
tps: Transfers per second to a physical device.
rtps: Read transfers per second to a physical device.
wtps: Write transfers per second to a physical device.
bread/s: Blocks (since kernel 2.4 = sectors = 512 bytes) read from devices per second.
bwrtn/s: Blocks written to devices per second.
Example output from a production server running: sar -b 1 1
Linux 2.6.18-274 el5PAE (server.domain.com) 8/26/2011
09:23:57 PM tps rtps wtps bread/s bwrtn/s
09:23:58 PM 7829.00 133.00 7696.00 1528.00 76960.00
Average: 7829.00 133.00 7696.00 1528.00 76960.00
-B will report paging stats. Some metrics / headers are only available in kernels 2.5 and newer.
pgpgin/s: Kilobytes paged in from disk per second.
pgpgout/s: Kilobytes paged out from disk per second.
magflt/s: Major faults per second (hits to disk, this is a bad thing...)
-c Process creation stats.
proc/s: Processes created per second.
-d Activity for each block device.
tps: Transfers per second
rd_sec/s: Sectors (512 bytes) read from block device per second.
wr_sec/s: Sectors (512 bytes) written to block device per second.
avgrq-sz: Average # of sectors
avgqu-sz: Average queue length
await: Average time in milliseconds for queue + servicing request.
svctm: Average servicing time.
%util: CPU percentage while I/O requests where issued. Close to 100% = device saturation.
-n DEV Network interface stats.
IFACE: Interface Name
rxpck/s: Packets received per second.
tcpck/s: Packets sent per second.
rxbyt/s: Bytes received per second.
txbyt/s: Bytes sent per second.
rxcmp/s: Compressed packets received per second.
txcmp/s: Compressed packets sent per second.
rxmcst/s: Multicast packets received per second.
-P ALL Per processor (or core) stats
-p Print pretty device names
Shows block devices as sda instead of dev8-0. Has no effect on Network device names.
-A same as: -bBcdqrRuvwWy -I SUM -I XALL -n ALL -P ALL
After you install the sysstat package you really need to let it run for a while and gather stats to see the real beauty of it all. However you can run it interactively if required. When running sar interactively the syntax is sar -FLAGS Interval Duration. (e.g. sar -b 2 60) runs I/O stats every two seconds for a minute. This is very hand to run if you're troubleshooting a slow system or watching it under load.
Monday, October 04, 2010
Documentation, not always the How To Dos
Documentation for me is often just How to do something, but I have been forgetting the WHY part of the equation. For instance, my documentation says to do our weekly maintenance window after 21:30 and to only reboot one particular server after 21:45, but I didn't say why and had forgotten myself. So I started doing the maintenance earlier and at one point rebooted the one particular server at 21:30. This caused the last of our production cron jobs to not run, and thus a customer didn't get their batch for the day.
Now this could have been avoided a few different ways. Since that first time was a mistake any thing that happens after it is a failure on my part, and thus can't happen again.
This is just one instance where the WHY is critical, but there are others. So please when you are writing documentation, and you should be please include the WHY you do something the way you do it. It also helps train the new guy, or your replacement.
Now this could have been avoided a few different ways. Since that first time was a mistake any thing that happens after it is a failure on my part, and thus can't happen again.
- I could have followed our procedure to the T.
- Read my e-mail to see that the cron job hadn't run yet.
- Run the cron job by hand after the server restart.
- Did all of the precursor work and waited for the cron job to run.
- Did all of the precursor work and run the cron job by hand.
This is just one instance where the WHY is critical, but there are others. So please when you are writing documentation, and you should be please include the WHY you do something the way you do it. It also helps train the new guy, or your replacement.
Wednesday, February 10, 2010
Mounting a LVM volume in Ubuntu (Live CD)
A while back my testing server crashed. This was no surprise to anyone as it was just a (Very) old workstation. However it was running my nagios install in a production setting. I had been meaning to move it to a proper server, but just hadn't gotten around to it. To make matters worse, I didn't back any of it up. So thankfully it was only the motherboard that failed and not the HDD.
I mounted the HDD in another PC I had sitting around and booted it using Ubuntu Live CD.
First, boot Ubuntu.
Second, install the needed tools:
$ sudo apt-get install lvm2
Third, load the modules to do our task:
$ sudo modprobe dm-mod
Fourth, scan the system for LVM volumes. Look for the volumes you want to mount. Typically this will be VolGroup00:
$ sudo vgscan
Fifth, we need to activate the volume(s):
$ sudo vgtchange -ay VolGroup00
Sixth, Look for the logical volume containing the root file system. Typically this will be LogVol00:
$ sudo lvs
Seventh, create the directory to mount the drive:
$ sudo mkdir /mnt/restore
Eighth, Mount the volume to the directory you just created.
$ sudo mount /dev/VolGroup00/LogVol00 /mnt/restore -o ro,user
Ninth, Copy your files off of the drive.
$ cp /mnt/restore/some/dir/and/path /some/dir/and/path
Tenth, Setup what ever backup means you have on the new server!
All in all this wasn't a terrible thing, it could have been much worse. I have since moved the nagios setup to a virtual machine and am backing it up nightly.
Labels:
CentOS,
Debian,
Fedora Core,
Linux,
nagios,
OS,
Redhat,
skills,
software,
Study Tips,
Tools,
Ubuntu,
Virtual Machine
Friday, September 11, 2009
Bash: Finding files between two dates in the current directory
Today my boss asked me for a bash command (or script) to find some files between two dates.
Thanks to Jadu Saikia over at Unstableme his post UNIX BASH scripting: Find Files between two dates, I had a starting point.
This will find all files between the two dates (20071019 & 20071121) in this case.
find . -type f -exec ls -l --time-style=full-iso {} \; | awk '{print $6,$NF}' | awk '{gsub(/-/,"",$1);print}' | awk '$1>= 20071019 && $1<= 20071121 {print $2}'Now, if you want just PGP files you would do:
find *.pgp -type f -exec ls -l --time-style=full-iso {} \; | awk '{print $6,$NF}' | awk '{gsub(/-/,"",$1);print}' | awk '$1>= 20071019 && $1<= 20071121 {print $2}'The second request that my boss was looking for with this is the file size, something that was being left out by awk. So we can fix that by updating the command to:
find *.pgp -type f -exec ls -lh --time-style=full-iso {} \; | awk '{print $6,$NF,$5}' | awk '{gsub(/-/,"",$1);print}' | awk '$1>= 20090624 && $1<= 20090901 {print $2,$3}'We added in a $5 to the first awk command, and the final one had $3 added to it. Also I like human readable file sizes so I added -h to the ls command.
Labels:
CentOS,
Debian,
Fedora Core,
Linux,
OS,
programming,
Redhat,
skills,
Study Tips,
Tools,
Ubuntu
Tuesday, July 14, 2009
Ghostscript Convert PDF to TIFF
Again this is mainly for my reference, but someone may have trouble finding the solution like I did earlier today.
On Windows be sure to add "C:\Program Files\gs\gs8.64\bin" to your PATH, then run the following command.
gswin32c -dNOPAUSE -q -r300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=[YOUR_OUTPUT_FILENAME.TIFF] [YOUR_INPUT_FILENAME.PDF]
Similarly on Linux you can run the command below.
There are also possibilities to script this, and when you can do that you should. I haven't found the need to bring it to that point yet as I just had to do four files today, but should this come up again I will be scripting it in some fashion and posting the results here.
Thank you to StackOverflow for the solution to my problem. Also one of the other solutions to this is to use a recursive search of a directory with PowerShell to convert files.
On Windows be sure to add "C:\Program Files\gs\gs8.64\bin" to your PATH, then run the following command.
gswin32c -dNOPAUSE -q -r300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=[YOUR_OUTPUT_FILENAME.TIFF] [YOUR_INPUT_FILENAME.PDF]
Similarly on Linux you can run the command below.
gs -dNOPAUSE -q -r300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=[YOUR_OUTPUT_FILENAME.TIFF] [YOUR_INPUT_FILENAME.PDF]There are also possibilities to script this, and when you can do that you should. I haven't found the need to bring it to that point yet as I just had to do four files today, but should this come up again I will be scripting it in some fashion and posting the results here.
Thank you to StackOverflow for the solution to my problem. Also one of the other solutions to this is to use a recursive search of a directory with PowerShell to convert files.
Friday, July 10, 2009
Creating a RAID 5 Array in software on CentOS 5.3
In order to create a RAID 5 array entirely in software on Linux you need to do a few things.
First I used three Identical drives, same speed, size, make, and model. This may not be a requirement, but
it will defiantly help the process. For RAID 5 you will need at least three partitions of the same size.
I picked up a four disk internal hot-swap enclosure from Addonics (http://www.addonics.com/products/raid_system/ae4rcs35nsa.asp) and
a hot-swap capable raid card. Once I got everything physically installed in the server case I booted into CentOS 5.3
and got on the command line. The first thing you need to do is create partitions on the blank drives and set them to be
Linux raid autodetect (Hex value of fd). To do this run fdisk /dev/sdX where X is the drive(s) that you want to partition for the RAID array.
For me this was SDC, SDD, SDE but you results will vary.
fdisk /dev/sdc
n [ENTER]
e [ENTER]
4 [ENTER]
[ENTER]
[ENTER]
n [ENTER]
l [ENTER]
t [ENTER]
5 [ENTER]
fd [ENTER]
w [ENTER]
You will want to create an Extended partition so choose n for New partition. If you get stuck you can hit m to get the help menu.
After you hit n type e for Extended. Then you will have to enter a partition number, I choose 4 for all of my drives.
After that you n again and then choose l for logical partition type. Again it will ask for a partition number 1-4 are for primary and thus not an option,
so I choose 5 for all of my drives.
Once the logical partitions are created hit t to change the partition type. If you are unsure what to use hit l, but in this case we already know that we want to
use type fd for the Linux RAID auto.
Once the type has been changed you can type w to write this info to the drive and start on the next one.
fdisk /dev/sdd
n [ENTER]
e [ENTER]
4 [ENTER]
[ENTER]
[ENTER]
n [ENTER]
l [ENTER]
t [ENTER]
5 [ENTER]
fd [ENTER]
w [ENTER]
fdisk /dev/sde
n [ENTER]
e [ENTER]
4 [ENTER]
[ENTER]
[ENTER]
n [ENTER]
l [ENTER]
t [ENTER]
5 [ENTER]
fd [ENTER]
w [ENTER]
Now that we have three (the minimum) partitions for our RAID device we have to create it in CentOS. Here we will use a tool called mdadm to create the
actual RAID device in Linux.
/sbin/mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdc5 /dev/sdd5 /dev/sde5 [ENTER]
Once this returns back, and it should be pretty quick, you will have a RAID 5 device. To check the status of it run:
/sbin/mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.03
Creation Time : Wed Jul 8 09:14:19 2009
Raid Level : raid5
Array Size : 2930271744 (2794.52 GiB 3000.60 GB)
Used Dev Size : 1465135872 (1397.26 GiB 1500.30 GB)
Raid Devices : 3
Total Devices : 3
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Fri Jul 10 11:20:02 2009
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 64K
UUID : 53f6f95a:9e33f5ba:7ac8ef3e:0a40921a
Events : 0.2
Number Major Minor RaidDevice State
0 8 21 0 active sync /dev/sdc5
1 8 37 1 active sync /dev/sdd5
2 8 53 2 active sync /dev/sde5
Now for me after I first created the RAID device the state was listed as clean, degraded, rebuilding. There was a place for the percentage rebuilt and
/dev/sde5 was listed as spare. It took the better part of a day for the rebuild to finish, given that it was a three terabyte device I am not surprised by that.
Once the rebuild was done I had to create a Physical volume for LVM to be able to manage the RAID device.
pvcreate /dev/md0
After that I was able to use system-config-lvm to create the storage volume and format the drive.
Labels:
CentOS,
Debian,
Fedora Core,
Linux,
OS,
Study Tips,
Tools
Tuesday, July 07, 2009
Copy Directory Structure Only
This is a simple one liner for copying a Directory structure, and not the contents.
find * -type d -exec mkdir /new_directory/\{\} \;
Now there are a few caveots to this of course, but they are simple.
First the /new_directory/ has to exist.
Second, you have to run the command from within the directory that you want to copy the structure from.
For example, if I need to copy the structure of /Storage to /newStorage I would:
mkdir /newStorage
cd /Storage
find * -type d -exec mkdir /newStorage/\{\} \;
Labels:
Backup,
CentOS,
Debian,
Fedora Core,
Linux,
OS,
Redhat,
Study Tips,
Tools
Wednesday, May 27, 2009
Failed to modify password entry for user while adding user with smbpasswd
I was trying to create a user today in samba and was getting the error "Failed to modify password entry for user [USER]".
I read over the man pages for smbpasswd and saw that I needed to add the -n switch because this user will not have a password. So again I tried to add the user with "smbpasswd -a -n [USER]" and got the same error.
A quick Google search lead me to a newb mistake on my part... I didn't have the user I was trying to add in my UNIX password file. A quick "useradd [USER]" followed by the same "smbpasswd -a -n [USER]" and I was all set.
Granted there are other reasons why this process might fail, but for me this was the reason.
I read over the man pages for smbpasswd and saw that I needed to add the -n switch because this user will not have a password. So again I tried to add the user with "smbpasswd -a -n [USER]" and got the same error.
A quick Google search lead me to a newb mistake on my part... I didn't have the user I was trying to add in my UNIX password file. A quick "useradd [USER]" followed by the same "smbpasswd -a -n [USER]" and I was all set.
Granted there are other reasons why this process might fail, but for me this was the reason.
Labels:
CentOS,
Debian,
Fedora Core,
Linux,
Redhat,
skills,
Study Tips,
Tools
Wednesday, May 06, 2009
mail command returns fseek Invalid argument, panic temporary file seek
Today I logged into one of our older servers, haven't logged into it for a while and saw that there was new mail (as always given the number of cron jobs running).
Below is the output of my command.
[root@server /]# mail
"/var/spool/mail/root": 1832 messages 1777 new 1832 unread
fseek: Invalid argument
panic: temporary file seek
After a little bit of searching online I found two possible and simple solutions.
If you want to read the mail try using mutt instead of mail. It doesn't have a problem with the 2GB file size of the mail box that mail did.
If you don't care about the old stuff you can run:
rm -f /var/spool/mail/root
to remove the file and then
cat /dev/null > /var/spool/mail/root
to recreate a blank file.
I ended up reading the mail I wanted and then blowing the file away. But before I could recreate it there was already a new file with 62MB of mail in it.
Tuesday, February 17, 2009
Please check your autoconf installation and the $PHP_AUTOCONFenvironment variable is set correctly and then rerun this script.
This is a very simple fix if you are running Redhat Enterprise / CentOS 5.2.
yum install autoconf
I came across this while setting up memcache / memcached. I had tried running phpize from the memcach-2.2.4 directory but was getting the error "Please check your autoconf installation and the $PHP_AUTOCONFenvironment variable is set correctly and then rerun this script."
Once I had autoconf installed I was able to finish the install process
./configure
make
make install
I know there are easier ways to do all of this on CentOS, but we are using a newer version of PHP (5.2.6) than came with CentOS (5.1.6), so using yum to install this would not have worked.
Labels:
apache,
CentOS,
Debian,
fedora core 4,
Linux,
programming,
skills,
Tools,
Ubuntu
Tuesday, February 10, 2009
How to: mod_expires & mod_deflate in Apache running on CentOS 5
While trying to improve the performance of our internal workflow I was tasked with setting up mod_deflate and mod_expires, based off of Yahoo's! Best Practices for Speeding Up Your Website.
The nitty gritty of these two is to make sure they are both listed in your httpd.conf file:
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
Since this server is running the default CentOS 5 apache I already had the support I needed. I then continued on to find the documentation online. Both modules support vhost context so that is the route I went with. I added the lines below to each vhost that I wanted the settings to take place for.
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType text/css A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/pdf A2592000
The syntax for the ExpiresByType directive is:
ExpiresByType mime/type TimeInSeconds.
The A2592000 is Access time + one month. If I wanted the file to be cached for one month from modification date I would have done M2592000 instead.
Other handy numbers in seconds:
86400 = One Day
604800 = One Week
2592000 = One Month
31536000 = One Year (365 Days)
157680000 = Five Years
3153600000 = Ten Years
Why might these large numbers come in handy? Well you want to set far future expiration dates for things that don't change often. The catch is if you need to update one of these items with a far future expiration date. You have to change the file name. Modify the case of the filename will work in the short term but really you want to start adding version strings to all of your static files like CSS and JavaScript.
mod_deflate is much easier to setup. Simply add the line:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript text/css
Again based on the mod_deflate documentation you can add this directive to the vhost directives. Please note that this directive can be placed on just about any context level and as such is very powerful. Also note that you should not try to compress image file because they are already compress and it really is just a waste of CPU and time.
Using these two methods we where able to reduce our website on a first visit from 190.7Kb total to 157.3Kb total.
Before:
9.4K HTML/Text
32.1K Javascript
12.9K Stylesheets
0.4K CSS Images
135.9K Images
190.7K Total
After:
3.1K HTML/Text
15.0K Javascript
2.9K Sytlesheets
0.4K CSS Images
135.9K Images
157.3K Total
I also used the yuicompressor to minify our main Javascript and our CSS file.
After:
3.1K HTML/Text
12.3K Javascript
2.2K Sytlesheets
0.4K CSS Images
135.9K Images
154.0K Total
As you can see using mod_deflate to compress the Javascript and CSS is a more substantial savings in terms of bandwidth than trying to minify.
Granted based on my observations if we really wanted to save on bandwidth and make our pages load faster we would reduce the substantial image footprint.
In case anyone is wondering where I culled all of these numbers from I used Y! Slow for Firebug in Firefox.
Thursday, January 15, 2009
How to: Use chkconfig, or keeping your services running on a new run level
OK, so I didn't take my own advice and made sure that all of my services where set to the run on the correct run levels before I switched run levels and rebooted the servers.
chkconfig is a command-line tool for updating the /etc/rc[0-6].d directories.
So I ran chkconfig --list | more to see what was running and in what run levels. Next I ran chkconfig --levels 235 service on to tell the service to start when it enters that run level. For example:
chkconfig --levels 235 named on
Now since I have already rebooted the server, and I know this service didn't start on it's own I had to:
service named start
If I had been smarter and done all of this before hand but wanted to see if named was running or not I would have run:
service named status
I understand that all of this is basics, but some people learn from others mistakes, so hopefully I can save one person from doing the same thing.
Other useful chkconfig switches:
chkconfig --help (Used to display the help dialog)
chkconfig --add [Service Name] (chkconfig --add mysqld) (Adds a service to the chkconfig list)
chkconfig --del [Service Name] (chkconfig --del mysqld) (Deletes a service from the chkconfig list)
chkconfig --level [2,3,4,5][Service Name][on, off, reset] (chkconfig --levels 235 httpd on)(Sets the run levels a service should start in.)
chkconfig can also manage xinetd scripts via /etc/xinetd.d.
Oh, and while you are at it run chkconfig --list | more to review what services are running on your server, you might be suprised. For instance I had bluetooth support running, but not one computer in my company has bluetooth support, so I disabled it (chkconfig --levels 2345 off) and (service bluetooth stop).
Friday, January 09, 2009
Configuring PuTTY to use PKI (passwordless) authentication
Since this is about using PuTTY I would recommend you download it if you haven't already. Also you will need to get PuTTYgen, it might be worth it to grab pscp as well. I like to keep putty.exe and puttygen.exe in my Windows directory, so I don't have to update my path, thus allowing me to run putty right from the command prompt.
Now run PuTTYGen and create a new pair of keys by clicking the “Generate” button. You will have to move your mouse around in the box to generate randomness, so keep doing that until the progress bar fills up. You can keep all the options at their default settings. Then, save both public and private key to a safe location. Name your public key [your_key_name].pub and the private key [your_key_name].ppk.
Now, upload your public key to a directory on your remote system. I used pscp to do this quickly to all of my servers (pscp [your_key_name.pub] user@remotesystem:)
Now you have to import your public key into the authorized_keys file (and authorized_keys2)
ssh-keygen -i -f [your_key_name.pub] >> .ssh/authorized_keys && ssh-keygen -i -f [your_key_name.pub] >> .ssh/authorized_keys2
Replace [your_key_name.pub] with the path to your key. Now log out and start PuTTY.
In Putty, you have to configure the following items:
In Connection/Data, add your remote user name
In Connection/SSH/Auth, browse to your private key file (.ppk)
In Sessions, fill in the FQDN or IP address of your remote machine, give your session a name [session_name] and click on Save.
Now you can use putty to SSH into your remote boxes with out a password. If you are a fan of having one or two click shortcuts create a shortcut to %windir%\putty.exe -load [session_name]. If you gave your [session_name] a name with spaces use double quotes to encase it like putty.exe -load "session name".
Friday, December 26, 2008
Adding a Virtual Host to Apache2 based on Name in CentOS 5
Well today I was setting up our new web development server and I wanted to use Host / Name based virtual hosts in apache, instead of the previous use of ports.
Much to my amazment this one is really simple.
Make sure to uncomment or add in:
NameVirtualHost *:80
Since I don't want to add multple IP's to the server and I always want to use port 80 (The default for http).
Then I added
<VirtualHost *:80>
ServerName scorpio.mydomain.local
ServerAlias scorpio
DocumentRoot "/var/www/html"
ServerPath /html/
DirectoryIndex index.php index.htm
</VirtualHost>
<VirtualHost *:80>
ServerName dev.mydomain.local
ServerAlias www.mydowmain.local mydomain.local
DocumentRoot "/var/www/html"
ServerPath /html/
DirectoryIndex index.php index.htm
</VirtualHost>
<VirtualHost *:80>
ServerName dev.myotherdomain.local
ServerAlias www.myotherdowmain.local myotherdomain.local
DocumentRoot "/var/www/html"
ServerPath /html/
DirectoryIndex index.php index.htm
</VirtualHost>
<VirtualHost *:80>
ServerName dev.mythirddomain.local
ServerAlias www.mythirddowmain.local mythirddomain.local
DocumentRoot "/var/www/html"
ServerPath /html/
DirectoryIndex index.php index.htm
</VirtualHost>
When it was all said and done this was pretty easy. Not as easy as doing the same thing in IIS in my opinion but still very easy. I could have tried this with Webmin but I did this all using vi from the CLI.
Friday, November 14, 2008
Adding a Virtual Host to Apache2 based on Port
Today I had to setup an internal testbed server for one of our websites. I didn't want to create a new host name for the site on our Apache server so I went with port based virtual hosts.
There are a few things you need to add for this to work. My first attempt to make this happed in Webmin didn't produce the results I wanted, so I turned to my trusty text editor vi.
vi /etc/httpd/conf/httpd.conf
Now I had to add in a line similar to:
Listen 8080
Also you have to tell apache to use name based virtual hosting. So add in the line:
NameVirtualHost *:8080
Then finally you can create the directives for your virtual host.
DocumentRoot /your/path/here
ServerName 1.2.3.4:8080
Wednesday, August 13, 2008
yum install imagemagick
Today's blog is going to be quick.
For those linux users out there that don't have imagemagick already installed the correct syntax is:
yum install ImageMagick
NOT yum install imagemagick
To find out if you already have imagemagick just type convert -version from the command line.
As it turns out I was trying to install something I already had thanks to CentOS.
For those linux users out there that don't have imagemagick already installed the correct syntax is:
yum install ImageMagick
NOT yum install imagemagick
To find out if you already have imagemagick just type convert -version from the command line.
As it turns out I was trying to install something I already had thanks to CentOS.
Tuesday, August 12, 2008
Clonezilla
I have seen Symantec Ghost used in the past. I have always wanted a scenario where using something like Ghost would make sense and today I have found it!
We have a great many machines here that are identical. They do the same function, have the same hardware, and need the same software. That being said I have finally found a reason to really need a solution like Symantec Ghost. Now being on a very tight budget I was looking for a different solution and thanks to the generous folks over on the Spiceworks fourms I found Clonezilla.
Now there is a server based version that I could use to Clonecast (I don't know if that is a real word or even something they use but I like it) images out to machines, but for now I am booting off of my 2GB USB key and saving / reading images from a seperate 160GB USB drive.
It takes about 15 to 20 minutes do drop an image from the USB-Hard drive to the client machine (for around 1GB of info). It takes just around as long do put the image on the USB-HDD which is very quick if you ask me. Most of the time is getting the computer to boot off of the USB key and configure the options you want.
One of my projects that I hope to do later is to install the NTFS 3g drivers for Linux so I can modify the file system once the image is installed. This will enable me to do things like rename the PC based on it's MAC address. Also I may get a Clonezilla server up and running. If I do you can be sure I will post something about it.
We have a great many machines here that are identical. They do the same function, have the same hardware, and need the same software. That being said I have finally found a reason to really need a solution like Symantec Ghost. Now being on a very tight budget I was looking for a different solution and thanks to the generous folks over on the Spiceworks fourms I found Clonezilla.
Now there is a server based version that I could use to Clonecast (I don't know if that is a real word or even something they use but I like it) images out to machines, but for now I am booting off of my 2GB USB key and saving / reading images from a seperate 160GB USB drive.
It takes about 15 to 20 minutes do drop an image from the USB-Hard drive to the client machine (for around 1GB of info). It takes just around as long do put the image on the USB-HDD which is very quick if you ask me. Most of the time is getting the computer to boot off of the USB key and configure the options you want.
One of my projects that I hope to do later is to install the NTFS 3g drivers for Linux so I can modify the file system once the image is installed. This will enable me to do things like rename the PC based on it's MAC address. Also I may get a Clonezilla server up and running. If I do you can be sure I will post something about it.
Thursday, May 24, 2007
How to Use Nslookup to Verify MX record configuration
As I have been installing, configuring, and testing our Microsoft Exchange Server 2007 I have had to test the DNS system to ensure our domain is registared and working properly. This is something that all system administrators should know how to do, but the exact syntax is often forgotten.
- Open a Command Prompt (Start, Run, cmd, [Enter])
- Type nslookup.
- Server
(The DNS server that you want to use. This is optional.) - Set q=mx (This sets the query type to "MX" {Mail Exchanger}.)
(The domain name you want to lookup the mail exchanger to.)
This operation can be done on Windows XP, Windows Server 2003, and Windows Vista. There are similar options if you are doing this from Linux.
- Open up a terminal (Differs by distribution)
- Type nslookup.
- Set type=mx (This sets the query type to "MX" {Mail Exchanger}.)
(The domain name you want to lookup the mail exchanger to.)
Subscribe to:
Posts (Atom)