Sunday, October 2, 2011

Mysql Optimize Configuration

# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
#
# Take care to only add/remove/change a setting if you are comfortable
# doing so! For Rackspace customers, if you have any questions or
# concerns, please contact the MySQL Database Services Team. Be aware
# that some work performed by this team can involve additional billable
# fees.
#
# This file generated for host Boodhii please modify
# variables if the server is resized from 4194304kB

[mysqld]

### General
user = mysql
port = 3306
datadir = /var/lib/mysql
tmpdir = /var/lib/mysqltmp
socket = /var/lib/mysql/mysql.sock
skip-external-locking = 1

## This prevents using host-based authentication. That means users must be
## created using an ip-address (ie 'myuser'@'192.168.100.1') or must make
## use of the % wildcard (ie 'myuser'@'%'). The benefit to not using
## host-based authentication is that DNS will not impact MySQL performance.
#skip-name-resolve

## If open-files-limit is set very low, MySQL may increase on its own. Either
## way, increase this if MySQL gives 'too many open files' errors. Setting
## this above 65535 could be unwise (MySQL may crash).
open-files-limit = 20000

## Set this to change the way MySQL handles validation, data conversion, etc.
## Be careful with this setting as it can cause unexpected results and
## horribly break some applications! Note, too, that it can be set per-session
## and can be hard set in stored procedures.
#sql-mode = TRADITIONAL

#event-scheduler = 1

### Cache
thread-cache-size = 16
table-open-cache = 2048
table-definition-cache = 512

## Generally, it is unwise to set the query cache to be larger than 64-128M
## as the costs associated with maintaining the cache outweigh the performance
## gains. A far superior solution would be to implement memcached, though this
## required modifying the application, among other things.
query-cache-size = 32M
query-cache-limit = 1M

### Per-thread Buffers
sort-buffer-size = 1M
read-buffer-size = 1M
read-rnd-buffer-size = 8M
join-buffer-size = 1M

### Temp Tables
tmp-table-size = 64M
max-heap-table-size = 64M

### Networking
back-log = 100
max-connections = 200
max-connect-errors = 10000
max-allowed-packet = 16M
interactive-timeout = 600
wait-timeout = 180
net_read_timeout = 30
net_write_timeout = 30
# This value is the size of the listen queue for incoming TCP/IP connections.
back_log = 128

#### Storage Engines
## Set this to force MySQL to use a particular engine / table-type
## for new tables. This setting can still be overridden by specifying
## the engine explicitly in the CREATE TABLE statement.
#default-storage-engine = InnoDB

## Makes sure MySQL does not start if InnoDB fails to start. This helps
## prevent ugly silent failures.
innodb = FORCE

### MyISAM
## Not sure what to set this to?
## Try running a 'du -sch /var/lib/mysql/*/*.MYI'
## This will give you a good estimate on the size of all the MyISAM indexes.
## (The buffer may not need to set that high, however)
key-buffer-size = 64M
## This setting controls the size of the buffer that is allocated when
## sorting MyISAM indexes during a REPAIR TABLE or when creating indexes
## with CREATE INDEX or ALTER TABLE.
myisam-sort-buffer-size = 128M

### InnoDB
## Note: While most settings in MySQL can be set at run-time, many InnoDB
## variables cannot be set at runtime as require restarting MySQL
###
## These settings control how much RAM InnoDB will use. Generally, when using
## mostly InnoDB tables, the innodb-buffer-pool-size should be as large as
## is possible without swapping or starving other processes of RAM. The other
## two settings usually do not need to be changed, but can help for very large
## datasets.
innodb-buffer-pool-size = 16M
innodb-log-buffer-size = 4M
#innodb-additional-mem-pool-size= 20M

## This can help, but can also hinder performance. Test appropriately!
## (For SAN, O_DIRECT is almost never a good idea)
#innodb-flush-method = O_DIRECT

## innodb-file-per-table can offer quite a few advantages, but does not work
## well when using it with a very large number of tables.
## If innodb-file-per-table is used, be sure to set innodb-open-files
## appropriately (which is roughly similar to open-files-limit, but is
## exclusive to InnoDB)
#innodb-file-per-table = 1
#innodb-open-files = 300

## If you are not sure what to set this to, the following formula can offer
## up a rough idea:
## (number of cpus * number of disks * 2)
#innodb-thread-concurrency = 16

## This can increase performance for single servers as disabling this enabled
## group-commit. This is not a viable option when using binary logging or
## replication, however.
#innodb-support-xa = 0

## Be careful when changing these as they require re-generating the
## ib-logfile* files, which must be done carefully. Do not change this unless
## you are familiar with the procedure.
#innodb-log-file-size = 100M
#innodb-log-group-home-dir = /var/lib/mysql
innodb-log-files-in-group = 2

## You cannot change this without dumping out the data and re-importing it!
#innodb-data-file-path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb-data-home-dir = /var/lib/mysql

### Replication

## Tired of running into replication errors due to having the same server
## id on two servers? Consider changing this variable to the Rackspace
## server number.
server-id = 1

## This sets the format used when logging to the binary log
## - ROW will force row-based logging
## - STATEMENT will force statement-based (ie pre 5.1) logging
## - MIXED wil use both, depending on the situation
## Note that this setting has implications for both replication and
## backups, so do not change this unless you know what you are doing!
#binlog-format = STATEMENT

#log-bin = /var/lib/mysqllogs/bin-log
#relay-log = /var/lib/mysqllogs/relay-log
#relay-log-space-limit = 4G
#expire-logs-days = 14

## This should be enabled on conventional MySQL slaves
#read-only = 1

## Enable this to make replication more resilient against server
## crashes and restarts, at the expense of higher I/O on the server.
#sync-binlog = 1

## This is usually only needed when setting up chained replication.
#log-slave-updates = 1

## Uncomment the following when enabling multi-master replication
## Do NOT uncomment these unless you know exactly what you are doing!
#auto-increment-offset = 1
#auto-increment-increment = 2

### Logging
## This option determines the destination for general query log and slow query log output.
## The option value can be given as one or more of the words TABLE, FILE, or NONE.
## NOTE: Table logging takes away 50% of performance and thus is not recommended
## http://bugs.mysql.com/bug.php?id=30414
## In addition, you cannot backup the contents of these tables properly
## (mysqldump skips these tables by default since they cannot be locked)
#log-output = FILE
#slow-query-log = 1
#slow-query-log-file = /var/lib/mysqllogs/slow-log
#long-query-time = 2
#log-queries-not-using-indexes = 1

[mysqld-safe]
log-error = /var/log/mysqld.log

[mysqldump]
max-allowed-packet = 16M

# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/sysconfig/mysqld-config/


http://everythingmysql.ning.com/profiles/blogs/using-tmpfs-for-mysqls-tmpdir

I would like to talk about not "why" MySQL does this but how to speed up the performance when MySQL internally or users create temporary tables to disk. A great solution is TMPFS, a quick how to is as follows:

-- Before you start
1. Make sure you allocate enough space to TMPFS
-- 2GB is usually safe but if you are using larger data sets with inefficient queries then there are far worse performance issues to deal with.

-- The safe way to implement TMPFS for MySQL
shell> mkdir /tmp/mysqltmp
shell> chown mysql:mysql /tmp/mysqltmp
shell> id mysql
##NOTE: make sure you get the uid and gid for mysql
shell> vi /etc/fstab
## make sure this in in your fstab
tmpfs /tmp/mysqltmp tmpfs rw,uid=25,gid=26,size=2G,nr_inodes=10k,mode=0700 0 0
shell> mount /tmp/mysqltmp
shell> vi /etc/my.cnf #or the mysql config file for your server
## NOTE: inside the file add the following under [mysqld]
tmpdir=/tmp/mysqltmp/
shell> service mysql restart

How to Set time & timezone in mysql

SELECT CURRENT_TIMESTAMP;

SET GLOBAL time_zone = '-5:00';

 

Apache Optimize Configuration

ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5


StartServers 4
MinSpareServers 9
MaxSpareServers 18
ServerLimit 279
MaxClients 279
MaxRequestsPerChild 1000



StartServers 4
MaxClients 1024
MinSpareThreads 64
MaxSpareThreads 192
ThreadsPerChild 64
MaxRequestsPerChild 0


Include /etc/httpd/ports.conf
ServerAdmin root@localhost
UseCanonicalName Off
DocumentRoot "/var/www/html"

Options -Indexes FollowSymLinks
AllowOverride All
DirectoryIndex index.php default.php index.html index.htm index.shtml index.php4 index.php3 index.phtml index.cgi
AccessFileName .htaccess
TypesConfig /etc/mime.types
HostnameLookups Off
ErrorLog /var/log/httpd/error_log
Redirect permanent /foo http://www.example.com/bar
Include vhost.d/*.conf

Securites.conf

ServerTokens Prod
ServerSignature Off
TraceEnable Off

ports.conf

Listen 80
NameVirtualHost *:80

Listen 443
NameVirtualHost *:443

vhost/servername.conf


ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/vhosts/example.com

Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php default.php index.html index.htm index.shtml index.php4 index.php3 index.phtml index.cgi


CustomLog /var/log/httpd/example.com-access.log combined
ErrorLog /var/log/httpd/example.com-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn





ServerName example.com
DocumentRoot /var/www/vhosts/example.com

Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php default.php index.html index.htm index.shtml index.php4 index.php3 index.phtml index.cgi


CustomLog /var/log/httpd/example.com-ssl-access.log combined
ErrorLog /var/log/httpd/example.com-ssl-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key


SSLOptions +StdEnvVars


BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
Monday, September 5, 2011

Hardisk Partion Create



Q. I've installed a new 250GB SATA hard disk on our office CentOS Linux server. How do I format a hard disk under Linux operating system from a shell prompt?



A.. There are total 4 steps involved for hard disk upgrade and installation procedure:


Step #1 : Partition the new disk using fdisk command


Following command will list all detected hard disks:

# fdisk -l | grep '^Disk'

Output:


Disk /dev/sda: 251.0 GB, 251000193024 bytes
Disk /dev/sdb: 251.0 GB, 251000193024 bytes

A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.

To partition the disk - /dev/sdb, enter:

# fdisk /dev/sdb

The basic fdisk commands you need are:



  • m - print help

  • p - print the partition table

  • n - create a new partition

  • d - delete a partition

  • q - quit without saving changes

  • w - write the new partition table and exit


Step#2 : Format the new disk using mkfs.ext3 command


To format Linux partitions using ext2fs on the new disk:

# mkfs.ext3 /dev/sdb1


Step#3 : Mount the new disk using mount command


First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:

# mkdir /disk1

# mount /dev/sdb1 /disk1

# df -H


Step#4 : Update /etc/fstab file


Open /etc/fstab file, enter:

# vi /etc/fstab

Append as follows:


/dev/sdb1               /disk1           ext3    defaults        1 2

Save and close the file.


Task: Label the partition


You can label the partition using e2label. For example, if you want to label the new partition /backup, enter

# e2label /dev/sdb1 /backup

You can use label name insted of partition name to mount disk using /etc/fstab:

LABEL=/backup /disk1 ext3 defaults 1 2


Featured Articles:



Monday, August 22, 2011

Difference between TCP and UDP

TCPUDP
Reliability: TCP is connection-oriented protocol. When a file or message send it will get delivered unless connections fails. If connection lost, the server will request the lost part. There is no corruption while transferring a message.Reliability: UDP is connectionless protocol. When you a send a data or message, you don't know if it'll get there, it could get lost on the way. There may be corruption while transferring a message.
Ordered: If you send two messages along a connection, one after the other, you know the first message will get there first. You don't have to worry about data arriving in the wrong order.Ordered: If you send two messages out, you don't know what order they'll arrive in i.e. no ordered
Heavyweight: - when the low level parts of the TCP "stream" arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together.Lightweight: No ordering of messages, no tracking connections, etc. It's just fire and forget! This means it's a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.
Streaming: Data is read as a "stream," with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call.Datagrams: Packets are sent individually and are guaranteed to be whole if they arrive. One packet per one read call.
Examples: World Wide Web (Apache TCP port 80), e-mail (SMTP TCP port 25 Postfix MTA), File Transfer Protocol (FTP port 21) and Secure Shell (OpenSSH port 22) etc.Examples: Domain Name System (DNS UDP port 53), streaming media applications such as IPTV or movies, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and online multiplayer games etc













Thursday, July 28, 2011

About Swap Space

Adding Swap Space
Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system from 128 MB to 256 MB, but there is only 256 MB of swap space. It might be advantageous to increase the amount of swap space to 512 MB if you perform memory-intense operations or run applications that require a large amount of memory.
You have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM2 logical volume. It is recommended that you extend an existing logical volume.

Extending Swap on an LVM2 Logical Volume
To extend an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend):
1. Disable swapping for the associated logical volume:
2. # swapoff -v /dev/VolGroup00/LogVol01
3. Resize the LVM2 logical volume by 256 MB:
4. # lvm lvresize /dev/VolGroup00/LogVol01 -L +256M
5. Format the new swap space:
6. # mkswap /dev/VolGroup00/LogVol01
7. Enable the extended logical volume:
8. # swapon -va
9. Test that the logical volume has been extended properly:
10. # cat /proc/swaps # free

Creating an LVM2 Logical Volume for Swap
To add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to add):
1. Create the LVM2 logical volume of size 256 MB:
2. # lvm lvcreate VolGroup00 -n LogVol02 -L 256M
3. Format the new swap space:
4. # mkswap /dev/VolGroup00/LogVol02
5. Add the following entry to the /etc/fstab file:
6. /dev/VolGroup00/LogVol02 swap swap defaults 0 0
7. Enable the extended logical volume:
8. # swapon -va
9. Test that the logical volume has been extended properly:
10. # cat /proc/swaps # free

Creating a Swap File
To add a swap file:
1. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
2. At a shell prompt as root, type the following command with count being equal to the desired block size:
3. dd if=/dev/zero of=/swapfile bs=1024 count=65536
4. Setup the swap file with the command:
5. mkswap /swapfile
6. To enable the swap file immediately but not automatically at boot time:
7. swapon /swapfile
8. To enable it at boot time, edit /etc/fstab to include the following entry:
9. /swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.
10. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

Removing Swap Space

Sometimes it can be prudent to reduce swap space after installation. For example, say you downgraded the amount of RAM in your system from 1 GB to 512 MB, but there is 2 GB of swap space still assigned. It might be advantageous to reduce the amount of swap space to 1 GB, since the larger 2 GB could be wasting disk space.
You have three options: remove an entire LVM2 logical volume used for swap, remove a swap file, or reduce swap space on an existing LVM2 logical volume.

Reducing Swap on an LVM2 Logical Volume
To reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend):
1. Disable swapping for the associated logical volume:
2. # swapoff -v /dev/VolGroup00/LogVol01
3. Reduce the LVM2 logical volume by 512 MB:
4. # lvm lvreduce /dev/VolGroup00/LogVol01 -L -512M
5. Format the new swap space:
6. # mkswap /dev/VolGroup00/LogVol01
7. Enable the extended logical volume:
8. # swapon -va
9. Test that the logical volume has been reduced properly:
10. # cat /proc/swaps # free

Removing an LVM2 Logical Volume for Swap
The swap logical volume cannot be in use (no system locks or processes on the volume). The easiest way to achieve this it to boot your system in rescue mode. Refer to for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.
To remove a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to remove):
1. Disable swapping for the associated logical volume:
2. # swapoff -v /dev/VolGroup00/LogVol02
3. Remove the LVM2 logical volume of size 512 MB:
4. # lvm lvremove /dev/VolGroup00/LogVol02
5. Remove the following entry from the /etc/fstab file:
6. /dev/VolGroup00/LogVol02 swap swap defaults 0 0
7. Test that the logical volume has been extended properly:
8. # cat /proc/swaps # free

Removing a Swap File
To remove a swap file:
1. At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file):
2. # swapoff -v /swapfile
3. Remove its entry from the /etc/fstab file.
4. Remove the actual file:
5. # rm /swapfile
Step 1:
First, log into the server via SSH.
Step 2:
df -h

Step 3:
Next, type fdisk -l to view the total hard disk(s) size and partitions on the disk. It can also be noticed here that the physical partition /dev/sda3 is using Linux LVM.

fdisk -l
Step 4:
Type the pvs command and press Enter.

Note: If the PSize value listed will often be bit smaller than the value listed by the fdisk command output. If the difference in size between the fdisk output and PSize is more than 100GB, please reference What if my physical volume size has not changed after increasing disk space? before continuing.

Further Explanation:
pvs arrow image Physical Volume Show command.
PV arrow image Physical Volume path
VG arrow image Volume Group name.
Fmt arrow image LVM Format
Attr arrow image Physical volume attributes. The a attribute means that the physical volume is allocatable and not read-only.
PSize arrow image Physical Size of the physical volume.
PFree arrow image Physical Free space left on the physical volume.


Step 5:
As stated above, our scenario requires roughly 9GB of data to be uploaded to the /var folder. Since the logical volume assigned to /var is only 4GB, we will increase this to 10GB using the lvextend command. The command below is to be used as reference only as the parameters will be different depending on your scenario.

The format for the lvextend command is as follows:
lvextend -L +6G /dev/mapper/vg00-var

Further Explaination:
lvextend arrow image This is the logical volume extend command used to make a logical volume larger.
-L +6G arrow image It is specified using the Logical volume size option, how much larger to make the volume. In this scenario, 6 gigabytes is added to the current 4 gigabyte volume to result in a 10 gigabyte volume.
/dev/mapper/vg00-var arrow image The path to the logical volume is specified last. The path to the volume to be extended was taken from the output from the second step in this guide.


Step 6:
Type df -h to display the disk free space once again. The lvextend operation finished successfully in the last step however the /dev/mapper/vg00-var size is still only showing 4.0G. This is because while the logical volume was increased successfully, the file system needs to be extended to take advantage of the full space of the logical volume.

Step 7:
Type lvs to show the logical volume information once again. Here, we can confirm that the logical volume has successfully been extended to 10 gigabytes. In the next steps, we will increase the file system to match the logical volume size.

Step 8:
Type mount and press ENTER to display the mounted file systems. From the output, we find that the /dev/mapper/vg00-var logical volume is using xfs.


Step 9:
To increase the file system to match that of the logical volume, we will use the xfs_growfs command.

Typing xfs_growfs /var will extend the file system to the 10 gigabyte limit of the logical volume.

Step 10:
Type df -h to display the disk free space to confirm that the file system has been extended.
Friday, July 22, 2011

SVN Delete option

Windows SVN Delete Option.

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

Linux SVN Delete option.

rm -rf `find . -type d -name .svn`
Tuesday, July 5, 2011

Configured SVN with http & https

yum install mod_dav_svn.i386


After installation we'll have to ensure that mod_dav_svn module was properly installed on apache.

LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so

We have apache with mod_dav_svn module installed properly. At this point we can create a repository. This will help us to test our instalation:

root# mkdir /var/www/svn
root# mkdir /var/www/svn/repos
root# svnadmin create /usr/home/svn/repos/test

Then we have to create the files that are going to be used to authenticate the users.

root# mkdir /var/www/svn/access
root# cd /var/www/svn/access
root# htpasswd -cm users root
password:****
root# htpasswd -m users viewer
password:*****

For add new user htpasswd -m users username

root# vi control

[test:/] repo name
root = rw
viewer = r
[test:/trunk] permission for trunk only
santosh = rw

[voip:/] repo name
arun = rw
ajay = r
santosh = rw



Now we will configure apache to read the repositories:

root# vi /etc/httpd/conf.d/subversion.conf


DAV svn
SVNParentPath /var/www/svn/repos
# SVNIndexXSLT "http://venus.idhasoft.com/svnindex.xsl"
AuthzSVNAccessFile /var/www/svn/access/control

# # Limit write permission to list of valid users.
#
# # Require SSL connection for password protection.
SSLRequireSSL
#
Satisfy Any
AuthType Basic
AuthName "Subversion Repositories at venus.idhasoft.com"
AuthUserFile /var/www/svn/access/users
Require valid-user
#



Apache will read all the files that are under the Includes directory, so our svn.conf will be loaded when apache starts, note that we are loading svnindex.xsl that is the file where the transformations are done, if you would like to give to your repository some look and feel work these file will be the appropiate. The file skeletons are under /usr/local/share/subversion/xslt/ directory, there are two files, one .xsl and another .css. Copy these files to your document root. I have a virtual server called svn.example.com in my machine. I have all my virtual servers under /usr/local/www/pages, so I have svn.example.com directory and I've configured that virtual server in /usr/local/etc/apache2/httpd.conf.

NameVirtualHost *:80

ServerAdmin ecruz@example.com
ServerName svn.example.com
DocumentRoot /usr/local/www/pages/svn.example.com
CustomLog /var/log/svn.example.com-access_log common


Restart the web server:

/etc/init.d/httpd restart
Thursday, June 30, 2011

no-reply email id configuration

Add User no-reply
passwd no-reply

vi /home/no-reply/autoreply
This email address is not active. To get in touch with domain name please write to us at info@domain name.

vi /etc/aliases (end need to write)
###Add by User Name ########
no-reply: "|/usr/libexec/webmin/postfix/autoreply.pl /home/no-reply/autoreply no-reply"

chmod -Rv 777 /home/no-reply/autoreply

For Email Forword option activation

vi /etc/postfix/virtual
user@domain name personal email id1,personal email id2
Tuesday, May 3, 2011

How to install RED5 on linux

Installing Red5 on SUSE (and other) Linux

This howto was provided by Jake Hilton. If you see any errors please let him know so that they can be corrected. These instructions are generic enough to work on many different linux operating systems.

The following steps will install the development (trunk) version of red5.

Before beginning this make sure you are running these commands as root.

1.
You can create a red5 user to run this under if you don't plan on using any ports below 1000. If you need red5 to bind to ports below 1000 you need to run it as root. With the red5 user disallow login access and make the red5 user part of the root group.
2.
Make sure you have downloaded and installed the latest JDK from java.sun.com
*
For this tutorial just download the .bin file. All you need to do is change the permissions of that bin file to 755 with

chmod 755 jdk-1_6_0

and then execute it.

./jdk-1_6_0

or something similar. Then once it’s done you just copy the contents of the folder it made and put them in /usr/java/jdk1.6.0
*
Then set your JAVA_HOME variable. It may have to be set two different ways. First way:

JAVA_HOME=/usr/java/jdk1.6.0

and the second way.

export JAVA_HOME=’/usr/java/jdk1.6.0′

3.
Install Apache Ant 1.7. You may have to download that as well. Install the binary for it.
*
Download and unzip the file. Then copy the contents to a directory, something like /usr/ant. Then set your ANT_HOME variable. If it doesn't work then don't worry about it. We will not be using that pointer in this tutorial.
4.
Once java and ant are all set up you simply pull the latest trunk for red5 to your box.

svn co http://red5.googlecode.com/svn/java/server/trunk red5-trunk

That will create a folder in your current directory called red5-trunk.
5.
Navigate to the red5-trunk directory and run

/usr/ant/bin/ant

That will build the project on your machine.
6.
At this point you will need to create a red5 directory in the opt directory.

mkdir /opt/red5

7.
Then you will want to copy the contents of the dist(distribution) folder to /opt/red5 like so

cp -R red5-trunk/dist/* /opt/red5/

8.
We need to fix the permissions on the /opt/red5 directory like so:

chown -R red5 /opt/red5

9.
In addition we need need to fix the permissions on the red5.sh file like so:

chmod 755 red5.sh

10.
To run the server you have a few options using the red5.sh file. Navigate to /opt/red5 to make sure you are in the proper location. Then run the server by either running

sh red5.sh &

or

./red5.sh &

. This will start the red5 service manually. For a start and stop script look at the “Extra info” below.
11.
Run

netstat -ant

and verify the correct ports are being bound to. You may need to edit the red5.properties file in the /opt/red5/conf directory if you can’t connect to your server from an external location. Try to connect to the server before you modify the properties file because you may be able to connect to it with no problems.
12.
Extra info: The version compiled from source does not come with a start/stop script. I have put together one that will work with this how-to. If you run red5 as a different user this script will have to be tweaked. To put this script on your system do the following logged in as root:

cd /etc/init.d/
touch red5
chmod 755 red5
vi red5

then when you are in the red5 file push “i” to start inserting into that file and then put this code in by copying it and then pasting it with a right click of the mouse:

#! /bin/sh
#
# Author: Jake Hilton
# /etc/init.d/red5
#
# Check for missing file
RED5_DIR=/opt/red5
test -x $RED5_DIR/red5.sh || exit 5

case "$1" in
start)
echo -n "Starting Red5 Service"
echo -n " "
cd $RED5_DIR
su -s /bin/bash -c "$RED5_DIR/red5.sh &" red5
sleep 2
;;
stop)
echo -n "Shutting down red5"
echo -n " "
su -s /bin/bash -c "killall -q -u red5 java" red5
sleep 2
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
esac

Then you can simply start, stop, and restart red5 from that script by typing:

/etc/init.d/red5 start
/etc/init.d/red5 stop
/etc/init.d/red5 restart


http://0.0.0.0:5080/

How To add user and root group

gpasswd -a username groupname

gpasswd -a arun root
Thursday, April 21, 2011

How to reset forgot MAC root password

1. boot computer and hold the "apple" key and the "s" key.
2. wait for terminal show
3. release keys
4. type without the quotes: "/sbin/mount -uaw"
5. press enter
6. type without the quotes: "rm /var/db/.applesetupdone
7. press enter
8. type without the quotes: "reboot"
9. press enter

this will let you create a new admin account when you reboot your computer.
Tuesday, April 5, 2011

How to incress swap file size of linux server

dd if=/dev/zero of=/temp/swapfile1 bs=1024 count=6000000 6000000 GB

/sbin/mkswap /temp/swapfile1

/sbin/swapon /temp/swapfile1

/temp/swapfile1 swap swap defaults 0 0


Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:
# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab

Append following line:
/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?
Simply use free command:
$ free -m
Monday, March 14, 2011

How to remove Exchange

http://support.microsoft.com/kb/833396

http://support.microsoft.com/kb/310516
Thursday, March 10, 2011

Amazon Internal Network Access via Private IP

You will need to add the following rule to your security group to enable ICMP traffic to the host

Protocol : ICMP
From Port : -1
To Port : -1
Source ( IP or group ) : IP_address/32 ( Change the IP_address to be the IP you want to allow traffic from )

For SAMBA you will need to add rules for the following ports
Port 135/TCP, Port 137/UDP, Port 138/UDP, Port 139/TCP, Port 445/TCP
Monday, February 14, 2011

Ffmpeg installtion

FFmpeg (http://ffmpeg.mplayerhq.hu)
Mplayer + Mencoder (http://www.mplayerhq.hu/design7/dload.html)
Flv2tool (http://inlet-media.de/flvtool2)
Libogg + Libvorbis (http://www.xiph.org/downloads)
LAME MP3 Encoder (http://lame.sourceforge.net)
FlowPlayer - A Free Flash Video Player - http://flowplayer.org/
Installing FFMpeg

yum install ffmpeg ffmpeg-devel

If you get package not found, then you will need to add few lines in the yum repository for dag packages installation. Create a file named dag.repo in /etc/yum.repos.d with the following contents on it

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

then

yum install ffmpeg ffmpeg-devel

If everything is fine, then the installation should proceed smoothly. If not you will get something like warning GPG public key missing .
Common Errors

To fix rpmforge GPG key warning:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

For more information refer to this faq depending on Centos version

Missing Dependency Error:

If you get missing dependency error like shown below, in the middle of ffmpeg installation

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package ffmpeg
Error: Missing Dependency: libtheora.so.0(libtheora.so.1.0) is needed by package ffmpeg
Error: Missing Dependency: rtld(GNU_HASH) is needed by package ffmpeg
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package a52dec
Error: Missing Dependency: rtld(GNU_HASH) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package gsm
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package x264
Error: Missing Dependency: rtld(GNU_HASH) is needed by package xvidcore
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package lame
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package a52dec
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faad2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package x264
Error: Missing Dependency: rtld(GNU_HASH) is needed by package lame
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package xvidcore
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faac
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faad2
Error: Missing Dependency: libgif.so.4 is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faac
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package gsm
Error: Missing Dependency: libpng12.so.0(PNG12_0) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package libmp4v2
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package libmp4v2

then most commonly you have GLIB 2.3 installed instead of GLIB 2.4 version. To check the current GLIB version installed on your server. just use

yum list glib*

and it should list the latest GLIB package version.

The reason i was getting this error was my rpmforge packages was pointed to centos 5 versions instead of centos 4.6.

To fix dependency error:

To fix this error, you might need to check your rpmforge packages compatible to the release of your existing CentOS version.
Check the file /etc/yum.repos.d/rpmforge.repo and it should look like for Centos 4.6(Final). If you have lines like http://apt.sw.be/redhat/el5/en/mirrors-rpmforge you might need to make changes to the rpmforge.repos like shown below

Note: Backup the original rpmforge.repo file before you edit its content.

[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el4/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el4/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

To know what linux type and version you are running

cat /etc/redhat-release

Once this is done, do again yum install ffmpeg.

This trick resolved the problem in my linux box running Centos 4.6 and this is the only way i found to install ffmpeg using yum.
To check the FFmpeg working:

Finally, check the ffmpeg whether it is working or not.

> ffmpeg
> ffmpeg -formats
> ffmpeg --help
// This lists path of mpeg, its modules and other path information


ffmpeg -i Input.file Output.file
To check what audi/video formats are supported

ffmpeg -formats > ffmpeg-format.txt

Open the ffmpeg-formats.txt to see the ooutput

D means decode
E means encode
V means video
A means audio
T = Truncated
Thursday, February 3, 2011

Set Java path permant in linux

vi /root/.bash_profile


# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
export JAVA_HOME=/usr/java/jdk1.6.0_16
PATH=$PATH:/usr/java/jdk1.6.0_16


export PATH
unset USERNAME

Set Java path for all user

vi /etc/.bash_profile
Thursday, January 6, 2011

How to mount Linux LVM volume partitions on Linux

1) Once we were in live session, we opened a terminal and ran

[root]# fdisk -l

This lists out the partition table of the system and it looked something like this

Device Boot Start End Blocks Id System
/dev/sda1 * 1 4864 39070048+ 7 HPFS/NTFS
/dev/sda2 4865 6691 14675377+ 83 LVM2_member
...

2) The good news was that the system was at least able to distinguish the partitions. So, in order to backup the data, the next step was to access the /dev/sda2 partition. But since it is an lvm partition we will had to take some additional steps to mount it.

Now, run the pvs command. Please note that while in live session you may find that this is not installed by default. In order to install the required tools, run the following command.

[shredder12]$ sudo apt-get install lvm2

Of course, you should be connected to internet. Once you are done with this run pvs.

[root]# pvs

This will list the volume groups to which our physical volume /dev/sda2 belonged. It would be of the form

PV VG Fmt Attr PSize PFree
/dev/hda2 VolGroup01 lvm2 a- 148.94G 32.00M

The second field, VG, shows the Volume group. The above output is just an example, showing that we are concerned with the Volume group "VolGroup01". The next step is to list the information about this volume group.

[root]# lvdisplay /dev/VolGroup01

It will throw a bunch of ouput, but the one we are concerned with is LV Name. It will look something like this

LV Name /dev/VolGroup01/LogVol00

In our case, there were two entries of type LV Name, the other being LogVol01, the swap. The whole output along with it will help you to identify the target logical volume you are looking for. Assuming that the above one is the partition that we need to mount, just use the usual method to mount it.

[root]# mount /dev/VolGroup01/LogVol00 /mnt

Now, you can to find the data you were looking for in the /mnt folder.