Search This Blog

Thursday, September 13, 2012

Windows Batch Script to Start, Stop and Restart a JAR file or JAVA Process


Windows Batch Script to Start, Stop and Restart a JAR file



To Start a JAR file using a batch script: 

echo Starting Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar


To Stop a running JAR file process using a batch script: 

echo Stopping Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq Your_JAR_File_Name"

Pause


To Restart a JAR file process using a batch script: 

@echo off
echo You are about to restart
Your_JAR_File_Name!

Pause

echo Stopping
Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq
Your_JAR_File_Name"

Pause

echo Starting
Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar

Tuesday, September 11, 2012

Configure NTP to synchronize the system clock in CENTOS/RHEL/FEDORA




CENTOS/RHEL/FEDORA: Configure NTP to synchronize the system clock


/* First install NTP on your system */
# yum install ntp

/* Now turn on NTP service */
# chkconfig ntpd on

/* synchronize your system clock with in.pool.ntp.org server */
# ntpdate  in.pool.ntp.org       //NTP server for India

/* Now start the NTP  Service*/
# /etc/init.d/ntpd start

/* Setting up a cronjob to sync automatically with NTP server every hour */
# crontab –e    // This will open a crontab file

/* Write the following line in the crontab file */
0 */1 * * * ntpdate  in.pool.ntp.org

/* Now save and close crontab file */



Saturday, September 8, 2012

How to access MySQL Server from outside




MySQL Server Remote Access

For accessing MySQL Server remotely from external network you to do port forwarding of SSH port 22 i.e. default port for SSH.

Step1: Edit /etc/my.cnf  
            # vi /etc/my.cnf
OR
# vi /opt/lamp/lamp/etc/my.cnf 
            Now locate file that read as :
            [mysqld]
            Make sure line skip-networking is commented and add the following line.
            bind-address= your-MySQlServer-IP (i.e. your system’s IP )

Step2: Save and close my.cnf file and restart mysql services.
            #service mysqld restart
OR
#/opt/lamp/lamp restart

Step3: Grant access to remote IP address:
            # mysql –u root –p “password for mysql”
            mysql> GRANT ALL ON *.* TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’;        

Note: In the above mysql query “*.*’”, first * is indicates all databases and second * indicates all tables. So, if you want give access to a particular database all tables then write this query.
mysql> GRANT ALL ON <Database 1>.* TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’;
Similarly for giving access to a particular table write the below query.
mysql> GRANT ALL ON <Database 1>.<table1> TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’; 
mysql> exit

From your remote system or your desktop type the following command:

$ mysql -u root –h 10.10.10.1 –p

Where,
§  -u is MySQL username
§  -h IP or hostname is MySQL server IP address or hostname
§  -p : Prompt for password

OR

  You can use SQLYog software to connect from remote location.





How to change default MySQL port in linux




How To Change Mysql Port In Linux

Open and Edit /etc/my.cnf  OR  /opt/lamp/lamp/etc/my.cnf  using your favourite editor.

# vi /etc/my.cnf
OR
# vi /opt/lamp/lamp/etc/my.cnf 

Now find the line Port=3306 (default MySQL port) and change it to :
Port= new port no.   // make sure this port is not used for other     services. (/etc/services)

The below is my system’s my.cnf  file:
[mysqld]
user       = root
port       = 3307
socket     = /opt/lampp/var/mysql/mysql.sock
skip-external-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M


Now save and close my.cnf file and restart MySQL services:
#service mysqld restart
OR
#/opt/lamp/lamp restart


How To Reset A Root Password



HOW TO RESET A ROOT PASSWORD


If you forget or lose your system’s root password, then do the following to reset it.

Entering recovery mode

While is system is starting up, hold down the ctrl key to see the boot loader menu. After you see the menu do the following:
 Ø  Use the arrow keys to select the boot entry you want to modify.
 Ø  Press ‘e’ to edit the menu.
 Ø  Use the arrow keys to go to kernel line.
 Ø  Press ‘a’ or ‘e’ to append this entry.
 Ø  At the end of the line add word ‘single’ or the number ‘1’.
 Ø  Press Enter to accept the changes.
 Ø  Press ‘b’ to boot this kernel.
Now you will be seeing a root prompt.
Now you can change your system’s root password.  As root, changing password doesn’t ask for your old password.
Run this command:
 root@localhost# passwd


Resetting password when boot loader is password protected

 Ø  Boot form the installed OS CD/DVD.
 Ø  Select “Rescue Installed System”
 Ø  Answer the prompt for language & keyboard.
 Ø  Let the rescue mode mount your file systems in the read/write mode.
 Ø  Press Enter to get the shell prompt.
 Ø  At the prompt, enter the following commands.
# chroot /mnt/sysimage
# passwd
# exit
# exit

Thursday, March 1, 2012

Steps to Install COLLABNET SUBVERSION EDGE on CENTOS / FEDORA/ RHEL Linux


Installing COLLABNET SUBVERSION EDGE on CENTOS 6.2 / FEDORA/ RHEL Linux

Requirements:-
1)    Java 1.6 JRE/JDK must be installed.
2)    Python 2.4 or higher version must be installed.
3)    Download CollabNetSubversionEdge-2.2.1_linux (32/64 bit)

Installation Notes:-
Note: Do not untar CollabNetSubversionEdge-2.2.1_linux package using root or sudo. 
This will cause the UID/GID on the files to carry the values from our build system instead 
of being reset.
 
1.      Install JAVA Runtime Environment package from Add/Remove Software 
(System>Administration>Add/Remove Software) by searching for Java/JRE.
                                                       
                                                 OR
# yum install java-1.6.0-openjdk.x86_64
 
2.      After Java installation is over, type the following command in Terminal window.
 
                   export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
 
And also add the above line to /etc/profile (at the bottom of the file)
 
#sudo gedit /etc/profile
 
OR
 
#sudo vi /etc/profile 
 
      Now you can check the installed java version by the following command.
      
      # java –version
        
        Probably this would be the output:
 
        java version "1.6.0_22"
         OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.42.1.10.4.el6_2-x86_64)
         OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)  
 
3.      Add any normal (non-root) user to etc/sudoers file or by the following command.
# visudo
And add the following line anywhere in the file.
username  ALL=(ALL)  ALL

4.      Now migrate to non-root (normal) user and select the folder where you want to install CollabNet Subversion Edge. I would recommend you to install the Subversion in the normal user folder. It can be Downloads/ Documents/ Desktop etc.
[root@localhost ]# su – username

[username@localhost]$ mkdir opt/subversion
Note: If you are not able to create folder “subversion” in “opt” directory, then you can create it through “root” or “sudo”.

[username@localhost]$ cd opt/subversion

[username@localhost]$ sudo chmod o+wx /opt/subversion/

Now move the downloaded CollabNetSubversionEdge-2.2.1-linux-x86_64.tar.gz package to opt/subversion.

5.      Now Untar the CollabNetSubversionEdge-2.2.1-linux-x86_64.tar.gz package by the following command.

[username@localhost subversion]$ tar zxf CollabNetSubversionEdge-2.2.1_linux-x86_64.tar.gz  
Note: The above command will create a folder named “csvn”.

[username@localhost subversion]$ cd csvn

Now we will install the application so that subversion will start automatically when the server restarts. For doing this type the following command.



Note: To set up the server so that it starts automatically when rebooted, you will need to have root/sudo access and follow these steps.
Edit the configuration. When a process is started at server startup it runs as root. You do not want the CSVN console to run as root, you want it to run as a specific user -- whatever your login user is.
  1. To do this, edit the file data/conf/csvn.conf.
$ vi data/conf/csvn.conf
  1. Scroll down a little bit until you see #RUN_AS_USER= . Uncomment it out and add your username.
Example:
RUN_AS_USER= username
  1. Save the changes.

[username@localhost csvn]$ sudo –E bin/csvn install

Now we will start the server. Be sure that you are not logged in as root.

[username@localhost csvn]$ bin/csvn start

     This will take a few minutes and the script will loop until it sees that the server is running. 
 
 
     Note: If the server does not start, then try starting the server with this command:
      
            [username@localhost csvn]$ bin/csvn console
 
6.      Add the following line to /etc/sysconfig/iptables
 
# iptables -A INPUT –p tcp --dport 3343 –j ACCEPT
 
Restart firewall to update the changes
 
# service iptables restart
 
 
 
Installation is done, now open the following link:
 
http://localhost:3343/csvn
username: admin  
password: admin
 
Note: If you are not able to see your CSVN server on the browser, then just disabled the your system Firewall by entering setup command in the terminal window.
# setup
Or 
Go to System>Administration>Firewall and disable it.
 
 
Note: You can change the IP address of your subversion server with your machine IP address by editing 
 opt/subversion/csvn/data/conf/csvn.conf file (at line no. 62) by the following command. 
$ sudo vi data/conf/csvn.conf
 
OR
 
$ sudo gedit  data/conf/csvn.conf




Subversion Edge also starts an SSL-protected version using a self-signed SSL certificate.
You can access the SSL version on this URL:
   
https://localhost:4434/csvn
 

Steps to install Bugzilla 4.2 (latest version) on CENTOS / Fedora / RHEL Linux.


Installing Bugzilla-4.2 on CENTOS / FEDORA/ RHEL Linux

Step 1: update remi repository
#  rpm –Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
#  rpm –Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Step 2: yum update

            yum install perl-CPAN

yum install httpd mysql-server mod_perl mod_perl-devel httpd-devel graphviz patchutils gcc perl-DateTime perl-Template-Toolkit perl-Email-Send perl-Email-MIME perl-GD perl-Chart perl-Template-GD perl-GDGraph perl-GDTextUtil perl-PatchReader perl-MIME-tools perl-LDAP perl-Authen-SASL perl-RadiusPerl perl-SOAP-Lite perl-JSON-RPC perl-JSON-XS perl-Test-Taint perl-HTML-Scrubber perl-Email-MIME-Attachment-Stripper perl-Email-Reply perl-TheSchwartz perl-Daemon-Generic perl-Math-Random-Secure perl-YAML perl-Class-Inspector

