记录nodejs与oracle
发布时间:2020-12-12 15:36:16 所属栏目:百科 来源:网络整理
导读:环境:虚拟机 - ubuntu14server64位 参考资源: https://npm.taobao.org/https://github.com/oracle/node-oracledb/blob/master/INSTALL.mdhttp://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html//centos下nodejs的安装http://blog.csdn.ne
环境:虚拟机 - ubuntu14server64位 参考资源: https://npm.taobao.org/ https://github.com/oracle/node-oracledb/blob/master/INSTALL.md http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html //centos下nodejs的安装 http://blog.csdn.net/u010833605/article/details/50282139 1安装git sudo apt-get update sudo apt-get install git sudo apt-get install npm 2切换淘宝源 npm install -g cnpm --registry=https://registry.npm.taobao.org 3安装node cnpm install -g n n stable 4安装模块oracledb 首先去下载对应系统版本的instantclient(http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html) 然后解压两个压缩包合并到一个目录里,并生成一个link cd /opt/oracle unzip instantclient-basic-linux.x64-12.1.0.2.0.zip unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip mv instantclient_12_1 instantclient cd instantclient ln -s libclntsh.so.12.1 libclntsh.so 最后需要配置环境变量 export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH export OCI_LIB_DIR=/opt/oracle/instantclient export OCI_INC_DIR=/opt/oracle/instantclient/sdk/include 可能需要安装libaio1,如果找不到这个就是叫libaio因系统而异 最后安装oracledb cnpm install oracledb 5远程连接oracle需要的配置 需要一个配置文件tnsnames.ora 例如,远程ip为10.10.10.10,端口默认1521,SID:orcl,我取的别名是ORCL_HB ORCL_HB= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.10)(PORT = 1521)) ) (CONNECT_DATA = (SID = orcl) (SERVER = DEDICATED) ) ) 这个配置文件需要放到etc目录下面 mv ./tnsnames.ora /etc/tnsnames.ora 那么,在node中的配置为 config = { dbowner: '',dbconn: { user: 'root',password: '123',connectString: 'ORCL_HB' } }; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |