CentOS 7 安装Oracle 客户端并配置SQLPLUS工具(ZIP包)
1、下载客户端
http://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html
2、添加oracle的相关用户组和用户信息,并设定一个密码,密码可以随便写一个,这里用”oracle”。
[root@test-server ~]# groupadd -g 500 oinstall [root@test-server ~]# groupadd -g 501 dba [root@test-server ~]# useradd -u 500 oracle -g oinstall -G dba [root@test-server ~]# passwd oracle Changing password for user oracle. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [root@test-server ~]#
3、使用ZIP安装时,可以使用非root 用户,这里我们使用oracle用户,最终的安装路径是/home/oracle,切换到oracle用户,并创建一些文件夹。
[root@test-server ~]# su - oracle [oracle@test-server ~]$ cd /home/oracle
4、上传ZIP 包到/home/oracle/ 目录下,如果要使用SQLPLUS工具,要两个都上传,如果上传的这两个文件的所有者或组不是oracle和oinstall,可以用chown oracle:oinstall *.zip
命令行来修改,此时我们解压这两个文件到当前目录下,会生成一个文件夹 instantclient_11_2。
[oracle@test-server ~]$ ll *.zip -rw-r--r-- 1 oracle oinstall 60704657 Sep 12 09:34 instantclient-basic-linux.x64-11.2.0.4.0.zip -rw-r--r-- 1 oracle oinstall 834491 Spe 12 09:34 instantclient-sqlplus-linux.x64-11.2.0.4.0.zip [oracle@test-server instantclient]$unzip instantclient-basic-linux.x64-11.2.0.4.0.zip ……… [oracle@test-server instantclient]$unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip ………
5、建立库连接,这里要用 root 用户。
[oracle@test-server ~]$ exit [root@test-server ~]# echo /home/oracle/instantclient_11_2/ > /etc/ld.so.conf.d/oracle-instantclient.conf [root@test-server ~]# cat /etc/ld.so.conf.d/oracle-instantclient.conf /home/oracle/instantclient_11_2 [root@test-server ~] ldconfig [root@test-server ~] su - oracle
6、配置tnsname.ora,这里切回oracle用户。
[oracle@test-server ~]$ mkdir /home/oracle/instantclient_11_2/network/admin –p [oracle@test-server ~]$ cd /home/oracle/instantclient_11_2/network/admin [oracle@test-server admin]$ vi tnsnames.ora XE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.255.99.99)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE) ) ) :wq
7、配置环境变量
建议修改 .bash_profile 文件,前三行是新增,第四行是是修改原来的。
export ORACLE_CLIENT=/home/oracle/instantclient_11_2/ export LD_LIBRARY_PATH= $ORACLE_CLIENT export TNS_ADMIN= $ORACLE_CLIENT/network/admin PATH=$PATH:$HOME/bin:$ORACLE_CLIENT/ :wq source .bash_profile
8、测试数据库连接
[root@test-server ~]$ sqlplus “oracle/oracle@XE” SQL> select count(*) from user_objects; COUNT(*) ---------- 2 SQL>
扫描二维码推送至手机访问。
版权声明:本文由卖水果的net发布,如需转载请注明出处。
本文地址:http://www.msgde.net/oracle/oracle_setup_client_on_linux_use_zip.html