nodejs linux下配置oracle支持

我自己测试了,刚开始下载的是oracle12的包,死活安装不上,重新下载了instantclient-sdk-linux.x64-11.2.0.4.0.zip 和 instantclient-basic-linux.x64-11.2.0.4.0.zip ,再安装,成功了。
在oracle网站下载oracle数据库客户端连接包  
  
instantclient-basic-linux,instantclient-sdk-linux  
  
解压oracle客户端连接模块  
  
$ unzip instantclient-basic-linux-11.2.0.3.0.zip  
$ unzip instantclient-sdk-linux-11.2.0.3.0.zip   
$ sudo mv instantclient_11_2/ /opt/instantclient  
  
$ cd /opt/instantclient  
$ sudo ln -s libocci.so.11.1 libocci.so  
$ sudo ln -s libclntsh.so.11.1 libclntsh.so  
  
配置环境变量  
  
$ export OCI_INCLUDE_DIR=/opt/instantclient/sdk/include/  
$ export OCI_LIB_DIR=/opt/instantclient  
  
进入nodejs目录  安装oracle模块支持  
  
$ cd /usr/local/lib  
  
$ npm install oracle  
  
export LD_LIBRARY_PATH=/opt/instantclient  
  
编写oracle.js文件 测试连接于执行sql是否正常  
  
var oracle = require("oracle");  
  
oracle.connect({ "hostname": "localhost", "user": "demo", "password": "demo", "database": "orcl", "port": 1521}, function(err, connection) {  
  if(err) {  
   console.log(err);  
  }  
  // selecting rows 注意 connection.execute 方法必须要三个参数 不然会出错  
  connection.execute("SELECT * FROM TEST WHERE ID = :1", ['1'], function(err1, results) {  
    // results will be an array of objects  
    console.log("query start");  
    if(err1) {  
        console.log(err1);  
    }  
   // console.log(results.length);  
   for(var i = 0; i < results.length; i++) {  
     console.log(results[i].ID);  
    }  
    connection.close();  
  });  
});  
-bash-4.1# unzip instantclient-
instantclient-basic-linux.x64-11.2.0.4.0.zip  instantclient-sdk-linux.x64-11.2.0.4.0.zip
-bash-4.1# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip 
Archive:  instantclient-basic-linux.x64-11.2.0.4.0.zip
  inflating: instantclient_11_2/BASIC_README  
  inflating: instantclient_11_2/adrci  
  inflating: instantclient_11_2/genezi  
  inflating: instantclient_11_2/libclntsh.so.11.1  
  inflating: instantclient_11_2/libnnz11.so  
  inflating: instantclient_11_2/libocci.so.11.1  
  inflating: instantclient_11_2/libociei.so  
  inflating: instantclient_11_2/libocijdbc11.so  
  inflating: instantclient_11_2/ojdbc5.jar  
  inflating: instantclient_11_2/ojdbc6.jar  
  inflating: instantclient_11_2/uidrvci  
  inflating: instantclient_11_2/xstreams.jar  
-bash-4.1# unzip instantclient
instantclient_11_2/                           instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-basic-linux.x64-11.2.0.4.0.zip  
-bash-4.1# unzip instantclient
instantclient_11_2/                           instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-basic-linux.x64-11.2.0.4.0.zip  
-bash-4.1# unzip instantclient-
instantclient-basic-linux.x64-11.2.0.4.0.zip  instantclient-sdk-linux.x64-11.2.0.4.0.zip
-bash-4.1# unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip 
Archive:  instantclient-sdk-linux.x64-11.2.0.4.0.zip
   creating: instantclient_11_2/sdk/
   creating: instantclient_11_2/sdk/include/
  inflating: instantclient_11_2/sdk/include/occi.h  
  inflating: instantclient_11_2/sdk/include/occiCommon.h  
  inflating: instantclient_11_2/sdk/include/occiControl.h  
  inflating: instantclient_11_2/sdk/include/occiData.h  
  inflating: instantclient_11_2/sdk/include/occiObjects.h  
  inflating: instantclient_11_2/sdk/include/occiAQ.h  
  inflating: instantclient_11_2/sdk/include/oci.h  
  inflating: instantclient_11_2/sdk/include/oci1.h  
  inflating: instantclient_11_2/sdk/include/oci8dp.h  
  inflating: instantclient_11_2/sdk/include/ociap.h  
  inflating: instantclient_11_2/sdk/include/ociapr.h  
  inflating: instantclient_11_2/sdk/include/ocidef.h  
  inflating: instantclient_11_2/sdk/include/ocidem.h  
  inflating: instantclient_11_2/sdk/include/ocidfn.h  
  inflating: instantclient_11_2/sdk/include/ociextp.h  
  inflating: instantclient_11_2/sdk/include/ocikpr.h  
  inflating: instantclient_11_2/sdk/include/ocixmldb.h  
  inflating: instantclient_11_2/sdk/include/ocixstream.h  
  inflating: instantclient_11_2/sdk/include/odci.h  
  inflating: instantclient_11_2/sdk/include/oratypes.h  
  inflating: instantclient_11_2/sdk/include/ori.h  
  inflating: instantclient_11_2/sdk/include/orid.h  
  inflating: instantclient_11_2/sdk/include/orl.h  
  inflating: instantclient_11_2/sdk/include/oro.h  
  inflating: instantclient_11_2/sdk/include/ort.h  
  inflating: instantclient_11_2/sdk/include/xa.h  
  inflating: instantclient_11_2/sdk/include/nzt.h  
  inflating: instantclient_11_2/sdk/include/nzerror.h  
  inflating: instantclient_11_2/sdk/include/ldap.h  
   creating: instantclient_11_2/sdk/demo/
  inflating: instantclient_11_2/sdk/demo/demo.mk  
  inflating: instantclient_11_2/sdk/demo/cdemo81.c  
  inflating: instantclient_11_2/sdk/demo/occidemo.sql  
  inflating: instantclient_11_2/sdk/demo/occidemod.sql  
  inflating: instantclient_11_2/sdk/demo/occidml.cpp  
  inflating: instantclient_11_2/sdk/demo/occiobj.cpp  
  inflating: instantclient_11_2/sdk/demo/occiobj.typ  
  inflating: instantclient_11_2/sdk/SDK_README  
 extracting: instantclient_11_2/sdk/ottclasses.zip  
  inflating: instantclient_11_2/sdk/ott  
