Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Tuesday, December 16, 2014

Simple way to configuring mysql or Postgresql RDBMS as Hive metastore

simple way to configuring mysql or Postgresql RDBMS as Hive metastore

Hive will store the metadata information (i.e like RDBMS will stores the table
and column information) out of HDFS and it will process the data available in HDFS.

By default Hive store its metastore into Derby a lightweight database.
which will serve single instance at a time. If you try to start mutltiple instance of Hive, you will get error like
"Another instance of Derby may have already booted the database".

In this will see how we can configure other RDBMS (MySQL & PostgreSQL) as Hive metastore.


Create / rename hive-default.xml.template TO hive-site.xml under $HIVE_HOME/conf
hadoop@solai# vim.tiny $HIVE_HOME/conf/hive-default.xml


change the value of the following property



<property>

<name>javax.jdo.option.ConnectionURL</name>

<value>jdbc:mysql://localhost:3306/hivedb</value> 

</property>

<property>

<name>javax.jdo.option.ConnectionDriverName</name>

<value>com.mysql.jdbc.Driver</value>

</property>

<property>

<name>javax.jdo.option.ConnectionUserName</name> 

<value>mysqlroot</value> 

</property>

<property>

<name>javax.jdo.option.ConnectionPassword</name> 

<value>hive@123</value> 
</property>




download and plcae the "mysql-connector-java-5.x.xx-bin.jar" to the $HIVE_HOME/lib
hadoop@solai# mv /home/hadoop/Downloads/mysql-connector-java-5.1.31.tar.gz $HIVE_HOME/lib
In Mysql create database "hivedb" and load the hive schema to the database "hivedb"
mysql> create database hivedb;
mysql> use hivedb;

## following will create hive schema in mysql database.
mysql> SOURCE $HIVE_HOME/scripts/metastore/upgrade/mysql/hive-schema-0.12.0.mysql.sql

its important to restrict user to alter / delete hivedb.
mysql> CREATE USER 'mysqlroot'@'hivedb' IDENTIFIED BY 'hive@123';



mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqlroot'@'hivedb';



mysql> GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES,EXECUTE ON hivedb.* TO 'mysqlroot'@'localhost';



mysql> FLUSH PRIVILEGES;



mysql> quit;
Enter Hive CLI, for create table
hadoop@solai#$HIVE_HOME/bin/hive

hive> create table testHiveMysql(uname string, uplace string);
enter into mysql to check the schema information created in hive environment. following lines will return the table and column information.
mysql> select * from TBLS;
mysql> select * from COLUMNS_V2;
mysql> show tables;
show tables, will return all the tables pertaining to the Hive schema

Friday, October 25, 2013

Replication in MySQL : From slave : unable to connect Master 10.184.0.10

Recently one my colleague was setting up MySQL replication through phpMyAdmin. When connecting Master through Slave, got error like  "unable to connect Master : 10.84.1.20"


Slave : Unable to connect Master : 10.84.1.20


SOLUTION
  I was gone through both Master and Salve my.cnf file. both Master and Slave   bind-address was pointing to the localhost. Modify  bind-address   localhost to 0.0.0.0 was solved the issues. 

from
 bind-address = 127.0.0.1
to
 bind-address = 0.0.0.0





Tuesday, September 3, 2013

MySQL start FAILED on VM Virtual Box

Recently  I had on issue with MySQL Start-up with VM. my environment was
Host OS   : Debian / BOSS
Guest OS : CentOS
Application running in CentsOS. We tried to replicate the same in Debian/BOSS but wouldn't because some missing packages. so decided to go with Virtual Machine concept.

When we boot the CentOS from Debian/BOSS, MySQL Failed to start.

As we followed my error.log we managed to start the MySQL.

1) Network Adapter settings in your VM settings to be bridged mode

2) Change bind address  in /etc/mysql/my.cnf to 0.0.0.0
bind-address = 0.0.0.0
 start the server by /etc/init.d/mysql start

3) gone through the log file (img),


MySQL error log  running on VM

got few error which was related to permission denied.


  • Error 1)
