oracle 客戶端安裝
阿新 • • 發佈:2019-01-10
************************************************
* 注意事項 *
* 需要安裝跟客戶oracle相同版本的客戶端 *
* 此檔案以oracle 10為例進行說明 *
* 修改任何檔案前請先備份 *
************************************************
ORACLE客戶端及PDO OCI擴充套件的安裝
下載以下安裝包
oracle-instantclient-devel-10.2.0.5-1.x86_64.rpm
oracle-instantclient-basic-10.2.0.5-1.x86_64.rpm
oracle-instantclient-sqlplus-10.2.0.5-1.x86_64.rpm
執行如下命令安裝如下三個包:
rpm -ivh oracle-instantclient-devel-10.2.0.5-1.x86_64.rpm
rpm -ivh oracle-instantclient-basic-10.2.0.5-1.x86_64.rpm
rpm -ivh oracle-instantclient-sqlplus-10.2.0.5-1.x86_64.rpm
echo '/usr/lib/oracle/10.2.0.5/client64/lib/' > /etc/ld.so.conf.d/oracle_client.conf
/sbin/ldconfig
------------------------------------------------------------
yum install libaio
tar zxvf oci8.tar.gz
cd oci8
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/10.2.0.5/client64/lib/
make && make install
vim /usr/local/etc/php/php.ini
加入extension=oci8.so
-----------------------------------------------------------
tar zxvf pdo_oci.tar.gz
cd pdo_oci/
ln -s /usr/include/oracle/11.0.0.1 /usr/include/oracle/10.2.0.5
ln -s /usr/lib/oracle/11.0.0.1/ /usr/lib/oracle/10.2.0.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-oci=instantclient,/usr,10.2.0.5
make && make install
vim /usr/local/etc/php/php.ini
加入extension=pdo_oci.so
------------------------------------------------------------
配置環境變數(在檔案/root/.bash_profile輸入如下行)
TNS_ADMIN=/usr/lib/oracle/10.2.0.5/client64
LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.5/client64/lib
NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export TNS_ADMIN LD_LIBRARY_PATH NLS_LANG
-------------------------------------------------------------
若執行完上述操作後,沒有檔案/etc/ld.so.conf.d/oracle-lib.conf,請在在/etc/ld.so.conf中加入如下行:
/usr/lib/oracle/10.2.0.5/client64/lib/
------------------------------------------------------------
若執行完上述操作後,沒有檔案/usr/lib/oracle/10.2.0.5/client64/tnsnames.ora
在/usr/lib/oracle/10.2.0.5/client64/tnsnames.ora中加入
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
注:修改HOST的地址和SERVICE_NAME的資料庫名稱
sqlplus64 user/[email protected]/dbname 連線資料庫命令
如需切換使用者執行 需要/etc/sudoers 內的env_reset 後增加 NLS_LANG 以保證字符集正常