安裝與升級 > 安裝與組態指南 > 使用 PTC Solution Installer > 安裝 Windchill 解決方案 > 選用產品設定 > Windchill Index Search 安裝 > Windchill Index Search 安裝後組態 > 配置獨立索引搜尋伺服器
  
配置獨立索引搜尋伺服器
如果您已在獨立模式下安裝索引搜尋伺服器,請完成下列步驟。
* 
請確保您使用 Java 8 或更高版本。否則,請在執行下列指令之前設定 SOLR_JAVA_HOME 環境變數︰
Windows:SET SOLR_JAVA_HOME=<PATH_TO_JAVA_8>
Unix:export SOLR_JAVA_HOME=<PATH_TO_JAVA_8>
Solr 伺服器:啟動與停止指令
欲啟動或停止 solr 伺服器,請執行下列指令:
啟動指令
啟動 Solr (Windows):
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat start
啟動 Solr (Unix):
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh start
停止指令
停止 Solr (Windows):
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat stop
停止 Solr (Unix):
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh stop
建立 Solr 核心 (獨立模式)
1. 開啟指令提示,並使用下列指令啟動 Solr︰
啟動 Solr (Windows):
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat start
啟動 Solr (Unix):
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh start
其中 <INDEX_SEARCH_HOME> 是安裝索引搜尋伺服器的安裝目錄。
2. 從指令提示下,導覽至 <INDEX_SEARCH_HOME></INDEX_SEARCH_HOME>/solr/bin,並執行下列指令來建立所需模組的核心︰
Windchill Index Search
Windows:
solr.cmd create -c wblib -n wblib -d D:\ptc\IndexSearchServer\SolrServer\solr_schemas\wblib
Unix:
solr create -c wblib -n wblib -d /opt/ptc/IndexSearchServer/SolrServer/solr_schemas/wblib
Windchill PartsLink
Windows:
solr.cmd create -c clfstructurelib -n clfstructurelib -d D:\ptc\IndexSearchServer\SolrServer\solr_schemas\clfstructurelib
Unix:
solr create -c clfstructurelib -n clfstructurelib -d /opt/ptc/IndexSearchServer/SolrServer/solr_schemas/clfstructurelib
S1000D
Windows:
solr.cmd create -c sisaadlib -n sisaadlib -d D:\ptc\IndexSearchServer\SolrServer\solr_schemas\sisaadlib
Unix:
solr create -c sisaadlib -n sisaadlib -d /opt/ptc/IndexSearchServer/SolrServer/solr_schemas/sisaadlib
* 
PTC 建議您建立 Windchill Index SearchWindchill PartsLink 和 S1000D 的核心,即使未安裝選用模組也應建立。因此,如果您日後決定要安裝這些模組,將不需要建立各自的核心。
3. 開啟 Solr 管理員介面,並確認 Solr 正在執行,而且核心可供使用︰
http://<SOLR_HOSTNAME>:<SOLR_PORT>/solr
更新獨立伺服器的 Solr 結構描述 (選用)
若要更新 Solr 結構描述,請完成下列步驟︰
1. 導覽至 <INDEX_SEARCH_HOME>/solr/server/solr,並進行必要的更新。
2. 開啟 Solr 管理員介面,然後選取 Core Admin
3. 選取已更新結構描述的核心,然後按一下 重新載入
配置 Solr 的基本驗證 (獨立模式)
1. 使用下列指令停止 Solr︰
Windows
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat stop
Unix
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh stop
2. 開啟下列檔案︰
<INDEX_SEARCH_HOME>/solr/server/etc/webdefault.xml
接著編輯內容,如下所示 (變更均反白顯示)︰
<security-constraint>
<web-resource-collection>
<web-resource-name>Disable TRACE</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Solr Realm</realm-name>
</login-config>
3. 開啟下列檔案︰
<INDEX_SEARCH_HOME>/solr/server/etc/jetty.xml
在結尾處的 </Configure> 標籤之前新增下一個區段︰
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">Solr Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
<Set name="refreshInterval">0</Set>
</New>
</Arg>
</Call>
4. 使用 Jetty 提供的下列公用程式產生加密格式的密碼︰
a. 開啟指令提示並導覽至 <INDEX_SEARCH_HOME>/solr/server
b. 使用純文字密碼作為引數執行下列指令︰
java -cp lib/jetty-util-9.2.13.v20150730.jar org.eclipse.jetty.util.security.Password <使用者名稱> <密碼>
例如,執行下列指令︰
java -cp lib/jetty-util-9.3.8.v20160314.jar org.eclipse.jetty.util.security.Password solr SolrRocks
導致下列輸出:
* 
PTC 建議使用此工具時以 CRYPT 作為最安全的加密選項。
5. 建立新檔案︰
<INDEX_SEARCH_HOME>/solr/server/etc/realm.properties
使用下列格式,新增在上一步中產生的加密密碼︰
<使用者名稱>: CRYPT:<加密密碼>,<角色>
例如:
solr: CRYPT:so3oR2FANmQ4Y,admin
6. 使用下列指令啟動 Solr︰
Windows
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat start
Unix
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh start
7. 開啟 Solr 管理員介面,並確認系統是否提示您輸入使用者名稱與密碼︰
http://<SOLR_HOSTNAME>:<SOLR_PORT>/solr
變更 Solr 使用者或密碼
您變更 Solr 使用者或密碼時,必須更新 Windchill 索引搜尋用戶端與伺服器。
1. 開啟 Windchill Shell 並執行下列指令來變更 Windchill Index Search 用戶端的密碼或使用者︰
xconfmanager -s wt.index.solrAdminUser=<New_User> -t codebase/WEB-INF/conf/index.solrAuth.properties -p
xconfmanager -s wt.index.solrAdminPassword=<New_Password> -t codebase/WEB-INF/conf/index.solrAuth.properties -p
2. 重新啟動 Windchill
3. 從指令提示下,導覽至 <INDEX_SEARCH_HOME>/bin,並執行下列指令來變更 Windchill Index Search 伺服器的密碼或使用者︰
Windows:
xconfmanager -s wt.index.server.solrAdminUser=<New_User> -t config/solrserver.properties -p
xconfmanager -s wt.index.server.solrAdminPassword=<New_Password> -t config/solrserver.properties -p
Unix:
sh xconfmanager -s wt.index.server.solrAdminUser=<New_User> -t config/solrserver.properties -p
sh xconfmanager -s wt.index.server.solrAdminPassword=<New_Password> -t config/solrserver.properties -p
4. 請依照上方所述的步驟更新 <INDEX_SEARCH_HOME>/solr/server/etc/realm.properties
5. 重新啟動 Solr。
對於獨立索引搜尋伺服器 (Solr) 配置 SSL
開始之前,您必須擁有作為單一檔案轉換為 PEM 格式的憑證和金鑰。
* 
如果沒有僅憑證檔案可供使用,您可以選擇從憑證和金鑰檔案產生一個︰
1. 使用 keytool 公用程式將 JKS 金鑰庫轉換為 PKCS12 格式︰
keytool -importkeystore -srckeystore solr-ssl.keystore.jks -destkeystore solr-ssl.keystore.p12 -srcstoretype jks -deststoretype pkcs12
2. 使用 openssl 指令,將 PKCS12 格式的金鑰庫 (僅包括憑證而不包括金鑰) 轉換為 PEM 格式︰
openssl pkcs12 -nokeys -in solr-ssl.keystore.p12 -out solr-ssl.cacert.pem
配置 Windchill Index Search 用戶端。
1. 開啟 Windchill Shell 並執行下列指令,設定通訊協定為索引搜尋用戶端連接至索引搜尋伺服器時將使用的 HTTPS:
xconfmanager -s wt.index.solrProtocol=https -t codebase/wt.properties -p
2. 重新啟動 Windchill
配置 Windchill Index Search 伺服器
1. 將憑證 (JKS) 檔案複製到 <Index_Search_Home>/solr/server/etc
2. 設定常用的 SSL 相關系統內容。
若要啟動 SSL 設定,請取消註解並更新下列檔案中以 SOLR_SSL_* 開頭的內容集合︰
Windows:bin\solr.in.cmd
例如:
set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
set SOLR_SSL_KEY_STORE_PASSWORD=secret
set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
set SOLR_SSL_TRUST_STORE_PASSWORD=secret
REM Require clients to authenticate
set SOLR_SSL_NEED_CLIENT_AUTH=false
REM Enable clients to authenticate (but not require)
set SOLR_SSL_WANT_CLIENT_AUTH=false
Unix:bin/solr.in.sh
例如:
bin/solr.in.sh example SOLR_SSL_* configuration
SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
SOLR_SSL_KEY_STORE_PASSWORD=secret
SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
SOLR_SSL_TRUST_STORE_PASSWORD=secret
# Require clients to authenticate
SOLR_SSL_NEED_CLIENT_AUTH=false
# Enable clients to authenticate (but not require)
SOLR_SSL_WANT_CLIENT_AUTH=false
其中,"secret" 是建立憑證時指定的密碼。
如果您想要修改 Solr 金鑰倉庫的預設密碼,請執行下列步驟以避免 Solr 伺服器啟動問題:
a. 確定密碼無論在適用於 Windows 的 solr.in.cmd 還是適用於 Unix 的 solr.in.sh 中均正確無誤。
b. 開啟 <INDEX_SEARCH_HOME>/solr/server/etc/jetty-ssl.xml 檔案
c. 以正確的密碼更新下列內容值:
<Set name="KeyStorePassword"><Property name="solr.jetty.keystore.password"
default="<enter the correct password>"/></Set>
<Set name="TrustStorePassword"><Property name="solr.jetty.truststore.password"
default="<enter the correct password>"/></Set>
d. 儲存 jetty-ssl.xml 檔案並啟動 Solr 伺服器。
3. 將憑證檔案新增至 JVM 信任存放區 (僅限 Windchill 的 JDK/JVM)。
a. 導覽至 Windchill 確認 <JAVA>/jre/lib/security 下的 cacerts 檔案路徑所用的 Java 位置。
b. 導覽至 <JAVA>/jre/bin 匯入新的憑證。以對 cacerts 具有寫入權限的使用者身分執行 keytool 公用程式:
keytool -import -file <憑證文件> -alias <唯一性名稱> -keystore <cacerts 文件的路徑>
例如:
keytool -import -file D:\SolrWithSSL\solr-5.4.1\server\etc\solr-ssl.cacert.pem -alias Key_Alias -keystore ../lib/security/cacerts
4. Windchill 配置為使用 SSL 時,在 Windchill 外部使用的任何 Java 用戶端都需要憑證才能連接。
因此,您必須將憑證匯入至由索引搜尋伺服器使用的 JVM。如此可讓索引搜尋伺服器連接至 Windchill 並下載文件以進行索引。
將憑證檔案新增至 JVM 信任存放區 (Solr 伺服器的 JDK/JVM):
a. 導覽至 Solr 伺服器所用的 Java 位置核對 <JAVA>/jre/lib/security 下的 cacerts 檔案路徑。
b. 導覽至 <JAVA>/jre/bin 匯入憑證。以對 cacerts 具有寫入權限的使用者身分執行 keytool 公用程式:
keytool -import -file <憑證文件> -alias <唯一性名稱> -keystore <cacerts 文件的路徑>
例如:
keytool -import -file D:\SolrWithSSL\solr-5.4.1\server\etc\solr-ssl.cacert.pem -alias Key_Alias -keystore ../lib/security/cacerts
* 
JVM 金鑰庫的預設密碼是 "changeit"。
5. 重新啟動 Windchill 與索引搜尋伺服器,然後導覽至 Solr 管理介面來核對 Solr 已執行 SSL。
* 
關於 SSL 的已知問題,請參閱下列網站︰