/usr/libexec/mysqld: File '/var/lib/mysql/log-bin.index' 
not found (Errcode: 13)
130930 15:27:22 [ERROR] Aborting
Solution
root@boss[~]# chmod -R 777   /var/lib/mysql/log-bin.index 
  • Error 2) 


innoDB : Operating Systems error number 13 in a file operation. the Error means mysqld doesn't have the access rights to the directory
File name ./ibdata
File operation call : 'open'
Cannot continue operation

Solution
root@boss[~]# chomd -R 777 `locate ibdata`


  • Error 3)
[ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
[ERROR] Can't start server : can't create PID file: Persmission denied

Solution
root@boss[~]#  chmod -R 777 /var/run/mysqld/mysqld.pid

root@boss[~]#  /etc/init.d/mysql start 

now MySQL started successfully


Friday, June 14, 2013

List the active connection/user in PostgreSQl,MySQL & mongoDB

As a DBA have to ensure number of active connection in database & which query consuming longer time to execute.

In PostgreSQL we can query from "pg_stat_activity" to know the status of the each connection.

when I was working in mongoDB(no-SQL) , wanted  to monitor the client  who currently accessing my server & the list active of operation.

here simple comparison,  how we to get  number of  active client (remote / local i.e different user ) connected to databases ( PostgreSQL,MySQL and mongoDB ) server.


PostgreSQL
----------------

select* from pg_stat_activity
postgres=# select datname, usename, application_name, client_addr,client_port,query_start,current_query from pg_stat_activity
 +------+---------+------------------------------+-------+---------+------+-------+------------------+
|datname  |usename   | application_name         | client_addr  | client_port | query_start 
+------+---------+------------------------------+-------+---------+------+-------+------------------+
template1 | postgres | pgAdmin III - Browser    | 127.0.0.1    |       56019 | 2013-06-14 19:52:52.775344+05:30
 SAAS     | postgres | psql                     | 192.168.1.10 |       58776 | 2013-06-14 19:58:33.084661+05:30
 koha     | postgres | pgAdmin III - Browser    | 192.168.0.2  |       56020 | 2013-06-14 19:52:52.729838+05:30
 pis      | postgres | pgAdmin III - Query Tool | 127.0.0.1    |       56022 | 2013-06-14 19:56:21.729744+05:30-
   - It display the list of active user/client ip address and query details.

Mysql
----------


show processlist; 
mysql> show processlist;
+------+---------+------------------------------+-------+---------+------+-------+------------------+
| Id   | User    | Host                         | db    | Command | Time | State | Info             |
+------+---------+------------------------------+-------+---------+------+-------+------------------+
| 3832 | root    | localhost                    | mysql | Query   |    0 | NULL  | show processlist |
| 3834 | erbnext | localhost                    | NULL  | Sleep   | 2524 |       | NULL             |
| 3837 | root    | solaimurugan.chennai.in:36125| koha  | Sleep   |    3 |       | NULL             |
+------+---------+------------------------------+-------+---------+------+-------+------------------+
3 rows in set (0.00 sec) 

it states that 3 active connections, 2 from localhost & 1 from client solaimurugan.chennai.in & it connects database mysql & koha.


mongoDB
------------



db.currentOp(true)
root@boss[bin]#./mongo  
MongoDB shell version: 2.2.3
-----------------------------------------------------------------------------------------------------------------------
db.currentOp(true).inprog.forEach(function(d){if(d.client && d.client!="0.0.0.0:0")printjson(d.client)})
----------------------------------------------------------------------------------------------------------------------
"solaimurugan.chennai.in:56231"
"127.0.0.1:49563" 
"192.168.31.101:50132" 
-------------------------------------------------------------------------------------------------------------------------------------

 mongoDB also has command to view total number of current connection & available connection to be established by client


db.serverStatus()

root@boss[bin]#./mongo  
MongoDB shell version: 2.2.3
-----------------------------------------------------------------------------------------------------------------------
db.serverStatus().connections
-----------------------------------------------------------------------------------------------------------------------------
{ "current" : 3, "available" : 816 }
------------------------------------------------------------------------------------------------------------------------------


Labels