Import Excel Data into MySQL

Sunday, April 16, 2017

Import Excel Data into MySQL :-

To import data from Excel is very simple using the LOAD DATA command from the MySQL Command prompt. there are following steps.

Step 1. Save your Excel data as a csv file (In Excel 2007 using Save As)

Step 2. Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc.

Step 3. Start the MySQL Command Prompt (or MySQL Query Browser – Tools – MySQL Command Line Client to avoid having to enter username and password etc.)

Step 4. Enter this command:
           LOAD DATA LOCAL INFILE 'C:\\temp\\myfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2);

Step 5. Done

Read more...

Setting up Monit with tomcat

Setting up Monit with tomcat :-


Monit is used for monitoring and restarting services when services are down, it can alert you or just restart after 3 or 5 failed connects/attempts. It handles everything from load, disk space,  memory, services, and other things. we can easily configure it.

Step 1. To install 

            On Debian/Ubuntu based:-
            apt-get install monit

           On Centos :-
           1. Our system's hostname is site1.example.com, and we have a web site www.example.com on it with the document root /var/www/www.example.com/web.

            2. Need To Enable The RPMforge Repository :-
             On i386 hosts
             wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
             rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

             rm -f rpmforge-release-0.3.6-1.el5.rf.i386.rpm

            On x86_64 hosts
            wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
            rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

            rm -f rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

            3. Need to Install And Configure munin :-
             yum install munin munin-node

            Then we create the system startup links for munin and start it:
            chkconfig --levels 235 munin-node on
            /etc/init.d/munin-node start

Next, we must edit the munin configuration file /etc/munin/munin.conf. We want munin to put its output into the directory /var/www/www.example.com/web/monitoring, therefore we change the value of htmldir, and we want it to use the name site1.example.com instead of localhost.localdomain in the HTML output, therefore we replace localhost.localdomain with site1.example.com. Without the comments, the changed file looks like this:
vi /etc/munin/munin.conf

          [...]
         dbdir   /var/lib/munin
         htmldir /var/www/www.example.com/web/monitoring
         logdir  /var/log/munin
         rundir  /var/run/munin

        # Where to look for the HTML templates
        tmpldir /etc/munin/templates
        [...]
        # a simple host tree
        [site1.example.com]
        address 127.0.0.1
        use_node_name yes
        [...]
         
        mkdir -p /var/www/www.example.com/web/monitoring
         chown munin:munin /var/www/www.example.com/web/monitoring
        /etc/init.d/munin-node restart

         4. Password-Protect The munin Output Directory (Optional)
             we can create an .htaccess file in /var/www/www.example.com/web/monitoring:
         
             vi /var/www/www.example.com/web/monitoring/.htaccess

             AuthType Basic
             AuthName "Members Only"
            AuthUserFile /var/www/www.example.com/.htpasswd
           
                require valid-user
           

              Then we must create the password file /var/www/www.example.com/.htpasswd. We want to log in with the username admin, so we do this:
htpasswd -c /var/www/www.example.com/.htpasswd admin

             Enter a password for admin

Step 2:- Tomcat Monitoring Method A.

             
             echo "check host tomcat with address localhost
             stop program = "/etc/init.d/tomcat stop"
             start program = "/etc/init.d/tomcat restart"
             if failed port 8080 and protocol http
             then start
              " > /etc/monit.d/tomcat
              /etc/init.d/monit restart

Step 3:- Tomcat Monitoring Method B.


             check process tomcat with pidfile "/var/run/tomcat/tomcat.pid"
             start program = "/usr/local/tomcat/bin/startup.sh"
            as uid tomcat gid tomcat
            stop program = "/usr/local/tomcat/bin/shutdown.sh"
            as uid tomcat gid tomcat
            if failed port 8080 then alert
           if failed port 8080 for 5 cycles then restart
         
           Then edit your catalina.sh and set

            CATALINA_PID to be /var/run/tomcat/tomcat.pid
            JAVA_HOME=/usr/java/jdk


Then of course create the pid directory

mkdir /var/run/tomcat/
chown tomcat.tomcat /var/run/tomcat/

Step 4:- MySQL Monitoring 


           Add this to your my.cnf under [mysqld]

           pid-file=/var/run/mysqld/mysqld.pid
           and this to your monit config

           check process mysql with pidfile /var/run/mysqld/mysqld.pid
           group database
           start program = "/etc/init.d/mysql start"
           stop program = "/etc/init.d/mysql stop"
          if failed host 127.0.0.1 port 3306 protocol mysql then restart
          if 5 restarts within 5 cycles then timeout
          depends on mysql_rc

          check file mysql_rc with path /etc/init.d/mysql
          group database
         if failed checksum then unmonitor
         if failed permission 755 then unmonitor
         if failed uid root then unmonitor
         if failed gid root then unmonitor

Step 5:- Disk Space Monitoring


Add this to your monit config
check filesystem with path /dev/xvda1
      if space usage > 95% then alert
      if inode usage > 95% then alert


Step 6:- SSH Monitoring


Add this to your monit config

check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/sshd start"
   stop program  "/etc/init.d/sshd stop"
   if failed port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout


reloaded your monit config
























Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP