天天看點

Java 通路PI 資料庫:(1)安裝必要軟體

Java 通路PI 資料庫

需求

  • 使用java 去通路PI 資料庫

前提環境

  • 已經在遠端安裝了PI 資料庫。
  • windows 系列
  • jre 8 及以上

資料收集

  • PI​​官網​​​​https://techsupport.osisoft.com/​​
  • 在官網上,開發者技術 上,可以看到相關幫助文檔與軟體下載下傳
  • 由官網(Developer Technologies)介紹可知:常用的通路PI資料庫的方案有
  • 使用 JDBC Driver 或 ODBC Driver
  • 使用 PI Web Api
  • 使用 sdk

确定方案

根據需求,決定選擇 JDBC Driver 來實作java 通路PI資料庫

原理

PI的JDBC驅動程式是一個java資料庫連接配接驅動,通過SQL查詢提供了強大的資料通路PI系統 。PI JDBC Driver 提供了一個類似于java 通路Mysql或者Oracle 同樣的方式。

但是,JDBC Driver 是 通過中間層 PI SQL DATA Access Server 來實作 PI JDBC driver 和 PI OLEDB Enterprise/PI OLEDB providers 之間的互動的。

PI SQL DAS(OLE DB)在用戶端 通過 Net.TCP 或者 HTTPS 來提供安全的網絡連接配接

Java 通路PI 資料庫:(1)安裝必要軟體
Java 通路PI 資料庫:(1)安裝必要軟體
Java 通路PI 資料庫:(1)安裝必要軟體

軟體安裝

一定要注意安裝順序:

按照摸索的過程書寫的文檔。其真實安裝步驟應該是:

* OLE DB

* PI SQL Data Access Server

* PI JDBC Driver 2016

安裝PI JDBC Driver 2016

  • PI JDBC Driver 2016 在 windows 上基本要求
  • windows7 及以上
  • JRE 7 及以上
  • 已經安裝了 PI SQL DATA Access Server
  • 安裝步驟
  • 下載下傳​​PI JDBC Driver 2016 SP1 Install Kit (Windows) ​​
  • 根據安裝向導運作,運作 PI-JDBC_2016-SP1_.exe,全部預設
  • 安裝以後,其安裝目錄(PIHOME),32bit:C:\Program Files (x86)\PIPC\JDBC,64 bit :C:\Program Files\PIPC\JDBC
  • 系統環境變量會自動添加或更新
  • PI_RDSA_LIB=PIHOME\JDBC\RDSAWrapper.dll
  • PI_RDSA_LIB64=PIHOME\JDBC\RDSAWrapper64.dll
  • CLASSPATH=PIHOME\JDBC\PIJDBCDriver.jar
  • 打開 cmd,運作​

    ​set pi​

    ​​ 和​

    ​set classpath​

    ​ 即可查詢環境變量是否設定
  • 安裝完成
  • 注意事項
  • 如果沒有安裝 PI SQL DATA Access Server,安裝了 JDBC Driver 也沒有什麼用。你會發現 JDBC 的安裝目錄下提供了一個類似于 JDBC通路Mysql的包而已。
  • 甚至,你自身的系統為64bit,它卻會靜默安裝 将32 bit 的安裝上去。
  • 程式還提供了一種靜默安裝方案
  • msiexec.exe /i PIJDBC.msi REBOOT=Suppress ALLUSES=1 /qn
  • msiexec.exe /i PIJDBC64.msi REBOOT=Suppress ALLUSES=1 /qn

    (未實踐)

安裝PI SQL DATA Access Serve(OLE DB)

  • PI SQL DAS 在 windows 上基本要求
  • 需要安裝 Microsoft .Net Framework 4.6
  • 需要安裝 PI OLEDB Provider 或者 PI OLEDB Enterprise
  • 安裝步驟
  • 下載下傳​​PI SQL Data Access Server (OLE DB) Install Kit ​​
  • 使用擁有管理者權限的賬戶來安裝
  • 根據安裝向導運作,運作 PISQLDAS_*.exe, 點選Ok
  • 當你運作安裝時,PI SQL DAS 會根據你的作業系統版本自動選擇安裝 32bit 或者 64bit
  • HTTPS port 預設為 5461,Net.TCP 為 5462
  • 自動安裝對應的證書
  • 會修改對應端口的防火牆
  • 安裝完成
  • 校驗服務是否在運作。我的電腦->管理->服務 中檢視 是否新增了一個 PI SQL Access Server(OLE DB)的服務在運作狀态
  • Java 通路PI 資料庫:(1)安裝必要軟體

安裝 PI OLEDB Provider 或者 PI OLEDB Enterprise

  • PI JDBC Driver 2016 在 windows 上基本要求
  • windows7 及以上
  • JRE 7 及以上
  • 需要安裝 Microsoft .Net Framework 4.6 (企業版中包含此安裝包)
  • 安裝步驟
  • 下載下傳​​PI OLEDB Provider ​​​ 或者​​PI OLEDB Enterprise ​​
  • 根據安裝向導運作,運作 PI-OLEDB_*.exe,全部預設
  • 安裝完成
  • 注意
  • PI OLEDB Enterprise 比 PI OLEDB Provider 要全面較多。所安裝的軟體也會更多。
  • msiexec.exe /i PIOLEDBEnterprise64.msi REBOOT=Suppress ALLUSES=1 /qn

安裝 PI ODBC Driver

  • 在 windows 上基本要求
  • windows7 及以上
  • JRE 7 及以上
  • 安裝步驟
  • 下載下傳​​ PI ODBC Driver​​
  • 根據安裝向導運作,運作 PI-ODBC_*.exe,全部預設
  • 安裝完成
  • 它包含一個工具SQL Commander Lite,可以用來查詢SQL
通過上述的安裝步驟之後,從開始菜單打開SQL Commander Lite,可以連接配接上 PI 服務,并且使用 類似 sql 語句去查詢PI 中的資料。具體 sql語句 檢視 幫助文檔如PI-OLEDB-Enterprise-2016-R2-User-Guide.pdf
Java 通路PI 資料庫:(1)安裝必要軟體

精簡安裝包

經過上述的安裝步驟之後,會發現,其安裝很是臃腫,比如,原本我是 64bit的作業系統,我隻想要安裝 64bit 即可,上述的安裝步驟,卻會将 32bit 也全部安裝。

對比各個包解壓後的檔案,檢視其 setup.ini, 則會發現 setup.ini 是一些關于安裝檔案與安裝順序的配置。調整 setup.ini 中的相關安裝檔案順序與安裝指令,一一對應,将其中對應的 32 bit 配置删除,并且将多個安裝包 合并在一起。

執行 setup.exe 即可內建安裝 .Net 4.6/PI OLEDB Provider/PI SQL DAS(OLE DB)/SQL Commander Lite 等

[SETUPKIT]
;
;-------------------------------------------------------------------------------
; Setup wrapper master log file and display name
;-------------------------------------------------------------------------------
;
NAME = PIOLEDB
DISPLAYNAME = PI OLEDB 2016
;
;------------------------------------
; Silent/Interactive options
; Should be TRUE for silent installs
;------------------------------------
SUPPRESSCOMPLETIONMESSAGE = FALSE
SUPPRESSPROGRESSMESSAGE = FALSE
SUPPRESSHEADERMESSAGE = FALSE
SUPPRESSDIALOGS = FALSE

;----------------------------
; Other setup wrapper options
;----------------------------
SHOWSKIPPEDMODULES = FALSE
FEATUREUPGRADE = FALSE

[NUMSETUPMODULES]
NUM=12

[SETUPMODULES]
1 = dotnet460Setup
2 = pibufss\PreInstallTasks
;   PIBufssPreInstallTasks required by pibufss.msi (4.3) and pibufss_x64.msi (4.3)
;
3 = MSRuntimes\MSRuntimes.msi
;   MSRuntimes.msi required by: pisdk.msi (1.4.4) because of its VB6 controls.
;
4 = VS2008Redistrib\MSVC9SP1x64Redistrib
;   MSRuntimes VS2008 SP1 (32-bit and 64-bit) required by: AFClient PISDKRegistry merge module, and PIBufss piapi.msm
;
5 = VS2010Redistrib\MSRuntimesSetupVS2010SP1_x64
;   MSRuntimes VS2010 SP1 required by:  pisdk (1.4.4) because of the following 3.4.390.xx utilities and dll's: pictrdll.dll, pigetmsg.exe, piconfig.exe, pidiag.exe
;
6 = VS2012Redistrib\MSRuntimesVS2012_x64
;   MSRuntimes VS2012 SP1 (32-bit and 64-bit) required by: pibufss (4.3)
;
;PI SDK (64-bit)
7 = pisdk\PISDK_x64.msi
;
;
; PI Buffer Subsystem
8 = pibufss\PIBufss_x64.msi
9 = PIOLEDB64.msi
10 = VS2015Redistrib\MSRuntimesVS2015_x64
11 = PI_SQL_Data_Access_Server_OLE_DB_x64.msi
12 = PI_SQL_Commander_Lite_x64.msi
[COMMANDLINE]
2 = 
;MSRuntimes 
3 = ALLUSERS=1
;2008 SP1 Runtimes (32-bit and 64-bit) 
4 = /qb- /norestart
;2010 SP1 Runtimes (32-bit and 64-bit) 
5 = /norestart /passive
;2012 SP1 Runtimes (32-bit and 64-bit) 
6 = /norestart /passive
;PI SDK (64-bit)
7 = NOPISDKBUFFERING=1 ALLUSERS=1
; PI Buffer Subsystem (64-bit)
8 = ALLUSERS=1
9 = ALLUSERS=1

10 = /norestart /passive
12 = ALLUSERS=1

[UPGRADECOMMANDLINE]
;PI SDK (32-bit, 64-bit)
7 = REINSTALL=ALL REINSTALLMODE=vemus

[DISPLAYNAME]
1 = DotNet 4.6
4 = Microsoft Visual C++ 2008


[CHECKFORINSTALLEDONLY]

[UNSUPPORTED_OPERATING_SYSTEMS_MESSAGE]
; Messages for X86 or X64 take priority over operating system specific messages.
;
;X86 = Setup initialization has failed. This setup kit cannot be installed on 32-bit Operating Systems. Setup cannot continue.
WinXP = Windows XP is not supported. 
Vista = Service Pack 2 is required on
Win7 = Service Pack 1 is required on Windows 7. 
Win2K = Windows 2000
WinNET = = Windows Server 2003
Win2008 = Service Pack 2 is required on Windows Server 2008. 
Win2008R2 =  Service Pack 1 is required on Windows Server 2008


[UNSUPPORTED_OPERATING_SYSTEMS]
;
;-------------------------------------------------------------------------------
; Defined Operating Systems
;
; (Win95, Win98, WinME, WinNT, Win2K, WinXP, WinNET, Vista, Win2008, Win7, 
;  Win2008R2, Win8, Win2012, Win81, Win2012R2)
;
; If Defined Operating Systems used, all versions of specified operating system
; is defined.
;
; Defined Operating Systems with Service Packs or sub category
;
; (WinNTPreSp6a, WinNTSp6a, Win2KNoSp, Win2KSp1, Win2KSp2, Win2KSp3, Win2KSp4,
; WinXPNoSp, WinXPSp1, WinXPSp2, WinNETNoSp , WinNETSp1, WinNETSp2, VistaNoSp,
; VistaSp1, VistaSp2, Win2008NoSP, Win2008Sp1, Win2008Sp2, CORE, Win7,
; Win2008R2, Win8, Win2012, Win81, Win2012R2, X64)
;
; If Defined Operating Systems with Service Packs used, only that specific
; service pack within operating system is defined. The exception is for
; WinNT where only Sp6a or pre Sp6a is defined.
;
; A 0 entry denotes that the setup can not run on the given operating systems.
; An entry that corresponds to an entry in the [SETUPMODULES] section denotes
; that the particular setup module will be skipped on the given operating system
;-------------------------------------------------------------------------------
;
0 = Win95, Win98, WinME, WinNT, Win2K, WinXP, WinNET, VistaNoSp, VistaSp1, Win2008NoSp, Win2008Sp1, Win7NoSp, Win2008R2NoSp, CORE
;
; VS2008Redistrib\MSVC9SP1x64Redistrib
4= X86
;
; VS2010Redistrib\MSRuntimesSetupVS2010SP1_x64
5 = X86
;
; VS2012Redistrib\MSRuntimesVS2012_x64
6 = X86
;
; PI SDK (64-bit)
7 = X86
;
;
; PI Buffer Subsystem (64-bit)
8 = X86
;
; PI OLEDB (64-bit)
9 = X86

;MSI's or Setup wrapper Dll's can write to this section to dynamically change 
;the command line for an MSI at setup runtime.
[RUNTIME_PARAMETERS]

;This section is used by the pibufss pre-install tasks and post-install tasks.
[PIBUFSS]