Step 3: # restorecon –Rv /var/www/html/

Step 4: Now download latest bugzilla-4.2 tar file from the below link.
            Note: The downloaded bugzilla tar file should be moved to /var/www/html/ directory.
            
            # cd /var/www/html
            Now untar the downloaded bugzilla tar ball
            # tar zxf bugzilla-4.2.tar.gz
            # mv bugzilla-4.2 bugzilla4
            # chown –R 751 bugzilla4
            # chown root:apache –R bugzilla4
            # cd bugzilla4

            check for missing modules
# ./checksetup.pl --check-modules

To install all the missing modules just type the following:
            # /usr/bin/perl install-module.pl --all
           
            Recheck of missing modules
# ./checksetup.pl --check-modules

You can install missing modules one by one by the following methods –
1.      /usr/bin/perl install-module.pl <module name>
2.      # cpan
cpan>  install <module name>
3.      Perl –MCPAN –e ‘install “<module name>”’

# ./checksetup.pl

Note:  You would not be able to install the Encode : Detect module but no need to worry, it is a optional module.

If all the necessary modules are installed properly, then it will ask to edit  ./localconfig file.

# vi ./localconfig

Search for $ db_pass=’ ’ line in localconfig file
Now put type a new password for mysql as shown below.
 $ db_pass=’your password for sql’
         
Step5: Modify /etc/my.cnf to increase bugzilla attachment size:
            # vi /etc/my.cnf

            Add the below line in my.cnf file

            max_allowed_packet=10M

Above will allow attachment size upto 10 mb, you can change the attachment size as per your requirements. 



Step 6: Creating My SQL database bugs for bugzilla server :
                    
            # service mysqld restart
            # mysql

sql> create database bugs;
        Query OK, 1 row affected (0.00 sec)

sql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,    CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY ‘your password for  mysql’;
          Query OK, 0 rows affected (0.00 sec)

sql> FLUSH PRIVILEGES;
sql> quit;

Step 7: Setup the Administrative User for Bugzilla
Rerun checksetup.pl. It reconfirms that all the modules are present, and notices the altered localconfig file, which it assumes you have edited to your satisfaction. It compiles the UI templates, connects to the database using the ‘bugs’ user you created and the password you defined, and creates the ‘bugs’ database and the tables therein.
If all goes well, it will ask you for an email for the Bugzilla Administrator account and the password for that account.
$ ./checksetup.pl

Step 8: Add the following to the httpd.conf file. This assumes you installed Bugzilla in the default path.

#vi /etc/httpd/conf/httpd.conf

find, uncomment and edit the following two lines:
ServerAdmin  root@yoursystemhostname     (line no.262 of your httpd.conf file)
ServerName  yoursystemhostname:80            (line no.276 of your httpd.conf file)

Also find and uncomment the following line:

AddHandler cgi-script .cgi     (you can find this at line no. 799 of your httpd.conf file)

            Type the below two line at the end of httpd.conf file:

PerlSwitches -I/var/www/html/bugzilla -I/var/www/html/bugzilla/lib -w -T
PerlConfigRequire /var/www/html/bugzilla/mod_perl.pl



Step 9: Now restart Apache web server:

# service httpd restart


Step 10: Open port 80 in firewall table:
# iptables –A INPUT –p tcp --dport 80 –j ACCEPT
# service iptables save

Now you can see your running bugzilla server on

Note: If you are not able to see your bugzilla server on the browser, then just disabled the your system Firewall by entering setup command in the terminal window.
# setup
Select Firewall Configuration menu and disable the Firewall by removing the “ * ” symbol by pressing spacebar in that Enabled bracket, then press OK , Yes and Quit.

                                                                         OR

Go to System>Administration>Firewall and disable it.

Now type this in the browser window: http://localhost/bugzilla

I hope now your are able to see your bugzilla server home page.





Email configuration for Bugzilla Server: 





Open your bugzilla server ip address in your browser
Log in with bugzilla administrator email id and password which you have setup during the installation.
After login click on Administration tab, then click Parameters, then click Email (on the left hand side menu) and change the following fields:

Mailfrom : your bugzillaserver email id (not bugzilla administrator email)
Smtpserver : your outgoing mailserver address
Smtp_username : your bugzillaserver email id
Smtp_password : bugzillaserver email id password

Then click on Save Changes at the bottom of the page.

Now go to User Authentication menu and go to field createemailregexp (at the bottom of the page), this field is used to give access to a particular email domain address.
For example: .*@gmail.com
In the above example, bugzilla will allow only those email address to be created who have @gmail.com as a suffix.

Now you are good to go with Bugzilla Server. Enjoy.