Download the corresponding driver for mac and install it: http://www.cloudera.com/downloads.html.html
*HOST address is the IP address of the machine where impala Daemon is located, and the port can be set in cm
vi /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini
<code><span>[ODBC Data Sources]</span><span>Sample_Cloudera_Impala_DSN_64=<span>Cloudera Impala ODBC Driver <span>64</span>-bit</span></span><span>[Sample_Cloudera_Impala_DSN_64]</span><span>Driver=<span>/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib</span></span><span>HOST=<span><span>192.168</span>.<span>2.103</span></span></span><span>PORT=<span><span>21050</span></span></span></code>
vi /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini
<code>[<span>ODBC</span><span>Drivers</span>] <span>Cloudera</span><span>Impala</span><span>ODBC</span><span>Driver</span><span>64</span>-bit=<span>Installed</span>[<span>Cloudera</span><span>Impala</span><span>ODBC</span><span>Driver</span><span>64</span>-bit] <span>Description</span>=<span>Cloudera</span><span>Impala</span><span>ODBC</span><span>Driver</span> (<span>64</span>-bit) <span>Driver</span>=<span>/opt/cloudera</span><span>/impalaodbc/lib</span><span>/universal/libclouderaimpalaodbc</span>.dylib</code>
Test:
isql -v Sample_Cloudera_Impala_DSN_64
PHP connection:
<code><span><span><?php</span><span>$connection</span>=odbc_connect(<span>'Sample_Cloudera_Impala_DSN_64'</span>,<span>''</span>,<span>''</span>); <span>$SQL_Exec_String</span>=<span>"show tables"</span>; <span>$result</span>=odbc_exec(<span>$connection</span>, <span>$SQL_Exec_String</span>); <span>while</span>(odbc_fetch_row(<span>$result</span>)) { <span>$Tables</span>=odbc_result(<span>$result</span>, <span>1</span>); <span>echo</span><span>$Tables</span>.<span>'<br/>'</span>; } <span>?></span></span></code>
The above introduces the configuration of impala odbc on mac, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.