Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music
All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => all application on unix knowledges by golfreeze => Topic started by: golfreeze on เมษายน 02, 2013, 03:35:37 pm
-
This entire install process is done as root, so login to your server and lets get started.
Install myODBC and unixODBC as a dependency.
yum install mysql-connector-odbc
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mysql-connector-odbc i386 3.51.12-2.2 base 142 k
Installing for dependencies:
unixODBC i386 2.2.11-7.1 base 832 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 973 k
Is this ok [y/N]: y
Print your config infomation.
odbcinst -j
unixODBC 2.2.11
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini
Edit /etc/odbc.inst and /etc/odbcinst.ini
Below are my examples.
vi /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc.so
Setup = /usr/lib/libodbcmyS.so
UsageCount = 2
[MySQL ODBC 3.51 Driver]
Description = ODBC 3.51 for MySQL
DRIVER = /usr/lib/libmyodbc3.so
SETUP = /usr/lib/libmyodbc3S.so
UsageCount = 2
vi /etc/odbc.inst
[zenoss]
Driver = /usr/lib/libmyodbc3.so
SERVER = localhost
PORT = 3306
DATABASE = events
OPTION = 3
USER = root
PASSWORD = BlAh
Note: The PASSWORD: is the one we setup during our Zenoss installation and is REQUIRED because Splunk uses it to authenticate to the database.
Once you create your files and save them here is how you do the install.
Install driver
odbcinst -i -d -f /etc/odbcinst.ini
Install system DSN
odbcinst -i -s -l -f /etc/odbc.ini
Test your DSN install by lisinting your installed data sources.
odbcinst -s -q
[zenoss]
Test that you can connect to the database via the ODBC.
isql -v zenoss root BlAh
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
You are done. Here are some quick and dirty ways to fix some problem I had during the install.
I did not have libtool installed properly.
Install libtool
yum install libtool
edit lb.so.conf
Before the include I added
/opt/splunk/lib <---- I later commented this out.
/user/lib
Load the new ld.so.conf
ldconfig (you will not recive any confermation)
I also had a problem acidently loading user DSN so you can remove the user odbc.ini file or copy the one from /etc to the profile.
rm /home/name/.odbc.ini
How to remove a driver.
odbcinst -u -d -n zenoss
zenoss has been deleted (if it existed at all) because its usage count became zero.
How to remove a datasource.
odbcinst -u -s -l -n zenoss
odbcinst: DSN removed (if it existed at all). ODBC_BOTH_DSN was used as the search path.
Remeber if you change a odbc peramerter you need to install it again.
odbcinst -i -s -l -f /etc/odbc.ini
Special Thank : http://webaj.com/how-setup-mysql-dsn-datasbase-source-centos-myodbc-and-unixodbc-command-line.htm
-
พอดีวันนี้ได้ลองใช้งาน icewall ครับแต่ต้องอาศัย odbc connector มาที่ Mysql
เพราะว่า icewall มีตัว connect ที่ใช้งานกับ ODBC มาให้
ดังนั้นเริ่มกันเลยครับ
ทำการ copy file configure ต้นฉบับไว้ก่อน (admin ควรทำไว้ทุกครั้งนะครับ)
#cp /etc/odbcinst.ini /etc/odbcinst.ini.ori
#cp /etc/odbc.ini /etc/odbc.ini
ไฟล์นี้จะบอกถึง Driver ที่เราต้องการใช้ connect ด้วยผมใช้เป็น MySQL ครับผม
#vi /etc/odbcinst.ini
[MySQL]
Description = For icewall test
Driver = /usr/lib64/libmyodbc3.so #ตัวนี้ขึ้นอยู่กับว่า mysql เราใช้เป็น 32bit หรือ 64bit นะครับ แต่ในที่นี่ผมใช้เป็น 64 bit
Setup = /usr/lib64/libodbcmyS.so
#Driver = /usr/lib/libmyodbc3.so #ตัวนี้ขึ้นอยู่กับว่า mysql ถ้าใช้เป็น 32bit
#Setup = /usr/lib/libodbcmyS.so
FileUsage = 1
UsageCount = 3
เสร็จแล้วทำการ config file ที่ใช้ connect ครับ
#vi /etc/odbc.ini
[icewalltest]
Driver = MySQL
SERVER = localhost
PORT = 3306
DATABASE = icewalltest
USER = testdad
PASSWORD = testmum
เสร็จแล้วทำการ load driver odbc เข้าระบบครับ
#odbcinst -i -d -f /etc/odbcinst.ini
ทำการ install system DSN
#odbcinst -i -s -l -f /etc/odbcinst.ini
ทำการเชคว่าใช้งานได้ยัง
#odbcinst -s -q
You need to see
[icewall]
[MySQL]
เทส connection ดูครับ
#isql -v icewalltest testdad testmum
You need to see
+----------------------------------+
Connected!
หมายความติดต่อ DB--> icewall ได้แล้ว ผ่าน odbc mysql connector
อีกนิดหนึ่งครับถ้าท่านใช้งาน icewall + certd + db
จะต้องเข้าไป แก้ configure เรื่องการติดต่อ DB ใน ไฟล์ cert.conf
ก่อนอื่น ให้ใส่ค่า connect DB เป็น plaintext ก่อนนะครับ แล้วทาง certd จะมี function encrypt DBUID,DBPWD ให้เองครับ
#vi cert.conf
DBHOST=icewalltest:localhost:3306:MySQL
DBUID=testdad
DBPWD=testmum
แล้วทำการ สั่งให้ certd start ครับ
#./start-cert
แล้วลองเข้าไปดูใน cert.conf อีกครั้งจะเห็นว่า ถูก encrypt ทั้ง DBUID , DBPWD ครับผม
-
ถ้าใช้งานเป็น mysql-odbc-connector บน AIX สามารถ configure และ export ได้ตามข้างล่างนี้ครับ
####export command with correct Odbc lib path
export LIBPATH=$LIBPATH:/app/sas/software/oracle/product/11.2.0/client_1/lib:/app/sas/software/odbc/lib
###check env path
env
###copy library to another server
cd /opt/freeware/lib
ls -la libmyodbc5.so
ls -la libmyodbc5-5.1.5.so
###file configure odbc.ini in
cd /opt/freeware/etc
vi odbc.ini
[MySQL]
Driver=/opt/freeware/lib/libmyodbc5-5.1.5.so
Description= ODBC for MySQL
SERVER=192.1.2.9
PORT=3306
USER=userpkl
Password=
Database=dbnamepkl
OPTION=3
SOCKET=
หลังจากนั้นสามารถทำการทดสอบโดยใช้ command isql_64 (กรณีเป็น 64bit)
####Command isql_64 need confirm MySQL working normally
isql_64 MySQL -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------
isql>show tables
| paycmastor|
| payer |