-bash-4.1# 
-bash-4.1# 
-bash-4.1# 
-bash-4.1# sudo mv /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# rm -rf /opt/instantclient/instantclient_12_1/
-bash-4.1# sudo mv /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# sudo mv /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# sudo mv /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# sudo mv /home/tools/
mongodb-linux-x86_64-2.4.9.tgz    nginx-1.5.9/                      redis-stable/
mongodb-linux-x86_64-2.6.4.tgz    nginx-1.5.9.tar.gz                redis-stable.tar.gz
mongodb-linux-x86_64-2.6.4.tgz.1  nodeoracle/                       wget-log
-bash-4.1# sudo mv /home/tools/
mongodb-linux-x86_64-2.4.9.tgz    nginx-1.5.9/                      redis-stable/
mongodb-linux-x86_64-2.6.4.tgz    nginx-1.5.9.tar.gz                redis-stable.tar.gz
mongodb-linux-x86_64-2.6.4.tgz.1  nodeoracle/                       wget-log
-bash-4.1# sudo mv /home/tools/nodeoracle/
12/                                           instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient_11_2/                           instantclient-sdk-linux.x64-11.2.0.4.0.zip
-bash-4.1# sudo mv /home/tools/nodeoracle/instantclient
instantclient_11_2/                           instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-basic-linux.x64-11.2.0.4.0.zip  
-bash-4.1# sudo mv /home/tools/nodeoracle/instantclient
instantclient_11_2/                           instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-basic-linux.x64-11.2.0.4.0.zip  
-bash-4.1# sudo mv /home/tools/nodeoracle/instantclient_11_2/ /opt/instantclient
-bash-4.1# cd /opt/instantclient/
-bash-4.1# ls
instantclient_11_2
-bash-4.1# sudo mv /opt/instantclient/instantclient_11_2/ /opt/instantclient2
-bash-4.1# cd /opt/instantclient2/
adrci              libclntsh.so.11.1  libociei.so        ojdbc6.jar         xstreams.jar       
BASIC_README       libnnz11.so        libocijdbc11.so    sdk/               
genezi             libocci.so.11.1    ojdbc5.jar         uidrvci            
-bash-4.1# cd /opt/instantclient2/
adrci              libclntsh.so.11.1  libociei.so        ojdbc6.jar         xstreams.jar       
BASIC_README       libnnz11.so        libocijdbc11.so    sdk/               
genezi             libocci.so.11.1    ojdbc5.jar         uidrvci            
-bash-4.1# cd /opt/instantclient2/
-bash-4.1# ls
adrci         genezi             libnnz11.so      libociei.so      ojdbc5.jar  sdk      xstreams.jar
BASIC_README  libclntsh.so.11.1  libocci.so.11.1  libocijdbc11.so  ojdbc6.jar  uidrvci
-bash-4.1# rm -rf /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# rm -rf /home/
Dag/          Hive-master/  jsgen/        NodeJsGpsWeb/ tools/        
-bash-4.1# rm -rf /opt/instantclient
-bash-4.1# sudo mv /opt/instantclient2/ /opt/instantclient/
-bash-4.1# cd /opt/
instantclient/ rh/            
-bash-4.1# cd /opt/
instantclient/ rh/            
-bash-4.1# cd /opt/
instantclient/ rh/            
-bash-4.1# cd /opt/instantclient/
adrci              libclntsh.so.11.1  libociei.so        ojdbc6.jar         xstreams.jar       
BASIC_README       libnnz11.so        libocijdbc11.so    sdk/               
genezi             libocci.so.11.1    ojdbc5.jar         uidrvci            
-bash-4.1# cd /opt/instantclient/
adrci              libclntsh.so.11.1  libociei.so        ojdbc6.jar         xstreams.jar       
BASIC_README       libnnz11.so        libocijdbc11.so    sdk/               
genezi             libocci.so.11.1    ojdbc5.jar         uidrvci            
-bash-4.1# cd /opt/instantclient/
adrci              libclntsh.so.11.1  libociei.so        ojdbc6.jar         xstreams.jar       
BASIC_README       libnnz11.so        libocijdbc11.so    sdk/               
genezi             libocci.so.11.1    ojdbc5.jar         uidrvci            
-bash-4.1# cd /opt/instantclient/
-bash-4.1# ls
adrci         genezi             libnnz11.so      libociei.so      ojdbc5.jar  sdk      xstreams.jar
BASIC_README  libclntsh.so.11.1  libocci.so.11.1  libocijdbc11.so  ojdbc6.jar  uidrvci
-bash-4.1# 
-bash-4.1# 
-bash-4.1# 
-bash-4.1# 
-bash-4.1# sudo ln -s libocci.so.11.1 libocci.so
-bash-4.1# sudo ln -s libclntsh.so.11.1 libclntsh.so
-bash-4.1# export OCI_INCLUDE_DIR=/opt/instantclient/sdk/include/
-bash-4.1# export OCI_LIB_DIR=/opt/instantclient
-bash-4.1# cd /usr/local/lib
-bash-4.1# npm install oracle
-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-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\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/
> [email protected] install /usr/local/lib/node_modules/oracle
> node-gyp rebuild


make: Entering directory `/usr/local/lib/node_modules/oracle/build'
  CXX(target) Release/obj.target/oracle_bindings/src/connection.o
  CXX(target) Release/obj.target/oracle_bindings/src/oracle_bindings.o
  CXX(target) Release/obj.target/oracle_bindings/src/executeBaton.o
  CXX(target) Release/obj.target/oracle_bindings/src/reader.o
  CXX(target) Release/obj.target/oracle_bindings/src/statement.o
  CXX(target) Release/obj.target/oracle_bindings/src/outParam.o
  SOLINK_MODULE(target) Release/obj.target/oracle_bindings.node
  SOLINK_MODULE(target) Release/obj.target/oracle_bindings.node: Finished
  COPY Release/oracle_bindings.node
make: Leaving directory `/usr/local/lib/node_modules/oracle/build'
[email protected] node_modules/oracle

你可能感兴趣的:(NodeJs)