安裝與升級 > 安裝與組態指南 > 使用 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>
設定和啟動 Zookeeper 節點
1. 建立每個 Zookeeper 節點的資料目錄。例如:
Windows:
D:\ptc\commondata\zkdata\node1
D:\ptc\commondata\zkdata\node2
D:\ptc\commondata\zkdata\node3
Unix:
/opt/ptc/commondata/zkdata/node1
/opt/ptc/commondata/zkdata/node2
/opt/ptc/commondata/zkdata/node3
2. 建立名為 "myid" 的檔案來識別 Zookeeper 節點。檔案的目錄應該識別節點。
例如,下列 myid 檔案的目錄可以僅通過編號 1 表示:
Windows:
D:\ptc\commondata\zkdata\node1\myid
Unix:
/opt/ptc/commondata/zkdata/node1/myid
同樣地,輸入 2 可以導覽到 node2/myid,輸入 3 可以導覽到 node3/myid
* 
這些是指派給 Zookeeper 的 ID,將用於下一步中的 zoo.cfg
3. 建立 Zookeeper 組態檔案︰
<INDEX_SEARCH_HOME>\zookeeper\conf\zoo.cfg
其中 <INDEX_SEARCH_HOME> 是安裝索引搜尋伺服器的安裝目錄。
針對 node1 新增下列內容:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=D:\\ptc\\commondata\\zkdata\\node1 OR /opt/ptc/commondata/zkdata/node1
# the port at which the clients will connect
clientPort=<埠號>
server.1=<主機1>.ptcnet.ptc.com:2888:3888
server.2=<主機2>.ptcnet.ptc.com:2889:3889
server.3=<主機3>.ptcnet.ptc.com:2890:3890
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
下列內容應該具唯一性,而且針對每個 Zookeeper 管理員節點指定︰
dataDir
Zookeeper 節點的資料目錄。
clientPort
Zookeeper 接聽請求的埠。
4. 執行下列指令,啟動所有 Zookeeper 節點︰
Windows:
<INDEX_SEARCH_HOME>\zookeeper\bin\zkServer.cmd
Unix:
sh <INDEX_SEARCH_HOME>\zookeeper\bin\zkServer.sh start
* 
啟動 Zookeeper 節點時,會開始與總體組態 (zoo.cfg) 中指定的其他 Zookeeper 節點進行通訊。
啟動時,您可能會看見主控台或記錄檔中的錯誤,報告節點無法連接至其他 Zookeeper 節點。這是因為這些節點尚未啟動。可以忽略這些錯誤。
建立 Solr 核心 (雲端)
* 
請確保您使用 Java 8 或更高版本。否則,請在執行下列指令之前設定 SOLR_JAVA_HOME 環境變數︰
Windows:SET SOLR_JAVA_HOME=<PATH_TO_JAVA_8>
Unix:export SOLR_JAVA_HOME=<PATH_TO_JAVA_8>
1. 開啟指令提示,並使用下列指令啟動 Solr︰
啟動 Solr (Windows):
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat start
停止 Solr (Windows):
<INDEX_SEARCH_HOME>/bin/Index_Search_Server.bat stop
啟動 Solr (Unix):
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh start
停止 Solr (Unix):
sh <INDEX_SEARCH_HOME>/bin/Index_Search_Server.sh stop
其中 <INDEX_SEARCH_HOME> 是安裝索引搜尋伺服器的安裝目錄。
2. 從指令提示下,導覽至 <INDEX_SEARCH_HOME></INDEX_SEARCH_HOME>/solr/bin,並執行下列指令來建立所需模組的核心︰
Windows︰
solr.cmd create -c <集合名稱> -n <ConfigSet 名稱> -d <ConfigSet 路徑> -shards <分區數> -replicationFactor <複本數 (Solr 節點)>
Unix︰
solr create -c <集合名稱> -n <ConfigSet 名稱> -d <ConfigSet 路徑> -shards <分區數> -replicationFactor <複本數 (Solr 節點)>
* 
僅從任何安裝執行指令一次即可。Zookeeper 將使核心可供整個 Solr 雲端使用。
Windchill Index Search
Windows:
solr.cmd create -c wblib -n wblib -d D:\ptc\IndexSearchServer_Solr1\solr_schemas\wblib -shards 1 -replicationFactor 2
Unix:
solr create -c wblib -n wblib -d /opt/ptc/IndexSearchServer_Solr1/solr_schemas/wblib -shards 1 -replicationFactor 2
Windchill PartsLink
Windows:
solr.cmd create -c clfstructurelib -n clfstructurelib -d D:\ptc\IndexSearchServer_Solr1\solr_schemas\clfstructurelib -shards 1 -replicationFactor 2
Unix:
solr create -c clfstructurelib -n clfstructurelib -d /opt/ptc/IndexSearchServer_Solr1/solr_schemas/clfstructurelib -shards 1 -replicationFactor 2
S1000D
Windows:
solr.cmd create -c sisaadlib -n sisaadlib -d D:\ptc\IndexSearchServer_Solr1\solr_schemas\sisaadlib -shards 1 -replicationFactor 2
Unix:
solr create -c sisaadlib -n sisaadlib -d /opt/ptc/IndexSearchServer_Solr1/solr_schemas/sisaadlib -shards 1 -replicationFactor 2
* 
PTC 建議您建立 Windchill Index SearchWindchill PartsLink 和 S1000D 的核心,即使未安裝選用模組也應建立。因此,如果您日後決定要安裝這些模組,將不需要建立各自的核心。
3. 開啟 Solr 管理員介面,並確認 Solr 正在執行,而且核心可供使用︰
http://<SOLR_HOSTNAME>:<SOLR_PORT>/solr
更新雲端模式的 Solr 結構描述 (選用)
若要更新 Solr 結構描述,請完成下列步驟︰
1. 導覽至 <INDEX_SEARCH_HOME>/solr_schemas,並進行必要的更新。
2. 導覽至 <INDEX_SEARCH_HOME>/solr/server/scripts/cloud-scripts,並執行下列指令將更新的結構描述上載至 Zookeeper:
Windows︰
zkcli.bat -cmd upconfig -confname <configset 名稱> -z <逗號分隔的 Zookeeper 主機名稱清單:埠項目> -confdir <schema_config 路徑>
Unix︰
zkcli.sh -cmd upconfig -confname <configset 名稱> -z <逗號分隔的 Zookeeper 主機名稱清單:埠項目> -confdir <schema_config 路徑>
例如:
Windows:
zkcli.bat -cmd upconfig -confname wblib -z host1.ptcnet.ptc.com:2181,host2.ptcnet.ptc.com:2182,host3.ptcnet.ptc.com:2183 -confdir <INDEX_SEARCH_HOME>\solr_schemas\wblib\conf
Unix:
sh zkcli.sh -cmd upconfig -confname wblib -z host1.ptcnet.ptc.com:2181,host2.ptcnet.ptc.com:2182,host3.ptcnet.ptc.com:2183 -confdir <INDEX_SEARCH_HOME>\solr_schemas\wblib\conf
在現有的 Solr 雲端中新增或移除 Solr 節點
新增 Solr 節點
1. 按照 在雲端模式下安裝索引搜尋伺服器 所述安裝索引搜尋伺服器,並對於 Zookeeper 主機、Solr 主機、Solr 資料目錄、Solr 連接埠、Solr 使用者和 Solr 密碼提供適當的輸入。
2. 啟動 Solr 節點。
3. 使用 Solr URL 呼叫下列 API 在這個新節點上建立複本,並將其新增至 Solr 雲端:
<SOLR_URL>/solr/admin/collections?action=ADDREPLICA&collection=<Collection_name>&shard=<shard_name>
例如:
Windchill Index Search:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=ADDREPLICA&collection=wblib&shard=shard1
Windchill PartsLink:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=ADDREPLICA&collection=clfstructurelib&shard=shard1
S1000D:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=ADDREPLICA&collection=sisaadlib&shard=shard1
* 
您也可以包含其他參數來指定應該建立複本的節點。例如:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=ADDREPLICA&collection=wblib&shard=shard1&node=127.0.0.1:9501_solr
移除 Solr 節點
1. 使用 Solr URL 呼叫下列 API 從 Solr 雲端刪除複本:
<SOLR_URL>/solr/admin/collections?action=DELETEREPLICA&collection=<Collection_name>&shard=<shard_name>&replica=<replica_node_naeme>
* 
分區名稱 (shard) 和複本節點名稱 (coreNodeName) 值可以在 <INDEX_SEARCH_HOME>/solr/server/solr/<collection_core_name> 下的 core.properties 檔案中找到。
例如:
Windchill Index Search:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=DELETEREPLICA&collection=wblib&shard=shard1&replica=core_node1
Windchill PartsLink:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=DELETEREPLICA&collection=clfstructurelib&shard=shard1&replica=core_node1
S1000D:
http://host1.ptcnet.ptc.com:9501/solr/admin/collections?action=DELETEREPLICA&collection=sisaadlib&shard=shard1&replica=core_node1
2. 您可以對於已移除的 Solr 節點刪除安裝檔案。
在現有的 Solr 雲端中新增或移除 Zookeeper 節點
新增 Zookeeper 節點
1. 按照在雲模式下安裝索引搜尋伺服器所述安裝索引搜尋伺服器,並對於 Zookeeper 主機、Solr 主機、Solr 資料目錄、Solr 連接埠、Solr 使用者和 Solr 密碼提供適當的輸入。
2. 如「設定與啟動 Zookeeper 節點」部份所述藉由新增 zoo.cfg 配置 Zookeeper 節點。
3. 更新所有現有 Zookeeper 節點的 zoo.cfg 新增新節點的項目。
4. 重新啟動所有 Zookeeper 節點。
5. 更新所有 Solr 節點的 solrserver.properties 以新增新的 Zookeeper 節點:
xconfmanager -s wt.index.zookeeperHosts=<以逗號分隔的 Zookeeper 主機名稱清單:連接埠項目> -t config/solrserver.properties -p
6. 重新啟動所有 Solr 節點。
7. 更新 wt.properties 新增新的 Zookeeper 節點:
xconfmanager -s wt.index.zookeeperHosts=<逗號分隔的 Zookeeper 主機名稱清單:埠項目> -t codebase/wt.properties -p
8. 重新啟動 Windchill
移除 Zookeeper 節點
1. 更新所有現有 Zookeeper 節點的 zoo.cfg 移除節點的項目。
2. 重新啟動所有 Zookeeper 節點。
3. 更新所有 Solr 節點的 solrserver.properties 以移除 Zookeeper 節點:
xconfmanager -s wt.index.zookeeperHosts=<以逗號分隔的 Zookeeper 主機名稱清單:連接埠項目> -t config/solrserver.properties -p
4. 重新啟動所有 Solr 節點。
5. 更新 wt.properties 移除 Zookeeper 節點:
xconfmanager -s wt.index.zookeeperHosts=<逗號分隔的 Zookeeper 主機名稱清單:埠項目> -t codebase/wt.properties -p
6. 重新啟動 Windchill
配置 Solr 的基本驗證 (雲端模式)
1. 開啟指令提示並導覽至 <INDEX_SEARCH_HOME>/solr/server/scripts/cloud-scripts
2. 執行下列指令將 security.json 載入至 Zookeeper 節點總體︰
Windows︰
zkcli.bat -cmd putfile /security.json <INDEX_SEARCH_HOME>/config/solr/security.json -z <逗號分隔的 Zookeeper 主機名稱清單:埠項目>
Unix:
sh zkcli.sh -cmd putfile /security.json <INDEX_SEARCH_HOME>/config/solr/security.json -z <逗號分隔的 Zookeeper 主機名稱清單:埠項目>
* 
每當執行 xconfmanger 設定索引搜尋伺服器的內容時,會以指定的使用者名稱與密碼產生 <INDEX_SEARCH_HOME>/config/solr/security.json。此檔案可以載入 Zookeeper 節點總體來設定或變更 Solr 雲端的驗證資訊。
3. 開啟 Solr 管理員介面,並確認系統是否提示您輸入使用者名稱與密碼︰
http://<SOLR_HOSTNAME>:<SOLR_PORT>/solr
變更 Solr 使用者或密碼
您變更 Solr 使用者或密碼時,您必須更新 Windchill Index Search 用戶端與伺服器。
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>/config/solr/security.json 載入至 Zookeeper 節點總體。
5. 重新啟動 Solr 和 Zookeeper 節點。
對於雲端索引搜尋伺服器 (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
對於 Solr 配置 SSL
對於執行 Solr 伺服器的所有節點配置 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" 是建立憑證時指定的密碼。
3. 開啟 Windchill Shell 並執行下列指令,設定通訊協定為索引搜尋用戶端連接至索引搜尋伺服器時將使用的 HTTPS:
xconfmanager -s wt.index.solrProtocol=https -t codebase/wt.properties -p
4. Windchill 配置為使用 SSL 時,在 Windchill 外部使用的任何 Java 用戶端都需要憑證才能連接。
因此,您必須將憑證匯入至將由 Solr 雲端中的 Solr 節點使用的 JVM。如此可讓 Solr 節點連接至 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
對於 Zookeeper 配置 SSL
1. urlScheme 全叢集內容需要設定為 https,任何 Solr 節點才會啟動。
開啟指令提示並導覽至 <INDEX_SEARCH_HOME>/solr/server/scripts/cloud-scripts,然後執行下列指令︰
Windows:
zkcli.bat -zkhost <逗號分隔的 Zookeeper 主機名稱清單:埠項目> -cmd clusterprop -name urlScheme -val https
例如:
zkcli.bat -zkhost host1.ptcnet.ptc.com:2181,host2.ptcnet.ptc.com:2182,host3.ptcnet.ptc.com:2183 -cmd clusterprop -name urlScheme -val https
Unix:
sh zkcli.sh -zkhost <逗號分隔的 Zookeeper 主機名稱清單:埠項目> -cmd clusterprop -name urlScheme -val https
例如:
sh zkcli.sh -zkhost host1.ptcnet.ptc.com:2181,host2.ptcnet.ptc.com:2182,host3.ptcnet.ptc.com:2183 -cmd clusterprop -name urlScheme -val https
* 
只要 Zookeeper 節點重新啟動,便應執行 urlScheme 指令。
2. 重新啟動 Solr 雲端 (Zookeeper 節點和 Solr 節點),然後導覽至 Solr 管理介面來核對 Solr 已執行 SSL。
* 
關於 SSL 的已知問題,請參閱下列網站︰