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



 
 

How to create virtual user in ftp using "pure-pw" command

How to create virtual user for existing ftp share using "pure-pw" command

1. Login to the FTP Server
2. Execute the below command

#pure-pw useradd <username> -u ftpuser -d /ftpfolder/cssbt -N 1024

provide the password when prompted

3. Execute the below command to save the configuration

#pure-pw mkdb

Friday, 20 April 2012

How to create ldap user in Linux LDAP Server

Lets see how to create ldap user in Linux LDAP Server

Step 1: Create a local user account named <sl092467> in LDAP Server

#useradd sl092467

Step 2 : Note down the details of the user using passwd file

#cat /etc/passwd | grep sl092467               (note down uid, gid etc)

Step 3 : create a file named <raja> and enter as below

dn: uid=sl092467,ou=People,dc=csscorp,dc=com
uid: sl092467
cn: sl092467
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}$1$QLoEkVTC$RHrUQKYbqtRi4cfoPtusT.
shadowLastChange: 15027
shadowMin: 1
shadowMax: 90
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1014
gidNumber: 1014
homeDirectory: /home/sl092467

Step 4 : Save the file and execute the below command to add user sl092467 as ldap user

#ldapadd  -D "cn=Manager,dc=csscorp,dc=com"  -W -x  -f /home/venkat/ldap/raja

Step 5 : execute the below command to set ldap password for user sl092467

#ldappasswd -S -x -W -D "cn=Manager,dc=example,dc=com" "uid=sl092467,ou=People,dc=example,dc=com"

Enter ldap password for user and confirm the password. Then u will be prompted for ldap root password

Step 6 :  To add user sl092467 as a member of sladmin group. Open the <groupname>.ldif file

dn: cn=sladmin,ou=Group,dc=csscorp,dc=com
objectClass: posixGroup
objectClass: top
cn: sladmin
userPassword: {crypt}x
gidNumber: 1050
memberUid: sl000132
memberUid: sl005204
memberUid: sl005207
memberUid: sl005209
memberUid: sl005241
memberUid: sl005262
memberUid: sl007290
memberUid: sl088966
memberUid: sl089004
memberUid: sl005408
memberUid: css95891
memberUid: sl092467
memberUid: sl088735
memberUid: sl005539
memberUid: css05210

Step 7 : Add the user sl092467 as highlighted above and save the file

Step 8 : Execute the below command to add user sl092467 as member of sladmin group

#ldapmodify  -D "cn=Manager,dc=csscorp,dc=com"  -W -x  -f grp_modi.ldif

Step 9 : Login to linux server using ldap account credentials. when u login for the first time u will be prompted to change the password.







Thursday, 12 April 2012

How to Setup NFS in Linux Server

How to Setup NFS Server

Step 1: Install the following nfs packages in linux server
  •    nfs-utils
  •    libevent
# rpm -ivh nfs-utils-1.0.9-60.el5.x86_64.rpm libevent-1.4.13-1.x86_64.rpm

Step 2: Start the nfs and portmap service as mentioned below

# /etc/init.d/nfs start
# /etc/init.d/portmap restart

Step 3: Open the nfs file /etc/exports and enter details as below

# vim /etc/exports

/data   10.2.1.x(rw,no_root_squash) 10.2.1.x(rw,no_root_squash)

Step 4: Save the file and restart portmap and nfs service

How to Setup NFS Client:

Step 1: Login the server where u want to mount the nfs partition and start netfs and portmap service

# /etc/init.d/netfs start
# /etc/init.d/portmap start

Step 2: Open the fstab file and make an entry as below

# vim /etc/fstab
10.2.1.x:/data/dbbackup     /nfs          nfs               defaults               0 0

Step 3:  Save the file and restart netfs service

Step 4: execute mount command to mount the nfs partition

# mount -a

Step 5:  check whether the nfs partition is mounted using the below command

#df -h


http://www.cyberciti.biz/faq/centos-fedora-rhel-nfs-v4-configuration/


Tuesday, 10 April 2012

How to enable remote access to mysql database

Recently in one of the server mysql was running but in netstat output port was not listening due to which users are not able to connect database in the server.

But able to login to mysql prompt without any issues

Resolution:

Step 1: Login to the server using putty
Step 2: Edit my.cnf file

  • If you are using Debian Linux file is located at /etc/mysql/my.cnf location
  • If you are using Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
  • If you are using FreeBSD you need to create a file /var/db/mysql/my.cnf
#vi /etc/my.cnf

Step 3:  Make sure line skip-networking is commented (or remove line) and add following line

bind-address=YOUR-SERVER-IP
 
  • bind-address : IP address to bind to.
  • skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should be removed from my.cnf or put it in comment state.
Step 4: restart mysql service and check accessing remotely.