https://blog.csdn.net/philosophyatmath/article/details/44806787
从这里”http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html”下载以下三个文件
instantclient-basic-linux.x64-12.2.0.1.0.zip
instantclient-sdk-linux.x64-12.2.0.1.0.zip
instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
新建并复制到oracle文件夹下,自然依次顺序解压后,会生成“instantclient_12_2”目录,basic和sqlplus会在其根下,而sdk会在其下生成“sdk”目录;在其下建立目录“/network/admin” (mkdir -p network/admin),创建文件:“tnsnames.ora(vi -p tnsnames.ora)”,并添加:
xxxxdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 100.xx.236.57)(PORT = xxxx))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xxxx)
)
)
配置:
1.
cd /
vi .bash_profile
export ORACLE_HOME=/app/instantclient_12_2
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
建立软链接:ln -s /app/instantclient_12_2/sqlplus /user/app
2.或者直接配置在etc/profile后source etc/profile 生效
3.保证每次进入后自动source。 需要修改~/.bashrc文件
cd root
ll -a
vi .bashrc
添加source /etc/profile保存即可。
~~~若还是连不上,则临时配置
export ORACLE_HOME=/app/instantclient_12_2
export PATH=$ORACLE_HOME:$PATH
ln -s /app/instantclient_12_2/sqlplus /user/app
运行:“source ~/.bash_profile ”使之生效
检查环境变量:
echo $ORACLE_HOME
运行命令:sqlplus
sqlplus: error while loading sharedlibraries: libaio.so.1: cannot open shared object file: No such file ordirectory
解决方法:执行如下命令:sudo apt-get install libaio*。问题解决
执行登录:sqlplus dbmgr/zhaoshang001@tabletdb
如遇报错:cx_Oracle.DatabaseError: ORA-24454: 客户机主机名未设置
一行指令解决:
sudo /bin/bash -c "echo '127.0.1.1 ${HOSTNAME}' >> /etc/hosts"
网友评论