Red Hat 7.x 配置ArcGIS Enterprise開機(jī)自動(dòng)啟動(dòng)

前言

要想在Red Hat 7.x上配置ArcGIS Datastore、ArcGIS Server、Portal for ArcGIS、WebAdaptor所在的tomcat自動(dòng)啟動(dòng),和之前的版本是不同的。在7之前的版本,參考教程為:

  1. 在Linux環(huán)境下設(shè)置ArcGIS的 Server,Portal和DataStore服務(wù)開機(jī)自啟
  2. Linux下Tomcat開機(jī)自啟

絕對不要嘗試在Red Hat 7.x上使用RedHat6.8上的實(shí)施方案。

一、Portal, Server, Datastore 開機(jī)啟動(dòng)

在開始之前,默認(rèn)您已經(jīng)按照Linux上安裝ArcGIS Enterprise超詳細(xì)教程——以Redhat7.2上安裝ArcGIS Enterprise 10.5為例的步驟將ArcGIS Enterprise安裝完畢。

1.拷貝

用root用戶登錄
將 <Portal for ArcGIS installation directory>/framework/etc/arcgisportal.service 服務(wù)注冊文件復(fù)制到 /etc/systemd/system
將 <ArcGIS Server 安裝目錄>/framework/etc/scripts/arcgisserver.service 單元文件復(fù)制到 /etc/systemd/system
將 <ArcGIS Data Store installation directory>/framework/etc/scripts/arcgisdatastore.service 復(fù)制到 /etc/systemd/system

具體命令:

cp /home/arcgis/arcgis/server/framework/etc/scripts/arcgisserver.service /etc/systemd/system/arcgisserver.service
cp /home/arcgis/arcgis/arcgisportal/framework/etc/arcgisportal.service /etc/systemd/system/arcgisserver.service
cp /home/arcgis/arcgis/arcgisdatastore/framework/etc/arcgisportal.service /etc/systemd/system/arcgisserver.service

2.修改權(quán)限

文件復(fù)制完成后,請確保將其文件權(quán)限設(shè)置為 600。

chmod -R 600 /etc/systemd/system/arcgisserver.service
chmod -R 600 /etc/systemd/system/arcgisportal.service
chmod -R 600 /etc/systemd/system/arcgisdatastore.service

3.配置啟動(dòng)

仍然以root用戶的身份運(yùn)行以下命令,以在 /etc/systemd/system/multi-user.target.wants 中自動(dòng)創(chuàng)建鏈接:

systemctl enable arcgisportal.service
systemctl enable arcgisserver.service
systemctl enable arcgisdatastore.service

4.如果想要驗(yàn)證是否配置正確

先停止了以上的產(chǎn)品。例如各產(chǎn)品安裝目錄下的./stopxxx
利用systemd 重新啟動(dòng)服務(wù)后檢查其狀態(tài)。以ArcGIS Server為例

systemctl stop arcgisserver.service
systemctl start arcgisserver.service
systemctl status arcgisserver.service

可以重啟此服務(wù)器進(jìn)行測試。看Server Datastore Portal服務(wù)能否起來。

reboot

二、Tomcat自動(dòng)啟動(dòng)

同樣的,默認(rèn)您已經(jīng)按照Linux上安裝ArcGIS Enterprise超詳細(xì)教程——以Redhat7.2上安裝ArcGIS Enterprise 10.5為例的步驟將ArcGIS Enterprise安裝完畢。Linux版的ArcGIS WebAdaptor 是運(yùn)行在tomcat 容器里的。所以設(shè)置了tomcat開機(jī)自動(dòng)啟動(dòng)也就實(shí)現(xiàn)了WebAdaptor開機(jī)自動(dòng)啟動(dòng)。
使用root用戶

1.創(chuàng)建pid文件

在tomcat目錄下新建一個(gè)空文件tomcat.pid 命令如下

cd /home/tomcat8
vi tomcat.pid
:wq!

2.設(shè)置tomcat記錄pid

在/home/tomcat8/bin目錄下新建setenv.sh(catalina.sh調(diào)用)

cd /home/tomcat8/bin
vi setenv.sh
$CATALINA_BASE為tomcat安裝的目錄路徑,將tomcat.pid指給了CATALINA_PID
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
:wq

CATALINA_PID 是個(gè)變量,在tomcat啟動(dòng)的時(shí)候會寫入值到tomcat.pid

3.增加systemctl的tomcat服務(wù)

在/etc/systemd/system/目錄下增加tomcat.service,目錄必須是絕對目錄。

cd /etc/systemd/system
vi /tomcat.service
[Unit]
Description=Apache Tomcat 8
After=syslog.target network.target
 
[Service]
Type=forking
PIDFile=/home/tomcat8/tomcat.pid
ExecStart=/home/tomcat8/bin/startup.sh 
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
:wq

設(shè)置600權(quán)限

chmod -R 600 /etc/systemd/system/tomcat.service

4.配置開機(jī)啟動(dòng)

systemctl enable tomcat

5.測試啟動(dòng)tomcat失敗

啟動(dòng)tomcat

systemctl start tomcat
得到報(bào)錯(cuò)為
Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.
查看錯(cuò)誤信息
systemctl status tomcat
● tomcat.service - Tomcat  
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; vendor preset: disabled)  
   Active: failed (Result: exit-code) since 五 2016-12-16 17:52:49 CST; 5s ago  
  Process: 34944 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)  
  Process: 34953 ExecStart=/usr/local/apache-tomcat-8.5.6/bin/startup.sh (code=exited, status=1/FAILURE)  
 Main PID: 34899 (code=exited, status=0/SUCCESS)  
  
12月 16 17:52:49 klmy-460-res01 systemd[1]: Starting Tomcat...  
12月 16 17:52:49 klmy-460-res01 startup.sh[34953]: Neither the JAVA_HOME nor the JRE_HOME environment varia...ined  
12月 16 17:52:49 klmy-460-res01 startup.sh[34953]: At least one of these environment variable is needed to ...gram  
12月 16 17:52:49 klmy-460-res01 systemd[1]: tomcat.service: control process exited, code=exited status=1  
12月 16 17:52:49 klmy-460-res01 systemd[1]: Failed to start Tomcat.  
12月 16 17:52:49 klmy-460-res01 systemd[1]: Unit tomcat.service entered failed state.  
12月 16 17:52:49 klmy-460-res01 systemd[1]: tomcat.service failed.  
Hint: Some lines were ellipsized, use -l to show in full.  

可以看到失敗的原因是 讀不到環(huán)境變量

startup.sh[34953]: Neither the JAVA_HOME nor the JRE_HOME environment varia...ined  
startup.sh[34953]: At least one of these environment variable is needed to ...gram  

而經(jīng)過檢查JAVA_HOME 和JRE_HOME都是正常的。只能強(qiáng)行在catalina.sh里寫入環(huán)境變量。
切換到tomcat bin目錄下

cd /home/tomcat/bin
vi catalina.sh
export JAVA_HOME=/home/jdk8
export JRE_HOME=/home/jdk8/jre  

再執(zhí)行

systemctl start tomcat
systemctl status tomcat

成功。
可以重啟此服務(wù)器進(jìn)行測試。看tomcat服務(wù)能否起來。

reboot
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容