先在Centos的虛擬機上操作:
首先安裝 JDK 和 mysql
可以參照之前的文章: https://my.oschina.net/Kxvz/blog/420244
SQL腳本地址: https://github.com/Tencent/Tars/tree/master/cpp/framework/sql
安裝好了之後進入數據庫建庫:
## 這裏我的數據庫帳號密碼是: root 123456
## mysql -u root -p123456
create database db_tars;
create database tars_stat;
create database tars_property;
建好庫之後就導入db_tars.sql到db_tars庫中 (可以參照:https://my.oschina.net/Kxvz/blog/417358)
數據庫方面弄完之後可以開始安裝 resin
## 下載
wget http://www.caucho.com/download/resin-4.0.49.tar.gz
## 解壓出來
tar zxvf resin-4.0.49.tar.gz
解壓好 resin 後就可以去打包tars了.
在開發機上操作:
首先進入 Tars\web 目錄
修改:src\main\resources 下的 app.config.properties 和 tars.conf
app.config.properties
tarsweb.datasource.tars.addr=127.0.0.1:3306
tarsweb.datasource.tars.user=root
tarsweb.datasource.tars.pswd=123456
upload.tgz.path=\opt\app\
tars.conf
<tars>
<application>
#proxy需要的配置
<client>
#地址
locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
sync-invoke-timeout = 20000
#最大超時時間(毫秒)
max-invoke-timeout = 60000
#刷新端口時間間隔(毫秒)
refresh-endpoint-interval = 300000
#模塊間調用[可選]
stat = tars.tarsstat.StatObj
#網絡異步回調線程個數
asyncthread = 3
modulename = tars.system
</client>
</application>
</tars>
完了之後用maven打包: 在Tars\web目錄下使用 cmd 輸入: mvn clean install
打包好了以後可以在Tars\web\target 下得到一個 tars.war
然後把 tars.war 上傳到 Centos的虛擬機上 並復制到 resin-4.0.49\webapps 目錄下
然後進入 resin-4.0.49\conf 目錄中 修改 resin.xml 文件
把:
<host id="" root-directory=".">
<web-app id="/" root-directory="webapps/ROOT"/>
</host>
改為:
<host id="" root-directory=".">
<web-app id="/" document-directory="webapps/tars"/>
</host>
完成後進進入 resin-4.0.49\bin 目錄中:
啟動服務:
./resin.sh start
然後訪問: http://{YourServerIP}:8080
如果訪問不了可能是你的Centos端口被關了 可以自己打開端口或者關閉防火墻
添加端口可以參考 :https://my.oschina.net/Kxvz/blog/900648
關閉防火墻:
systemctl stop firewalld
如此應該可以訪問了::
Tags: tars 可以 datasource resin database 之後
文章來源: