Thursday 20 September 2012

How to increase max connections in mysql

How to increase max connections in mysql, so that it can handle huge connections from applications.

By default in mysql database server max_connections is set to 100. This value indicates how many maximum concurrent connections mysql server can handle. If mysql reaches to it maximum (max) limit then you can see errors like "too many connections".

As we know my.cnf is default configuration file for mysqld service and by default it is located in /etc directory unless and until you have changed it.
To find out how many max_connections are allowed currently on your mysql server use following command from mysql prompt.
    mysql> select @@max_connections;
    +-------------------+
    | @@max_connections |
    +-------------------+
    | 100 |
    +-------------------+
    1 row in set (0.00 sec)
max_connections is a GLOBAL variable. we can increase it on the fly without restarting mysqld service.
To do so use following command.
    mysql> set global max_connections = 200;
    Query OK, 0 rows affected (0.00 sec)
Now, If you check again you will see that limit of max_connections is increased.
    mysql> select @@max_connections;
    +-------------------+
    | @@max_connections |
    +-------------------+
    | 200 |
    +-------------------+
    1 row in set (0.00 sec)

Tuesday 28 August 2012

How to make the linux server recognize the newly hot added Hard Disk

After adding the HDD to Linux Virtual machine while powered on, it will not automatically recognize it.

Hence please follow the below steps to make the linux server recognize the HDD

Step 1 : Login to the linux server as root user

Step 2 : Execute the below command to check whether HDD has been recognized by your server
              #fdisk -l

Step 3 : If not recognized then please execute the below command.
             # echo "- - -" > /sys/class/scsi_host/host0/scan

Step 4 : Now check (fdisk -l) to check whether it is recognized

How to backup database in Oracle Server 10.10.10.10

How to backup database in Oracle Server 10.10.10.10
Step 1 : Login to the oracle server as root in 10.10.10.10

Step 2 : Then switch over as oracle user using below command
                #su - oracle

Step 3 : Then set oracle_sid to use the respective database
               # export ORACLE_SID=citialps

Step 4 : Then check whether oracle home directory has been set as below
               #echo $ORACLE_HOME
                  /opt/ora9/product/9.2

Step 5 : Then use the below command to backup the database.

Note : make sure atleast 5 GB space is available in the server

            #exp testuat/testuat file=testuat280812.dmp full=yes

Monday 27 August 2012

How to mount NTFS partition ie USB HDD in linux server

Mounting NTFS Partition on RHEL 5.x/6.x

GCC Packages is must for Mounting NTFS.
After GCC installed

#yum -y install fuse fuse-ntfs-3g dkms dkms-fuse
 
if you are running xen kernel then only run this command

#yum install kernel-xen-devel

if you are running PAE kernel then only run this command
#yum install kernel-PAE-devel

Now Make Entry in your /etc/fstab file
make backup of your /etc/fstab by executing this command

#cp /etc/fstab /etc/fstab.bkp

now open your /etc/fstab file in your favorite editor

#vim /etc/fstab like below example
/dev/sda1          /mnt/ntfs      ntfs-3g      defaults       0  0


save & exit from file

#mount -t ntfs-3g /dev/<devicename> /<mountpoint>

 

 

 

Tuesday 14 August 2012

Input/Output error while mounting NFS Share

when u get below error while mounting nfs share

[root@ghrms ~]# mount -t nfs 10.2.1.74:/data/dbbackup/10.2.1.47 /nfs
mount.nfs: Input/output error


Please use the below option

[root@orione mnt]# mount -t nfs <ip address>:/mnt/backup/backup /zainetto/ -o nolock,udp

Thursday 19 July 2012

How to Implement mod_jk for web to app re-direction

mod_jk is used to redirect the requests which comes to port 80 to port 8080 or to tomcat

Step 1: wget http://apache.techartifact.com/mirror//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.37-src.tar.gz

Step 2: tar -zxvf tomcat-connectors-1.2.37-src.tar.gz

Step 3:cd tomcat-connectors-1.2.37-src

Step 4: cd native

Step 5: ./configure --with-apxs=/usr/sbin/apxs

Step 6: make

Step 7: cd apache-2.0/

Step 8: cp mod_jk.so /usr/lib64/httpd/modules/

Step 9: cd /etc/httpd/conf.d
vim mod_jk.conf

=====================================

LoadModule    jk_module  modules/mod_jk.so
    # Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
#    AddModule     mod_jk.c
    # Where to find workers.properties
    JkWorkersFile /etc/httpd/conf.d/workers.properties
    # Where to put jk shared memory
    JkShmFile     /var/log/httpd/mod_jk.shm
    # Where to put jk logs
    JkLogFile     /var/log/httpd/mod_jk.log
    # Set the jk log level [debug/error/info]
    JkLogLevel    info
    # Select the timestamp log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    # Send servlet for context /examples to worker named worker1
    #JkMount  /examples/servlet/* worker1
    # Send JSPs  for context /examples to worker named worker1
    #JkMount  /examples/*.jsp worker1
   JkMount /* node1
   JKOptions +DisableReuse
===================================

Step 10: vim /etc/httpd/conf.d/workers.properties

====================================
# Define list of workers that will be used
# for mapping requests
worker.list=node1

# Define Node1
worker.node1.port=8009
worker.node1.host= localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.local_worker=1 (1)
worker.node1.cachesize=10
===================================

Step 11:  /etc/init.d/httpd restart


How to implement Openssl for apache in linux

Step 1 : Generate a Private Key

The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request). It can also be used to generate self-signed certificates which can be used for testing purposes or internal usage.
The first step is to create your RSA Private Key.

#penssl genrsa -des3 -out server.key 2048

Step 2: Generate a CSR (Certificate Signing Request) 

Once the private key is generated a Certificate Signing Request can be generated. The CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate Authority, such as Thawte or Verisign who will verify the identity of the requestor and issue a signed certificate. The second option is to self-sign the CSR, which will be demonstrated in the next section.

#openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [GB]:CH
State or Province Name (full name) [Berkshire]:Bern
Locality Name (eg, city) [Newbury]:Oberdiessbach
Organization Name (eg, company) [My Company Ltd]:Akadia AG
Organizational Unit Name (eg, section) []:Information Technology
Common Name (eg, your name or your server's hostname) []:public.akadia.com
Email Address []:martin dot zahn at akadia dot ch
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

Step 3: Remove Passphrase from Key 

One unfortunate side-effect of the pass-phrased private key is that Apache will ask for the pass-phrase each time the web server is started. Obviously this is not necessarily convenient as someone will not always be around to type in the pass-phrase, such as after a reboot or crash. mod_ssl includes the ability to use an external program in place of the built-in pass-phrase dialog, however, this is not necessarily the most secure option either. It is possible to remove the Triple-DES encryption from the key, thereby no longer needing to type in a pass-phrase. If the private key is no longer encrypted, it is critical that this file only be readable by the root user! If your system is ever compromised and a third party obtains your unencrypted private key, the corresponding certificate will need to be revoked. With that being said, use the following command to remove the pass-phrase from the key:

#cp server.key server.key.org
#openssl rsa -in server.key.org -out server.key

Step 4: Generating a Self-Signed Certificate  

At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate. This temporary certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted.
To generate a temporary certificate which is good for 365 days, issue the following command:

#openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

 Step 5: Installing the Private Key and Certificate

When Apache with mod_ssl is installed, it creates several directories in the Apache config directory. The location of this directory will differ depending on how Apache was compiled. 

cp server.crt /etc/httpd/ssl/server.csr
cp server.key /usr/httpd/ssl/server.key


Step 6: Configuring SSL Enabled Virtual Hosts
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/server.crt
SSLCertificateKeyFile /etc/httpd/ssl/server.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog logs/ssl_request_log \
   "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

 or if there is ssl.conf under /etc/httpd/conf.d/ssl.conf then change the below 2 entry


SSLCertificateFile /etc/httpd/ssl/server.crt
SSLCertificateKeyFile /etc/httpd/ssl/server.key


Step 7: Restart Apache and Test
 
/etc/init.d/httpd stop
/etc/init.d/httpd stop