模板配置

模版配置介绍

每个Tars服务启动运行时,必须指定一个模版配置文件,在Tars web管理系统中部署的服务的模版配置由node进行组织生成,若不是在web管理系统上,则需要自己创建一个模版文件。

框架的模版配置文件由父模版、主模版、私有模版配置来组织。

父模版和主模版的配置信息,存放在db_tars/t_profile_template数据表里,表结构如下

模板配置 - 图1

私有模版信息,存放在db_tars/t_server_conf数据表的profile字段里面。

模板配置

注意模版中有db.tars.com时,需要修改成部署数据库的机器ip

tars.default 模板

模版名称:tars.default(所有服务的模版都直接或者间接继承这个模版)

内容:

  1. <tars>
  2. <application>
  3. enableset=${enableset}
  4. setdivision=${setdivision}
  5. <client>
  6. locator=${locator}
  7. sync-invoke-timeout=3000
  8. async-invoke-timeout=5000
  9. refresh-endpoint-interval=60000
  10. stat=tars.tarsstat.StatObj
  11. property=tars.tarsproperty.PropertyObj
  12. report-interval=60000
  13. sample-rate=100000
  14. max-sample-count=50
  15. asyncthread=${asyncthread}
  16. modulename=${modulename}
  17. </client>
  18. <server>
  19. app=${app}
  20. server=${server}
  21. localip=${localip}
  22. local=${local}
  23. basepath=${basepath}
  24. datapath=${datapath}
  25. logpath=${logpath}
  26. logsize=10M
  27. config=tars.tarsconfig.ConfigObj
  28. notify=tars.tarsnotify.NotifyObj
  29. log=tars.tarslog.LogObj
  30. deactivating-timeout=3000
  31. logLevel=DEBUG
  32. </server>
  33. </application>
  34. </tars>

tars.tarsconfig模版

模版名称:tars.tarsconfig(继承tars.default)

内容:

  1. <tars>
  2. <application>
  3. enableset=${enableset}
  4. setdivision=${setdivision}
  5. <client>
  6. locator=${locator}
  7. sync-invoke-timeout=3000
  8. async-invoke-timeout=5000
  9. refresh-endpoint-interval=60000
  10. report-interval=60000
  11. sample-rate=100000
  12. max-sample-count=50
  13. asyncthread=${asyncthread}
  14. modulename=${modulename}
  15. </client>
  16. <server>
  17. app=${app}
  18. server=${server}
  19. localip=${localip}
  20. local=${local}
  21. basepath=${basepath}
  22. datapath=${datapath}
  23. logpath=${logpath}
  24. logsize=10M
  25. config=tars.tarsconfig.ConfigObj
  26. notify=tars.tarsnotify.NotifyObj
  27. log=tars.tarslog.LogObj
  28. deactivating-timeout=3000
  29. logLevel=DEBUG
  30. </server>
  31. </application>
  32. <db>
  33. charset=utf8
  34. dbhost=db.tars.com
  35. dbname=db_tars
  36. dbpass=tars2015
  37. dbport=3306
  38. dbuser=tars
  39. </db>
  40. </tars>

tars.tarslog模版

模版名称:tars.tarslog(继承tars.default)

内容:

  1. <tars>
  2. <application>
  3. enableset=${enableset}
  4. setdivision=${setdivision}
  5. <client>
  6. locator=${locator}
  7. sync-invoke-timeout=3000
  8. async-invoke-timeout=5000
  9. refresh-endpoint-interval=60000
  10. stat=tars.tarsstat.StatObj
  11. property=tars.tarsproperty.PropertyObj
  12. report-interval=60000
  13. sample-rate=100000
  14. max-sample-count=50
  15. asyncthread=${asyncthread}
  16. modulename=${modulename}
  17. </client>
  18. <server>
  19. app=${app}
  20. server=${server}
  21. localip=${localip}
  22. local=${local}
  23. basepath=${basepath}
  24. datapath=${datapath}
  25. logpath=${logpath}
  26. logsize=100000000
  27. config=tars.tarsconfig.ConfigObj
  28. notify=tars.tarsnotify.NotifyObj
  29. log=tars.tarslog.LogObj
  30. deactivating-timeout=3000
  31. logLevel=ERROR
  32. </server>
  33. </application>
  34. <log>
  35. logpath=/usr/local/app/tars/remote_app_log
  36. logthread=10
  37. <format>
  38. hour=xx
  39. </format>
  40. </log>
  41. </tars>

tars.tarsnotify模版

模版名称:tars.tarsnotify(继承tars.default)

内容:

  1. <tars>
  2. sql=CREATE TABLE `${TABLE}` ( `id` int(11) NOT NULL AUTO_INCREMENT, `application` varchar(128) DEFAULT '', `server_name` varchar(128) DEFAULT NULL, `container_name` varchar(128) DEFAULT '' , `node_name` varchar(128) NOT NULL DEFAULT '', `set_name` varchar(16) DEFAULT NULL, `set_area` varchar(16) DEFAULT NULL, `set_group` varchar(16) DEFAULT NULL, `server_id` varchar(100) DEFAULT NULL, `thread_id` varchar(20) DEFAULT NULL, `command` varchar(50) DEFAULT NULL, `result` text, `notifytime` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_name` (`server_name`), KEY `servernoticetime_i_1` (`notifytime`), KEY `indx_1_server_id` (`server_id`), KEY `query_index` (`application`,`server_name`,`node_name`,`set_name`,`set_area`,`set_group`) ) ENGINE\=InnoDB DEFAULT CHARSET\=utf8
  3. <application>
  4. enableset=${enableset}
  5. setdivision=${setdivision}
  6. <client>
  7. locator=${locator}
  8. sync-invoke-timeout=3000
  9. async-invoke-timeout=5000
  10. refresh-endpoint-interval=60000
  11. report-interval=60000
  12. sample-rate=100000
  13. max-sample-count=50
  14. asyncthread=${asyncthread}
  15. modulename=${modulename}
  16. </client>
  17. <server>
  18. app=${app}
  19. server=${server}
  20. localip=${localip}
  21. local=${local}
  22. basepath=${basepath}
  23. datapath=${datapath}
  24. logpath=${logpath}
  25. logsize=10M
  26. config=tars.tarsconfig.ConfigObj
  27. notify=tars.tarsnotify.NotifyObj
  28. log=tars.tarslog.LogObj
  29. deactivating-timeout=3000
  30. logLevel=DEBUG
  31. </server>
  32. </application>
  33. <db>
  34. charset=utf8
  35. dbhost=db.tars.com
  36. dbpass=tars2015
  37. dbport=3306
  38. dbuser=tars
  39. dbname=db_tars
  40. </db>
  41. <hash>
  42. min_block=50
  43. max_block=200
  44. factor=1.5
  45. file_path=./notify
  46. file_size=50000000
  47. max_page_num=30
  48. max_page_size=20
  49. </hash>
  50. </tars>

tars.tarspatch模版

模版名称:tars.tarspatch(继承tars.default)

内容:

  1. <tars>
  2. directory=/usr/local/app/patchs/tars
  3. uploadDirectory=/usr/local/app/patchs/tars.upload
  4. size=100M
  5. <application>
  6. enableset=${enableset}
  7. setdivision=${setdivision}
  8. <client>
  9. locator=${locator}
  10. sync-invoke-timeout=3000
  11. async-invoke-timeout=5000
  12. refresh-endpoint-interval=60000
  13. report-interval=60000
  14. sample-rate=100000
  15. max-sample-count=50
  16. asyncthread=${asyncthread}
  17. modulename=${modulename}
  18. </client>
  19. <server>
  20. app=${app}
  21. server=${server}
  22. localip=${localip}
  23. local=${local}
  24. basepath=${basepath}
  25. datapath=${datapath}
  26. logpath=${logpath}
  27. logsize=10M
  28. config=tars.tarsconfig.ConfigObj
  29. notify=tars.tarsnotify.NotifyObj
  30. log=tars.tarslog.LogObj
  31. deactivating-timeout=3000
  32. logLevel=DEBUG
  33. </server>
  34. </application>
  35. </tars>

tars.tarsproperty模版

模版名称:tars.tarsproperty(继承tars.default)

内容:

  1. <tars>
  2. sql=CREATE TABLE `${TABLE}` (`stattime` timestamp NOT NULL default CURRENT_TIMESTAMP,`f_date` date NOT NULL default '1970-01-01', `f_tflag` varchar(8) NOT NULL default '',`master_name` varchar(128) NOT NULL default '',`master_ip` varchar(16) default NULL,`property_name` varchar(100) default NULL,`set_name` varchar(15) NOT NULL default '',`set_area` varchar(15) NOT NULL default '',`set_id` varchar(15) NOT NULL default '',`policy` varchar(20) default NULL,`value` varchar(255) default NULL, KEY (`f_date`,`f_tflag`,`master_name`,`master_ip`,`property_name`,`policy`),KEY `IDX_MASTER_NAME` (`master_name`),KEY `IDX_MASTER_IP` (`master_ip`),KEY `IDX_TIME` (`stattime`)) ENGINE\=Innodb
  3. <application>
  4. enableset=${enableset}
  5. setdivision=${setdivision}
  6. <client>
  7. locator=${locator}
  8. sync-invoke-timeout=3000
  9. async-invoke-timeout=5000
  10. refresh-endpoint-interval=60000
  11. report-interval=60000
  12. sample-rate=100000
  13. max-sample-count=50
  14. asyncthread=${asyncthread}
  15. modulename=${modulename}
  16. </client>
  17. <server>
  18. app=${app}
  19. server=${server}
  20. localip=${localip}
  21. local=${local}
  22. basepath=${basepath}
  23. datapath=${datapath}
  24. logpath=${logpath}
  25. logsize=10M
  26. config=tars.tarsconfig.ConfigObj
  27. notify=tars.tarsnotify.NotifyObj
  28. log=tars.tarslog.LogObj
  29. deactivating-timeout=3000
  30. logLevel=DEBUG
  31. </server>
  32. </application>
  33. <db>
  34. charset
  35. dbhost=db.tars.com
  36. dbname=tars
  37. dbport=3306
  38. dbuser=tars
  39. dbpass=tars2015
  40. </db>
  41. <multidb>
  42. <db1>
  43. dbhost=db.tars.com
  44. dbname=tars_property
  45. tbname=tars_property_
  46. dbuser=tars
  47. dbpass=tars2015
  48. dbport=3306
  49. charset=utf8
  50. </db1>
  51. <db2>
  52. dbhost=db.tars.com
  53. dbname=tars_property
  54. tbname=tars_property_
  55. dbuser=tars
  56. dbpass=tars2015
  57. dbport=3306
  58. charset=utf8
  59. </db2>
  60. </multidb>
  61. <hashmap>
  62. factor=1.5
  63. file=hashmap.txt
  64. insertInterval=5
  65. maxBlock=200
  66. minBlock=100
  67. size=10M
  68. </hashmap>
  69. <reapSql>
  70. Interval=10
  71. sql=insert ignore into t_master_property select master_name, property_name, policy from ${TABLE} group by master_name, property_name, policy;
  72. </reapSql>
  73. </tars>

tars.tarsstat模版

模版名称:tars.tarsstat(继承tars.default)

内容:

  1. <tars>
  2. sql=CREATE TABLE `${TABLE}`( `stattime` timestamp NOT NULL default CURRENT_TIMESTAMP,`f_date` date NOT NULL default '1970-01-01', `f_tflag` varchar(8) NOT NULL default '',`source_id` varchar(15) default NULL,`master_name` varchar(64) default NULL,`slave_name` varchar(64) default NULL,`interface_name` varchar(64) default NULL,`tars_version` varchar(16) NOT NULL default '',`master_ip` varchar(15) default NULL,`slave_ip` varchar(21) default NULL,`slave_port` int(10) default NULL,`return_value` int(11) default NULL,`succ_count` int(10) unsigned default NULL,`timeout_count` int(10) unsigned default NULL,`exce_count` int(10) unsigned default NULL,`interv_count` varchar(128) default NULL,`total_time` bigint(20) unsigned default NULL,`ave_time` int(10) unsigned default NULL,`maxrsp_time` int(10) unsigned default NULL,`minrsp_time` int(10) unsigned default NULL,PRIMARY KEY (`source_id`,`f_date`,`f_tflag`,`master_name`,`slave_name`,`interface_name`,`master_ip`,`slave_ip`,`slave_port`,`return_value`,`tars_version`),KEY `IDX_TIME` (`stattime`),KEY `IDC_MASTER` (`master_name`),KEY `IDX_INTERFACENAME` (`interface_name`),KEY `IDX_FLAGSLAVE` (`f_tflag`,`slave_name`), KEY `IDX_SLAVEIP` (`slave_ip`),KEY `IDX_SLAVE` (`slave_name`),KEY `IDX_RETVALUE` (`return_value`),KEY `IDX_MASTER_IP` (`master_ip`),KEY `IDX_F_DATE` (`f_date`)) ENGINE\=MyISAM DEFAULT CHARSET\=utf8
  3. enWeighted=1
  4. useolddatabase=0
  5. time_out=600
  6. <application>
  7. enableset=${enableset}
  8. setdivision=${setdivision}
  9. <client>
  10. locator=${locator}
  11. sync-invoke-timeout=3000
  12. async-invoke-timeout=5000
  13. refresh-endpoint-interval=60000
  14. report-interval=60000
  15. sample-rate=100000
  16. max-sample-count=50
  17. asyncthread=${asyncthread}
  18. modulename=${modulename}
  19. </client>
  20. <server>
  21. app=${app}
  22. server=${server}
  23. localip=${localip}
  24. local=${local}
  25. basepath=${basepath}
  26. datapath=${datapath}
  27. logpath=${logpath}
  28. logsize=10M
  29. config=tars.tarsconfig.ConfigObj
  30. notify=tars.tarsnotify.NotifyObj
  31. log=tars.tarslog.LogObj
  32. deactivating-timeout=3000
  33. logLevel=DEBUG
  34. </server>
  35. </application>
  36. <masteripGroup>
  37. tars.tarsstat;1.1.1.1
  38. </masteripGroup>
  39. <hashmap>
  40. masterfile=hashmap_master.txt
  41. slavefile=hashmap_slave.txt
  42. insertInterval=5
  43. enableStatCount=0
  44. size=8M
  45. countsize=1M
  46. </hashmap>
  47. <reapSql>
  48. interval=5
  49. insertDbThreadNum=4
  50. </reapSql>
  51. <multidb>
  52. <db1>
  53. dbhost=db.tars.com
  54. dbname=tars_stat
  55. tbname=tars_stat_
  56. dbuser=tars
  57. dbpass=tars2015
  58. dbport=3306
  59. charset=utf8
  60. </db1>
  61. </multidb>
  62. </tars>

tars.tarsquerystat模版

模版名称:tars.tarsquerystat(继承tars.default)

  1. <tars>
  2. <application>
  3. #是否启用SET分组
  4. enableset=${enableset}
  5. #SET分组的全名.(mtt.s.1)
  6. setdivision=${setdivision}
  7. <client>
  8. #地址
  9. locator =${locator}
  10. #同步调用超时时间,缺省3s(毫秒)
  11. sync-invoke-timeout = 3000
  12. #异步超时时间,缺省5s(毫秒)
  13. async-invoke-timeout =5000
  14. #重新获取服务列表时间间隔(毫秒)
  15. refresh-endpoint-interval = 60000
  16. #模块间调用服务[可选]
  17. stat = tars.tarsstat.StatObj
  18. #属性上报服务[可选]
  19. property = tars.tarsproperty.PropertyObj
  20. #上报间隔时间,默认60s(毫秒)
  21. report-interval = 60000
  22. #stat采样比1:n 例如sample-rate为1000时 采样比为千分之一
  23. sample-rate = 100000
  24. #1分钟内stat最大采样条数
  25. max-sample-count = 50
  26. #网络异步回调线程个数
  27. asyncthread = ${asyncthread}
  28. #模块名称
  29. modulename = ${modulename}
  30. </client>
  31. #定义所有绑定的IP
  32. <server>
  33. #应用名称
  34. app = ${app}
  35. #服务名称
  36. server = ${server}
  37. #本地ip
  38. localip = ${localip}
  39. #本地管理套接字[可选]
  40. local = ${local}
  41. #服务的数据目录,可执行文件,配置文件等
  42. basepath = ${basepath}
  43. #
  44. datapath = ${datapath}
  45. #日志路径
  46. logpath = ${logpath}
  47. #日志大小
  48. logsize = 10M
  49. #日志数量
  50. # lognum = 10
  51. #配置中心的地址[可选]
  52. config = tars.tarsconfig.ConfigObj
  53. #信息中心的地址[可选]
  54. notify = tars.tarsnotify.NotifyObj
  55. #远程LogServer[可选]
  56. log = tars.tarslog.LogObj
  57. #关闭服务时等待时间
  58. deactivating-timeout = 3000
  59. #滚动日志等级默认值
  60. logLevel=DEBUG
  61. </server>
  62. </application>
  63. <countdb>
  64. <db1>
  65. dbhost=db.tars.com
  66. dbname=tars_stat
  67. tbname=tars_stat_
  68. dbuser=tars
  69. dbpass=tars2015
  70. dbport=3306
  71. charset=utf8
  72. </db1>
  73. </countdb>
  74. </tars>
  75. >

tars.tarsqueryproperty 模版

模版名称:tars.tarsqueryproperty(继承tars.default)

<tars>
    <application>
    #是否启用SET分组
    enableset=${enableset}
    #SET分组的全名.(mtt.s.1)
    setdivision=${setdivision}
    <client>
        #地址
        locator =${locator}
        #同步调用超时时间,缺省3s(毫秒)
        sync-invoke-timeout = 3000
        #异步超时时间,缺省5s(毫秒)
        async-invoke-timeout =5000
        #重新获取服务列表时间间隔(毫秒)
        refresh-endpoint-interval = 60000
        #模块间调用服务[可选]
        stat            = tars.tarsstat.StatObj
        #属性上报服务[可选]
        property                    = tars.tarsproperty.PropertyObj
        #上报间隔时间,默认60s(毫秒)
        report-interval            = 60000
        #stat采样比1:n 例如sample-rate为1000时 采样比为千分之一
         sample-rate = 100000
        #1分钟内stat最大采样条数
         max-sample-count = 50

        #网络异步回调线程个数
        asyncthread      = ${asyncthread}
        #模块名称
        modulename      = ${modulename}
    </client>

    #定义所有绑定的IP
    <server>
        #应用名称
        app      = ${app}
        #服务名称
        server  = ${server}
        #本地ip
       localip  = ${localip}

        #本地管理套接字[可选]
        local  = ${local}
        #服务的数据目录,可执行文件,配置文件等
        basepath = ${basepath}
        #
        datapath = ${datapath}
        #日志路径
        logpath  = ${logpath}
        #日志大小
        logsize = 10M
        #日志数量
        #   lognum = 10
        #配置中心的地址[可选]
        config  = tars.tarsconfig.ConfigObj
        #信息中心的地址[可选]
        notify  = tars.tarsnotify.NotifyObj
        #远程LogServer[可选]
        log = tars.tarslog.LogObj
        #关闭服务时等待时间
         deactivating-timeout = 3000
        #滚动日志等级默认值
   logLevel=DEBUG
    </server>          
    </application>
    <countdb>
        <db1>
            dbhost=10.121.108.158
            dbname=tars_property
            tbname=tars_property_
            dbuser=tars
            dbpass=tars2015
            dbport=3306
            charset=utf8
        </db1>
    </countdb>
    </tars>
>

tars.tarsjava.default模版

模版名称:.tars.tarsjava.default(继承tars.default,所有tarsjava服务的模版都直接或者间接继承这个模版)

内容:

<tars>
    <application>
        enableset=${enableset}
        setdivision=${setdivision}
        <client>
            asyncthread=${asyncthread}
            locator=${locator}
            sync-invoke-timeout=3000
            async-invoke-timeout=5000
            refresh-endpoint-interval=60000
            stat=tars.tarsstat.StatObj
            property=tars.tarsproperty.PropertyObj
            report-interval=60000
            modulename=${modulename}
            sample-rate=1000000
            max-sample-count=10
        </client>
        <server>
            deactivating-timeout=2000
            openthreadcontext=0
            threadcontextnum=10000
            threadcontextstack=32768
            logLevel=DEBUG
            app=${app}
            server=${server}
            localip=${localip}
            local=${local}
            basepath=${basepath}
            datapath=${datapath}
            logpath=${logpath}
            loglevel=DEBUG
            logsize=15M
            log=tars.tarslog.LogObj
            config=tars.tarsconfig.ConfigObj
            notify=tars.tarsnotify.NotifyObj
            log=tars.tarslog.LogObj
            mainclass=com.qq.cloud.tars.server.startup.Main
            classpath=${basepath}/conf:${basepath}/lib
            jvmparams=-Dcom.sun.management.jmxremote.ssl\=false -Dcom.sun.management.jmxremote.authenticate\=false -Xms2000m -Xmx2000m -Xmn1000m -Xss1000k -XX:PermSize\=128M -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction\=60 -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:+CMSScavengeBeforeRemark -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction\=0 -verbosegc -XX:+PrintGCDetails -XX:ErrorFile\=${logpath}/${app}/${server}/jvm_error.log
            sessiontimeout=120000
            sessioncheckinterval=60000
            tcpnodelay=true
            udpbuffersize=8192
            charsetname=UTF-8
            backupfiles=bak1;bak2;bak3;conf
        </server>
    </application>
</tars>