引入分布式事务seata,有问题,日志问题,待解决
This commit is contained in:
1 parent
887512c5fe
commit
59fc017933
285 files changed
+3464
No files matched your search
@@ -0,0 +1,274 @@
|
||||
# Script usage demo
|
||||

|
||||
|
||||
## important attributes
|
||||
|
||||
you only need to follow the instructions below and keep the corresponding configuration in 'config.txt' to run. For more configuration information, please visit [seata.io](https://seata.io/)
|
||||
|
||||
| server | client |
|
||||
| ------------------------ | ------------------------------------------------------------ |
|
||||
| store.mode: file,db | config.type: file、nacos 、apollo、zk、consul、etcd3、custom |
|
||||
| #only db: | #only file: |
|
||||
| store.db.driverClassName | service.default.grouplist |
|
||||
| store.db.url | #All: |
|
||||
| store.db.user | service.vgroupMapping.default_tx_group |
|
||||
| store.db.password | service.disableGlobalTransaction |
|
||||
|
||||
## Script Introduction
|
||||
|
||||
The Script has interactive and non-interactive configuration modes,different patterns are distinguished by different file names.
|
||||
|
||||
interactive mode(*-config-interactive.sh or *-config-interactive.py): the script starts the config program in interactive mode on the command line, prompting you for each option.
|
||||
|
||||
non-interactive mode(*-config.sh or *-config.py): the script use additional config options to specify values for the options you choose during interactive mode, thus scripting the config process.
|
||||
|
||||
## Nacos
|
||||
|
||||
shell:
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/nacos/nacos-config-interactive.sh
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode, eg:
|
||||
|
||||
```
|
||||
Please enter the host of nacos.
|
||||
请输入nacos的host [localhost]:
|
||||
>>>
|
||||
Please enter the port of nacos.
|
||||
请输入nacos的port [8848]:
|
||||
>>>
|
||||
Please enter the group of nacos.
|
||||
请输入nacos的group [SEATA_GROUP]:
|
||||
>>>
|
||||
Please enter the tenant of nacos.
|
||||
请输入nacos的tenant:
|
||||
>>>
|
||||
Please enter the username of nacos.
|
||||
请输入nacos的username:
|
||||
>>>
|
||||
Please enter the password of nacos.
|
||||
请输入nacos的password:
|
||||
>>>
|
||||
Are you sure to continue? [y/n]
|
||||
```
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/nacos/nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 5a3c7d6c-f497-4d68-a71a-2e5e3340b3ca -u username -w password
|
||||
```
|
||||
|
||||
python:
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
python ${SEATAPATH}/script/config-center/nacos/nacos-config-interactive.py
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode like nacos-config-interactive.sh.
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
python ${SEATAPATH}/script/config-center/nacos/nacos-config.py localhost:8848
|
||||
```
|
||||
|
||||
Parameter Description:
|
||||
|
||||
-h: host, the default value is localhost.
|
||||
|
||||
-p: port, the default value is 8848.
|
||||
|
||||
-g: Configure grouping, the default value is 'SEATA_GROUP'.
|
||||
|
||||
-t: Tenant information, corresponding to the namespace ID field of Nacos, the default value is ''.
|
||||
|
||||
-u: username, nacos 1.2.0+ on permission control, the default value is ''.
|
||||
|
||||
-w: password, nacos 1.2.0+ on permission control, the default value is ''.
|
||||
|
||||
## Apollo
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/apollo/apollo-config-interactive.sh
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode, eg:
|
||||
|
||||
```
|
||||
Please enter the host of apollo.
|
||||
请输入apollo的host [localhost]:
|
||||
>>>
|
||||
Please enter the port of apollo.
|
||||
请输入apollo的port [8070]:
|
||||
>>>
|
||||
Please enter the env of apollo.
|
||||
请输入apollo的env [DEV]:
|
||||
>>>
|
||||
Please enter the appId of apollo.
|
||||
请输入apollo的appId [seata-server]:
|
||||
>>>
|
||||
Please enter the clusterName of apollo.
|
||||
请输入apollo的clusterName [default]:
|
||||
>>>
|
||||
Please enter the namespaceName of apollo.
|
||||
请输入apollo的namespaceName [application]:
|
||||
>>>
|
||||
Please enter the dataChangeCreatedBy of apollo.
|
||||
请输入apollo的dataChangeCreatedBy:
|
||||
>>>
|
||||
Please enter the releasedBy of apollo.
|
||||
请输入apollo的releasedBy:
|
||||
>>>
|
||||
Please enter the token of apollo.
|
||||
请输入apollo的token:
|
||||
>>>
|
||||
Are you sure to continue? [y/n]
|
||||
```
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/apollo/apollo-config.sh -h localhost -p 8070 -e DEV -a seata-server -c default -n application -d apollo -r apollo -t 3aa026fc8435d0fc4505b345b8fa4578fb646a2c
|
||||
```
|
||||
Parameter Description:
|
||||
|
||||
-h: host, the default value is localhost.
|
||||
|
||||
-p: port, the default value is 8070.
|
||||
|
||||
-e: Managed configuration environment, the default value is DEV.
|
||||
|
||||
-a: AppId to which the namespace belongs, the default value is seata-server.
|
||||
|
||||
-c: Managed configuration cluster name, Generally, you can pass in default. If it is a special cluster, just pass in the name of the corresponding cluster,the default value is default.
|
||||
|
||||
-n: Name of the managed namespace, If the format is not properties, you need to add a suffix name, such as sample.yml, the default value is application.
|
||||
|
||||
-d: The creator of the item, in the format of a domain account, which is the User ID of the sso system.
|
||||
|
||||
-r: Publisher, domain account, note: if namespace.lock.switch in ApolloConfigDB.ServerConfig is set to true (default is false), Then the environment does not allow the publisher and editor to be the same person. So if the editor is zhangsan, the publisher can no longer be zhangsan.
|
||||
|
||||
-t: Apollo admin creates third-party applications in http://{portal_address}/open/manage.html, It is best to check whether this AppId has been created before creation. After successful creation, a token will be generated.
|
||||
|
||||
For details of the above parameter descriptions, please see:
|
||||
|
||||
https://github.com/ctripcorp/apollo/wiki/Apollo%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0
|
||||
|
||||
## Consul
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/consul/consul-config-interactive.sh
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode, eg:
|
||||
|
||||
```
|
||||
Please enter the host of consul.
|
||||
请输入consul的host [localhost]:
|
||||
>>>
|
||||
Please enter the port of consul.
|
||||
请输入consul的port [8500]:
|
||||
>>>
|
||||
Are you sure to continue? [y/n]
|
||||
```
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/consul/consul-config.sh -h localhost -p 8500
|
||||
```
|
||||
|
||||
Parameter Description:
|
||||
|
||||
-h: host, the default value is localhost.
|
||||
|
||||
-p: port, the default value is 8500.
|
||||
|
||||
## Etcd3
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/etcd3/etcd3-config-interactive.sh
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode, eg:
|
||||
|
||||
```
|
||||
Please enter the host of etcd3.
|
||||
请输入etcd3的host [localhost]:"
|
||||
>>>
|
||||
Please enter the port of etcd3.
|
||||
请输入etcd3的port [2379]:
|
||||
>>>
|
||||
Are you sure to continue? [y/n]
|
||||
```
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/etcd3/etcd3-config.sh -h localhost -p 2379
|
||||
```
|
||||
|
||||
Parameter Description:
|
||||
|
||||
-h: host, the default value is localhost.
|
||||
|
||||
-p: port, the default value is 2379.
|
||||
|
||||
## ZK
|
||||
|
||||
- Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/zk/zk-config-interactive.sh
|
||||
```
|
||||
|
||||
This command will generate interactive configuration mode, eg:
|
||||
|
||||
```
|
||||
Please enter the host of zookeeper.
|
||||
请输入zookeeper的host [localhost]:
|
||||
>>>
|
||||
Please enter the port of zookeeper.
|
||||
请输入zookeeper的port [2181]:
|
||||
>>>
|
||||
Please enter the zkHome of zookeeper.
|
||||
请输入zookeeper的zkHome:
|
||||
>>>
|
||||
Are you sure to continue? [y/n]
|
||||
```
|
||||
|
||||
- Non-Interactive Mode
|
||||
|
||||
|
||||
```bash
|
||||
sh ${SEATAPATH}/script/config-center/zk/zk-config.sh -h localhost -p 2181 -z "/Users/zhangchenghui/zookeeper-3.4.14"
|
||||
```
|
||||
Parameter Description:
|
||||
|
||||
-h: host, the default value is localhost.
|
||||
|
||||
-p: port, the default value is 2181.
|
||||
|
||||
-z: zk path.
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# apollo open api, click on the link for details:
|
||||
# https://github.com/ctripcorp/apollo/wiki/Apollo%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0
|
||||
|
||||
# add config: http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items
|
||||
# publish config: http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases
|
||||
|
||||
echo -e "Please enter the host of apollo.\n请输入apollo的host [localhost]:"
|
||||
read -p ">>> " host
|
||||
echo -e "Please enter the port of apollo.\n请输入apollo的port [8070]:"
|
||||
read -p ">>> " port
|
||||
echo -e "Please enter the env of apollo.\n请输入apollo的env [DEV]:"
|
||||
read -p ">>> " env
|
||||
echo -e "Please enter the appId of apollo.\n请输入apollo的appId [seata-server]:"
|
||||
read -p ">>> " appId
|
||||
echo -e "Please enter the clusterName of apollo.\n请输入apollo的clusterName [default]:"
|
||||
read -p ">>> " clusterName
|
||||
echo -e "Please enter the namespaceName of apollo.\n请输入apollo的namespaceName [application]:"
|
||||
read -p ">>> " namespaceName
|
||||
echo -e "Please enter the dataChangeCreatedBy of apollo.\n请输入apollo的dataChangeCreatedBy:"
|
||||
read -p ">>> " dataChangeCreatedBy
|
||||
echo -e "Please enter the releasedBy of apollo.\n请输入apollo的releasedBy:"
|
||||
read -p ">>> " releasedBy
|
||||
echo -e "Please enter the token of apollo.\n请输入apollo的token:"
|
||||
read -p ">>> " token
|
||||
read -p "Are you sure to continue? [y/n]" input
|
||||
case $input in
|
||||
[yY]*)
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=8070
|
||||
fi
|
||||
if [[ -z ${env} ]]; then
|
||||
env=DEV
|
||||
fi
|
||||
if [[ -z ${appId} ]]; then
|
||||
appId=seata-server
|
||||
fi
|
||||
if [[ -z ${clusterName} ]]; then
|
||||
clusterName=default
|
||||
fi
|
||||
if [[ -z ${namespaceName} ]]; then
|
||||
namespaceName=application
|
||||
fi
|
||||
if [[ -z ${dataChangeCreatedBy} ]]; then
|
||||
echo " dataChangeCreatedBy is empty, please input it "
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z ${releasedBy} ]]; then
|
||||
echo " releasedBy is empty, please input it "
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z ${token} ]]; then
|
||||
echo " token is empty, please input it "
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
[nN]*)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Just enter y or n, please."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
portalAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
authorization="Authorization:$token"
|
||||
publishBody="{\"releaseTitle\":\"$(date +%Y%m%d%H%M%S)\",\"releaseComment\":\"\",\"releasedBy\":\"${releasedBy}\"}"
|
||||
|
||||
echo "portalAddr is ${portalAddr}"
|
||||
echo "env is ${env}"
|
||||
echo "appId is ${appId}"
|
||||
echo "clusterName is ${clusterName}"
|
||||
echo "namespaceName is ${namespaceName}"
|
||||
echo "dataChangeCreatedBy is ${dataChangeCreatedBy}"
|
||||
echo "releasedBy is ${releasedBy}"
|
||||
echo "token is ${token}"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
curl -X POST -H "${1}" -H "${2}" -d "${3}" "http://${4}/openapi/v1/envs/${5}/apps/${6}/clusters/${7}/namespaces/${8}/items" >"${tempLog}" 2>/dev/null
|
||||
log=$(cat "${tempLog}")
|
||||
if [[ ${log} =~ ":401" || ${log} =~ ":403"
|
||||
|| ${log} =~ ":404" || ${log} =~ ":405"
|
||||
|| ${log} =~ ":500" || ! ${log} =~ "{" ]]; then
|
||||
echo "set $9=${10} failure "
|
||||
(( failCount++ ))
|
||||
else
|
||||
echo "set $9=${10} successfully "
|
||||
fi
|
||||
}
|
||||
|
||||
function publishConfig() {
|
||||
curl -X POST -H "${1}" -H "${2}" -d "${3}" "http://${4}/openapi/v1/envs/${5}/apps/${6}/clusters/${7}/namespaces/${8}/releases" >"${tempLog}" 2>/dev/null
|
||||
log=$(cat "${tempLog}")
|
||||
if [[ ${log} =~ ":401" || ${log} =~ ":403"
|
||||
|| ${log} =~ ":404" || ${log} =~ ":405"
|
||||
|| ${log} =~ ":500" || ! ${log} =~ "{" ]]; then
|
||||
echo " Publish fail "
|
||||
exit 1
|
||||
else
|
||||
echo " Publish successfully, please start seata-server. "
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
body="{\"key\":\"${key}\",\"value\":\"${value}\",\"comment\":\"\",\"dataChangeCreatedBy\":\"${dataChangeCreatedBy}\"}"
|
||||
addConfig ${contentType} "${authorization}" "${body}" "${portalAddr}" "${env}" "${appId}" "${clusterName}" "${namespaceName}" "${key}" "${value}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ $failCount -eq 0 ]]; then
|
||||
read -p "Publish now, y/n: " result
|
||||
if [[ ${result} == "y" ]]; then
|
||||
publishConfig "${contentType}" "${authorization}" "${publishBody}" "${portalAddr}" "${env}" "${appId}" "${clusterName}" "${namespaceName}"
|
||||
else
|
||||
echo "Remember to publish later..."
|
||||
fi
|
||||
else
|
||||
echo " init apollo config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# apollo open api, click on the link for details:
|
||||
# https://github.com/ctripcorp/apollo/wiki/Apollo%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0
|
||||
|
||||
# add config: http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items
|
||||
# publish config: http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases
|
||||
|
||||
while getopts ":h:p:e:a:c:n:d:r:t:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
e)
|
||||
env=$OPTARG
|
||||
;;
|
||||
a)
|
||||
appId=$OPTARG
|
||||
;;
|
||||
c)
|
||||
clusterName=$OPTARG
|
||||
;;
|
||||
n)
|
||||
namespaceName=$OPTARG
|
||||
;;
|
||||
d)
|
||||
dataChangeCreatedBy=$OPTARG
|
||||
;;
|
||||
r)
|
||||
releasedBy=$OPTARG
|
||||
;;
|
||||
t)
|
||||
token=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] [-e env] [a appId] [-c clusterName] [-n namespaceName] [-d dataChangeCreatedBy] [-r releasedBy] [-t token] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=8070
|
||||
fi
|
||||
if [[ -z ${env} ]]; then
|
||||
env=DEV
|
||||
fi
|
||||
if [[ -z ${appId} ]]; then
|
||||
appId=seata-server
|
||||
fi
|
||||
if [[ -z ${clusterName} ]]; then
|
||||
clusterName=default
|
||||
fi
|
||||
if [[ -z ${namespaceName} ]]; then
|
||||
namespaceName=application
|
||||
fi
|
||||
if [[ -z ${dataChangeCreatedBy} ]]; then
|
||||
echo " dataChangeCreatedBy is empty, please usage option: [-d dataChangeCreatedBy] "
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z ${releasedBy} ]]; then
|
||||
echo " releasedBy is empty, please usage option: [-r releasedBy] "
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z ${token} ]]; then
|
||||
echo " token is empty, please usage option: [-t token] "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
portalAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
authorization="Authorization:$token"
|
||||
publishBody="{\"releaseTitle\":\"$(date +%Y%m%d%H%M%S)\",\"releaseComment\":\"\",\"releasedBy\":\"${releasedBy}\"}"
|
||||
|
||||
echo "portalAddr is ${portalAddr}"
|
||||
echo "env is ${env}"
|
||||
echo "appId is ${appId}"
|
||||
echo "clusterName is ${clusterName}"
|
||||
echo "namespaceName is ${namespaceName}"
|
||||
echo "dataChangeCreatedBy is ${dataChangeCreatedBy}"
|
||||
echo "releasedBy is ${releasedBy}"
|
||||
echo "token is ${token}"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
curl -X POST -H "${1}" -H "${2}" -d "${3}" "http://${4}/openapi/v1/envs/${5}/apps/${6}/clusters/${7}/namespaces/${8}/items" >"${tempLog}" 2>/dev/null
|
||||
log=$(cat "${tempLog}")
|
||||
if [[ ${log} =~ ":401" || ${log} =~ ":403"
|
||||
|| ${log} =~ ":404" || ${log} =~ ":405"
|
||||
|| ${log} =~ ":500" || ! ${log} =~ "{" ]]; then
|
||||
echo "set $9=${10} failure "
|
||||
(( failCount++ ))
|
||||
else
|
||||
echo "set $9=${10} successfully "
|
||||
fi
|
||||
}
|
||||
|
||||
function publishConfig() {
|
||||
curl -X POST -H "${1}" -H "${2}" -d "${3}" "http://${4}/openapi/v1/envs/${5}/apps/${6}/clusters/${7}/namespaces/${8}/releases" >"${tempLog}" 2>/dev/null
|
||||
log=$(cat "${tempLog}")
|
||||
if [[ ${log} =~ ":401" || ${log} =~ ":403"
|
||||
|| ${log} =~ ":404" || ${log} =~ ":405"
|
||||
|| ${log} =~ ":500" || ! ${log} =~ "{" ]]; then
|
||||
echo " Publish fail "
|
||||
exit 1
|
||||
else
|
||||
echo " Publish successfully, please start seata-server. "
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
body="{\"key\":\"${key}\",\"value\":\"${value}\",\"comment\":\"\",\"dataChangeCreatedBy\":\"${dataChangeCreatedBy}\"}"
|
||||
addConfig ${contentType} "${authorization}" "${body}" "${portalAddr}" "${env}" "${appId}" "${clusterName}" "${namespaceName}" "${key}" "${value}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ $failCount -eq 0 ]]; then
|
||||
read -p "Publish now, y/n: " result
|
||||
if [[ ${result} == "y" ]]; then
|
||||
publishConfig "${contentType}" "${authorization}" "${publishBody}" "${portalAddr}" "${env}" "${appId}" "${clusterName}" "${namespaceName}"
|
||||
else
|
||||
echo "Remember to publish later..."
|
||||
fi
|
||||
else
|
||||
echo " init apollo config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,153 @@
|
||||
#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
|
||||
#Transport configuration, for client and server
|
||||
transport.type=TCP
|
||||
transport.server=NIO
|
||||
transport.heartbeat=true
|
||||
transport.enableTmClientBatchSendRequest=false
|
||||
transport.enableRmClientBatchSendRequest=true
|
||||
transport.enableTmClientChannelCheckFailFast=true
|
||||
transport.enableRmClientChannelCheckFailFast=true
|
||||
transport.enableTcServerBatchSendResponse=false
|
||||
transport.rpcRmRequestTimeout=30000
|
||||
transport.rpcTmRequestTimeout=30000
|
||||
transport.rpcTcRequestTimeout=30000
|
||||
transport.threadFactory.bossThreadPrefix=NettyBoss
|
||||
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
|
||||
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
|
||||
transport.threadFactory.shareBossWorker=false
|
||||
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
|
||||
transport.threadFactory.clientSelectorThreadSize=1
|
||||
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
|
||||
transport.threadFactory.bossThreadSize=1
|
||||
transport.threadFactory.workerThreadSize=default
|
||||
transport.shutdown.wait=3
|
||||
transport.serialization=seata
|
||||
transport.compressor=none
|
||||
|
||||
#Transaction routing rules configuration, only for the client
|
||||
service.vgroupMapping.default_tx_group=default
|
||||
#If you use a registry, you can ignore it
|
||||
service.default.grouplist=127.0.0.1:8091
|
||||
service.enableDegrade=false
|
||||
service.disableGlobalTransaction=false
|
||||
|
||||
client.metadataMaxAgeMs=30000
|
||||
#Transaction rule configuration, only for the client
|
||||
client.rm.asyncCommitBufferLimit=10000
|
||||
client.rm.lock.retryInterval=10
|
||||
client.rm.lock.retryTimes=30
|
||||
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
|
||||
client.rm.reportRetryCount=5
|
||||
client.rm.tableMetaCheckEnable=true
|
||||
client.rm.tableMetaCheckerInterval=60000
|
||||
client.rm.sqlParserType=druid
|
||||
client.rm.reportSuccessEnable=false
|
||||
client.rm.sagaBranchRegisterEnable=false
|
||||
client.rm.sagaJsonParser=fastjson
|
||||
client.rm.tccActionInterceptorOrder=-2147482648
|
||||
client.rm.sqlParserType=druid
|
||||
client.tm.commitRetryCount=5
|
||||
client.tm.rollbackRetryCount=5
|
||||
client.tm.defaultGlobalTransactionTimeout=60000
|
||||
client.tm.degradeCheck=false
|
||||
client.tm.degradeCheckAllowTimes=10
|
||||
client.tm.degradeCheckPeriod=2000
|
||||
client.tm.interceptorOrder=-2147482648
|
||||
client.undo.dataValidation=true
|
||||
client.undo.logSerialization=jackson
|
||||
client.undo.onlyCareUpdateColumns=true
|
||||
server.undo.logSaveDays=7
|
||||
server.undo.logDeletePeriod=86400000
|
||||
client.undo.logTable=undo_log
|
||||
client.undo.compress.enable=true
|
||||
client.undo.compress.type=zip
|
||||
client.undo.compress.threshold=64k
|
||||
#For TCC transaction mode
|
||||
tcc.fence.logTableName=tcc_fence_log
|
||||
tcc.fence.cleanPeriod=1h
|
||||
# You can choose from the following options: fastjson, jackson, gson
|
||||
tcc.contextJsonParserType=fastjson
|
||||
|
||||
#Log rule configuration, for client and server
|
||||
log.exceptionRate=100
|
||||
|
||||
#Transaction storage configuration, only for the server. The file, db, and redis configuration values are optional.
|
||||
store.mode=db
|
||||
store.lock.mode=db
|
||||
store.session.mode=db
|
||||
#Used for password encryption
|
||||
store.publicKey=
|
||||
|
||||
#If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
|
||||
store.file.dir=file_store/data
|
||||
store.file.maxBranchSessionSize=16384
|
||||
store.file.maxGlobalSessionSize=512
|
||||
store.file.fileWriteBufferCacheSize=16384
|
||||
store.file.flushDiskMode=async
|
||||
store.file.sessionReloadReadSize=100
|
||||
|
||||
#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
|
||||
store.db.datasource=druid
|
||||
store.db.dbType=mysql
|
||||
store.db.driverClassName=com.mysql.jdbc.Driver
|
||||
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
|
||||
store.db.user=root
|
||||
store.db.password=root
|
||||
store.db.minConn=5
|
||||
store.db.maxConn=30
|
||||
store.db.globalTable=global_table
|
||||
store.db.branchTable=branch_table
|
||||
store.db.distributedLockTable=distributed_lock
|
||||
store.db.queryLimit=100
|
||||
store.db.lockTable=lock_table
|
||||
store.db.maxWait=5000
|
||||
|
||||
#These configurations are required if the `store mode` is `redis`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `redis`, you can remove the configuration block.
|
||||
store.redis.mode=single
|
||||
store.redis.type=pipeline
|
||||
store.redis.single.host=127.0.0.1
|
||||
store.redis.single.port=6379
|
||||
store.redis.sentinel.masterName=
|
||||
store.redis.sentinel.sentinelHosts=
|
||||
store.redis.sentinel.sentinelPassword=
|
||||
store.redis.maxConn=10
|
||||
store.redis.minConn=1
|
||||
store.redis.maxTotal=100
|
||||
store.redis.database=0
|
||||
store.redis.password=
|
||||
store.redis.queryLimit=100
|
||||
|
||||
#Transaction rule configuration, only for the server
|
||||
server.recovery.committingRetryPeriod=1000
|
||||
server.recovery.asynCommittingRetryPeriod=1000
|
||||
server.recovery.rollbackingRetryPeriod=1000
|
||||
server.recovery.timeoutRetryPeriod=1000
|
||||
server.maxCommitRetryTimeout=-1
|
||||
server.maxRollbackRetryTimeout=-1
|
||||
server.rollbackRetryTimeoutUnlockEnable=false
|
||||
server.distributedLockExpireTime=10000
|
||||
server.session.branchAsyncQueueSize=5000
|
||||
server.session.enableBranchAsyncRemove=false
|
||||
server.enableParallelRequestHandle=true
|
||||
server.enableParallelHandleBranch=false
|
||||
|
||||
server.raft.cluster=127.0.0.1:7091,127.0.0.1:7092,127.0.0.1:7093
|
||||
server.raft.snapshotInterval=600
|
||||
server.raft.applyBatch=32
|
||||
server.raft.maxAppendBufferSize=262144
|
||||
server.raft.maxReplicatorInflightMsgs=256
|
||||
server.raft.disruptorBufferSize=16384
|
||||
server.raft.electionTimeoutMs=2000
|
||||
server.raft.reporterEnabled=false
|
||||
server.raft.reporterInitialDelay=60
|
||||
server.raft.serialization=jackson
|
||||
server.raft.compressor=none
|
||||
server.raft.sync=true
|
||||
|
||||
|
||||
|
||||
#Metrics configuration, only for the server
|
||||
metrics.enabled=false
|
||||
metrics.registryType=compact
|
||||
metrics.exporterList=prometheus
|
||||
metrics.exporterPrometheusPort=9898
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
echo -e "Please enter the host of consul.\n请输入consul的host [localhost]:"
|
||||
read -p ">>> " host
|
||||
echo -e "Please enter the port of consul.\n请输入consul的port [8500]:"
|
||||
read -p ">>> " port
|
||||
read -p "Are you sure to continue? [y/n]" input
|
||||
case $input in
|
||||
[yY]*)
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=8500
|
||||
fi
|
||||
;;
|
||||
[nN]*)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Just enter y or n, please."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
consulAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
echo "Set consulAddr=$consulAddr"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
curl -X PUT -H "${1}" -d "${2}" "http://$3/v1/kv/$4" >"${tempLog}" 2>/dev/null
|
||||
if [[ -z $(cat "${tempLog}") ]]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(cat "${tempLog}") =~ "true" ]]; then
|
||||
echo "Set $4=$2 successfully "
|
||||
else
|
||||
echo "Set $4=$2 failure "
|
||||
(( failCount++ ))
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${contentType}" "${value}" "${consulAddr}" "${key}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ ${failCount} -eq 0 ]]; then
|
||||
echo " Init consul config finished, please start seata-server. "
|
||||
else
|
||||
echo " Init consul config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
while getopts ":h:p:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=8500
|
||||
fi
|
||||
|
||||
consulAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
echo "Set consulAddr=$consulAddr"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
curl -X PUT -H "${1}" -d "${2}" "http://$3/v1/kv/$4" >"${tempLog}" 2>/dev/null
|
||||
if [[ -z $(cat "${tempLog}") ]]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(cat "${tempLog}") =~ "true" ]]; then
|
||||
echo "Set $4=$2 successfully "
|
||||
else
|
||||
echo "Set $4=$2 failure "
|
||||
(( failCount++ ))
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${contentType}" "${value}" "${consulAddr}" "${key}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ ${failCount} -eq 0 ]]; then
|
||||
echo " Init consul config finished, please start seata-server. "
|
||||
else
|
||||
echo " Init consul config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# etcd REST API v3.
|
||||
# author:wangyuewen
|
||||
|
||||
# shellcheck disable=SC2039,SC2162,SC2046,SC2013,SC2002
|
||||
echo -e "Please enter the host of etcd3.\n请输入etcd3的host [localhost]:"
|
||||
read -p ">>> " host
|
||||
echo -e "Please enter the port of etcd3.\n请输入etcd3的port [2379]:"
|
||||
read -p ">>> " port
|
||||
read -p "Are you sure to continue? [y/n]" input
|
||||
case $input in
|
||||
[yY]*)
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=2379
|
||||
fi
|
||||
;;
|
||||
[nN]*)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Just enter y or n, please."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
etcd3Addr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
echo "Set etcd3Addr=$etcd3Addr"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
keyBase64=$(printf "%s""$2" | base64)
|
||||
valueBase64=$(printf "%s""$3" | base64)
|
||||
curl -X POST -H "${1}" -d "{\"key\": \"$keyBase64\", \"value\": \"$valueBase64\"}" "http://$4/v3/kv/put" >"${tempLog}" 2>/dev/null
|
||||
if [[ -z $(cat "${tempLog}") ]]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(cat "${tempLog}") =~ "error" || $(cat "${tempLog}") =~ "code" ]]; then
|
||||
echo "Set $2=$3 failure "
|
||||
(( failCount++ ))
|
||||
else
|
||||
echo "Set $2=$3 successfully "
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${contentType}" "${key}" "${value}" "${etcd3Addr}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ ${failCount} -eq 0 ]]; then
|
||||
echo " Init etcd3 config finished, please start seata-server. "
|
||||
else
|
||||
echo " Init etcd3 config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# etcd REST API v3.
|
||||
|
||||
while getopts ":h:p:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=2379
|
||||
fi
|
||||
|
||||
etcd3Addr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
echo "Set etcd3Addr=$etcd3Addr"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
keyBase64=$(printf "%s""$2" | base64)
|
||||
valueBase64=$(printf "%s""$3" | base64)
|
||||
curl -X POST -H "${1}" -d "{\"key\": \"$keyBase64\", \"value\": \"$valueBase64\"}" "http://$4/v3/kv/put" >"${tempLog}" 2>/dev/null
|
||||
if [[ -z $(cat "${tempLog}") ]]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(cat "${tempLog}") =~ "error" || $(cat "${tempLog}") =~ "code" ]]; then
|
||||
echo "Set $2=$3 failure "
|
||||
(( failCount++ ))
|
||||
else
|
||||
echo "Set $2=$3 successfully "
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${contentType}" "${key}" "${value}" "${etcd3Addr}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ ${failCount} -eq 0 ]]; then
|
||||
echo " Init etcd3 config finished, please start seata-server. "
|
||||
else
|
||||
echo " Init etcd3 config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
# @Author : wangyeuwen
|
||||
import http.client
|
||||
import urllib.parse
|
||||
import re
|
||||
|
||||
|
||||
def get_params() -> dict:
|
||||
params = {
|
||||
'host': '127.0.0.1',
|
||||
'port': '8848',
|
||||
'tenant': '',
|
||||
'group': 'SEATA_GROUP',
|
||||
'username': '',
|
||||
'password': ''
|
||||
}
|
||||
host = input("Please enter the host of nacos.\n请输入nacos的host [localhost]\n>>> ")
|
||||
port = input("Please enter the port of nacos.\n请输入nacos的port [8848]\n>>> ")
|
||||
group = input("Please enter the group of nacos.\n请输入nacos的group [SEATA_GROUP]\n>>> ")
|
||||
tenant = input("Please enter the tenant of nacos.\n请输入nacos的tenant\n>>> ")
|
||||
username = input("Please enter the username of nacos.\n请输入nacos的username\n>>> ")
|
||||
password = input("Please enter the password of nacos.\n请输入nacos的password\n>>> ")
|
||||
confirm = input("Are you sure to continue? [y/n]")
|
||||
if confirm[0] == 'y' or confirm[0] == 'Y':
|
||||
if len(host) != 0: params['host'] = host
|
||||
if len(port) != 0: params['port'] = port
|
||||
if len(group) != 0: params['group'] = group
|
||||
if len(tenant) != 0: params['tenant'] = tenant
|
||||
if len(username) != 0: params['username'] = username
|
||||
if len(password) != 0: params['password'] = password
|
||||
elif confirm[0] == 'n' or confirm[0] == 'N':
|
||||
exit()
|
||||
else:
|
||||
print("Just enter y or n, please.")
|
||||
exit()
|
||||
|
||||
return params
|
||||
|
||||
|
||||
def error_exit():
|
||||
print(' init nacos config fail.')
|
||||
exit()
|
||||
|
||||
|
||||
def get_pair(line: str) -> tuple:
|
||||
res = re.match(r"([\.\w]+)=(.*)", line)
|
||||
return res.groups() if res is not None else ['', '']
|
||||
|
||||
|
||||
headers = {
|
||||
'content-type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
|
||||
hasError = False
|
||||
|
||||
params = get_params()
|
||||
|
||||
url_prefix = f"{params['host']}:{params['port']}"
|
||||
tenant = params['tenant']
|
||||
username = params['username']
|
||||
password = params['password']
|
||||
group = params['group']
|
||||
url_postfix_base = f'/nacos/v1/cs/configs?group={group}&tenant={tenant}'
|
||||
|
||||
if username != '' and password != '':
|
||||
url_postfix_base += f'&username={username}&password={password}'
|
||||
|
||||
if url_prefix == ':':
|
||||
error_exit()
|
||||
|
||||
for line in open('../config.txt'):
|
||||
pair = get_pair(line.rstrip("\n"))
|
||||
if len(pair) < 2 or pair[0] == '' or pair[0].startswith("#") or pair[1] == '':
|
||||
continue
|
||||
url_postfix = url_postfix_base + f'&dataId={urllib.parse.quote(str(pair[0]))}&content={urllib.parse.quote(str(pair[1])).strip()}'
|
||||
conn = http.client.HTTPConnection(url_prefix)
|
||||
conn.request("POST", url_postfix, headers=headers)
|
||||
res = conn.getresponse()
|
||||
data = res.read().decode("utf-8")
|
||||
if data != "true":
|
||||
hasError = True
|
||||
print(f"{pair[0]}={pair[1]} {data if hasError else 'success'}")
|
||||
|
||||
if hasError:
|
||||
print("init nacos config fail.")
|
||||
else:
|
||||
print("init nacos config finished, please start seata-server.")
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/bin/sh
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# author:wangyuewen
|
||||
|
||||
# shellcheck disable=SC2039,SC2162,SC2046,SC2013,SC2002,SC2086
|
||||
echo -e "Please enter the host of nacos.\n请输入nacos的host [localhost]:"
|
||||
read -p ">>> " host
|
||||
echo -e "Please enter the port of nacos.\n请输入nacos的port [8848]:"
|
||||
read -p ">>> " port
|
||||
echo -e "Please enter the group of nacos.\n请输入nacos的group [SEATA_GROUP]:"
|
||||
read -p ">>> " group
|
||||
echo -e "Please enter the tenant of nacos.\n请输入nacos的tenant:"
|
||||
read -p ">>> " tenant
|
||||
echo -e "Please enter the username of nacos.\n请输入nacos的username:"
|
||||
read -p ">>> " username
|
||||
echo -e "Please enter the password of nacos.\n请输入nacos的password:"
|
||||
read -p ">>> " password
|
||||
|
||||
read -p "Are you sure to continue? [y/n]" input
|
||||
case $input in
|
||||
[yY]*)
|
||||
if [ -z ${host} ]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [ -z ${port} ]; then
|
||||
port=8848
|
||||
fi
|
||||
if [ -z ${group} ]; then
|
||||
group="SEATA_GROUP"
|
||||
fi
|
||||
if [ -z ${tenant} ]; then
|
||||
tenant=""
|
||||
fi
|
||||
if [ -z ${username} ]; then
|
||||
username=""
|
||||
fi
|
||||
if [ -z ${password} ]; then
|
||||
password=""
|
||||
fi
|
||||
;;
|
||||
[nN]*)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Just enter y or n, please."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
nacosAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
|
||||
echo "set nacosAddr=$nacosAddr"
|
||||
echo "set group=$group"
|
||||
|
||||
urlencode() {
|
||||
length="${#1}"
|
||||
i=0
|
||||
while [ $length -gt $i ]; do
|
||||
char="${1:$i:1}"
|
||||
case $char in
|
||||
[a-zA-Z0-9.~_-]) printf $char ;;
|
||||
*) printf '%%%02X' "'$char" ;;
|
||||
esac
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
}
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
addConfig() {
|
||||
dataId=`urlencode $1`
|
||||
content=`urlencode $2`
|
||||
curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$dataId&group=$group&content=$content&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null
|
||||
if [ -z $(cat "${tempLog}") ]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(cat "${tempLog}")" == "true" ]; then
|
||||
echo "Set $1=$2 successfully "
|
||||
else
|
||||
echo "Set $1=$2 failure "
|
||||
failCount=`expr $failCount + 1`
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
count=`expr $count + 1`
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${key}" "${value}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [ ${failCount} -eq 0 ]; then
|
||||
echo " Init nacos config finished, please start seata-server. "
|
||||
else
|
||||
echo " init nacos config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
import http.client
|
||||
import sys
|
||||
import getopt as opts
|
||||
import urllib.parse
|
||||
import re
|
||||
|
||||
|
||||
def get_params() -> dict:
|
||||
params = {
|
||||
'-h': '127.0.0.1',
|
||||
'-p': '8848',
|
||||
'-t': '',
|
||||
'-g': 'SEATA_GROUP',
|
||||
'-u': '',
|
||||
'-w': ''
|
||||
}
|
||||
inputs, args = opts.getopt(sys.argv[1:], shortopts='h:p:t:g:u:w:')
|
||||
for k, v in inputs:
|
||||
params[k] = v
|
||||
print(params)
|
||||
return params
|
||||
|
||||
def error_exit():
|
||||
print('python nacos-config.py [-h host] [-p port] [-t tenant] [-g group] [-u username] [-w password]')
|
||||
exit()
|
||||
|
||||
def get_pair(line: str) -> tuple:
|
||||
res = re.match(r"([\.\w]+)=(.*)",line)
|
||||
return res.groups() if res is not None else ['','']
|
||||
|
||||
|
||||
headers = {
|
||||
'content-type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
|
||||
hasError = False
|
||||
|
||||
params = get_params()
|
||||
|
||||
url_prefix = f"{params['-h']}:{params['-p']}"
|
||||
tenant = params['-t']
|
||||
username = params['-u']
|
||||
password = params['-w']
|
||||
group = params['-g']
|
||||
url_postfix_base = f'/nacos/v1/cs/configs?group={group}&tenant={tenant}'
|
||||
|
||||
if username != '' and password != '':
|
||||
url_postfix_base += f'&username={username}&password={password}'
|
||||
|
||||
if url_prefix == ':':
|
||||
error_exit()
|
||||
|
||||
for line in open('../config.txt'):
|
||||
pair = get_pair(line.rstrip("\n"))
|
||||
if len(pair) < 2 or pair[0] == '' or pair[0].startswith("#") or pair[1] == '':
|
||||
continue
|
||||
url_postfix = url_postfix_base + f'&dataId={urllib.parse.quote(str(pair[0]))}&content={urllib.parse.quote(str(pair[1])).strip()}'
|
||||
conn = http.client.HTTPConnection(url_prefix)
|
||||
conn.request("POST", url_postfix, headers=headers)
|
||||
res = conn.getresponse()
|
||||
data = res.read().decode("utf-8")
|
||||
if data != "true":
|
||||
hasError = True
|
||||
print(f"{pair[0]}={pair[1]} {data if hasError else 'success'}")
|
||||
|
||||
if hasError:
|
||||
print("init nacos config fail.")
|
||||
else:
|
||||
print("init nacos config finished, please start seata-server.")
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/bin/sh
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
while getopts ":h:p:g:t:u:w:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
g)
|
||||
group=$OPTARG
|
||||
;;
|
||||
t)
|
||||
tenant=$OPTARG
|
||||
;;
|
||||
u)
|
||||
username=$OPTARG
|
||||
;;
|
||||
w)
|
||||
password=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] [-g group] [-t tenant] [-u username] [-w password] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z ${host} ]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [ -z ${port} ]; then
|
||||
port=8848
|
||||
fi
|
||||
if [ -z ${group} ]; then
|
||||
group="SEATA_GROUP"
|
||||
fi
|
||||
if [ -z ${tenant} ]; then
|
||||
tenant=""
|
||||
fi
|
||||
if [ -z ${username} ]; then
|
||||
username=""
|
||||
fi
|
||||
if [ -z ${password} ]; then
|
||||
password=""
|
||||
fi
|
||||
|
||||
nacosAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
|
||||
echo "set nacosAddr=$nacosAddr"
|
||||
echo "set group=$group"
|
||||
|
||||
urlencode() {
|
||||
length="${#1}"
|
||||
i=0
|
||||
while [ $length -gt $i ]; do
|
||||
char="${1:$i:1}"
|
||||
case $char in
|
||||
[a-zA-Z0-9.~_-]) printf $char ;;
|
||||
*) printf '%%%02X' "'$char" ;;
|
||||
esac
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
}
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
dataId=`urlencode $1`
|
||||
content=`urlencode $2`
|
||||
curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$dataId&group=$group&content=$content&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null
|
||||
if [ -z $(cat "${tempLog}") ]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(cat "${tempLog}")" == "true" ]; then
|
||||
echo "Set $1=$2 successfully "
|
||||
else
|
||||
echo "Set $1=$2 failure "
|
||||
failCount=`expr $failCount + 1`
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
count=`expr $count + 1`
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${key}" "${value}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [ ${failCount} -eq 0 ]; then
|
||||
echo " Init nacos config finished, please start seata-server. "
|
||||
else
|
||||
echo " init nacos config fail. "
|
||||
fi
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# The purpose is to sync the local configuration(config.txt) to zk.
|
||||
# This script need to rely on zk.
|
||||
echo -e "Please enter the host of zookeeper.\n请输入zookeeper的host [localhost]:"
|
||||
read -p ">>> " host
|
||||
echo -e "Please enter the port of zookeeper.\n请输入zookeeper的port [2181]:"
|
||||
read -p ">>> " port
|
||||
echo -e "Please enter the zkHome of zookeeper.\n请输入zookeeper的zkHome:"
|
||||
read -p ">>> " zkHome
|
||||
read -p "Are you sure to continue? [y/n]" input
|
||||
case $input in
|
||||
[yY]*)
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=2181
|
||||
fi
|
||||
if [[ -z ${zkHome} ]]; then
|
||||
echo " zk home is empty, please input it "
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
[nN]*)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Just enter y or n, please."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
zkAddr=$host:$port
|
||||
|
||||
root="/seata"
|
||||
tempLog=$(mktemp -u)
|
||||
|
||||
echo "ZK address is $zkAddr"
|
||||
echo "ZK home is $zkHome"
|
||||
echo "ZK config root node is $root"
|
||||
|
||||
function check_node() {
|
||||
"$2"/bin/zkCli.sh -server "$1" ls ${root} >/dev/null 2>"${tempLog}"
|
||||
}
|
||||
|
||||
function create_node() {
|
||||
"$2"/bin/zkCli.sh -server "$1" create ${root} "" >/dev/null
|
||||
}
|
||||
|
||||
function create_subNode() {
|
||||
"$2"/bin/zkCli.sh -server "$1" create "${root}/$3" "$4" >/dev/null
|
||||
}
|
||||
|
||||
function delete_node() {
|
||||
"$2"/bin/zkCli.sh -server $1 rmr ${root} "" >/dev/null
|
||||
}
|
||||
|
||||
check_node "${zkAddr}" "${zkHome}"
|
||||
|
||||
if [[ $(cat "${tempLog}") =~ "No such file or directory" ]]; then
|
||||
echo " ZK home is error, please enter correct zk home! "
|
||||
exit 1
|
||||
elif [[ $(cat "${tempLog}") =~ "Exception" ]]; then
|
||||
echo " Exception error, please check zk cluster status or if the zk address is entered correctly! "
|
||||
exit 1
|
||||
elif [[ $(cat "${tempLog}") =~ "Node does not exist" ]]; then
|
||||
create_node "${zkAddr}" "${zkHome}"
|
||||
else
|
||||
read -p "${root} node already exists, now delete ${root} node in zk, y/n: " result
|
||||
if [[ ${result} == "y" ]]; then
|
||||
echo "Delete ${root} node..."
|
||||
delete_node "${zkAddr}" "${zkHome}"
|
||||
create_node "${zkAddr}" "${zkHome}"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
echo "Set" "${key}" "=" "${value}"
|
||||
create_subNode "${zkAddr}" "${zkHome}" "${key}" "${value}"
|
||||
done
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# The purpose is to sync the local configuration(config.txt) to zk.
|
||||
# This script need to rely on zk.
|
||||
|
||||
|
||||
while getopts ":h:p:z:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
z)
|
||||
zkHome=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] [-z zkHome] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=2181
|
||||
fi
|
||||
if [[ -z ${zkHome} ]]; then
|
||||
echo " zk home is empty, please usage option: [-z zkHome] "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zkAddr=$host:$port
|
||||
|
||||
root="/seata"
|
||||
tempLog=$(mktemp -u)
|
||||
|
||||
echo "ZK address is $zkAddr"
|
||||
echo "ZK home is $zkHome"
|
||||
echo "ZK config root node is $root"
|
||||
|
||||
function check_node() {
|
||||
"$2"/bin/zkCli.sh -server "$1" ls ${root} >/dev/null 2>"${tempLog}"
|
||||
}
|
||||
|
||||
function create_node() {
|
||||
"$2"/bin/zkCli.sh -server "$1" create ${root} "" >/dev/null
|
||||
}
|
||||
|
||||
function create_subNode() {
|
||||
"$2"/bin/zkCli.sh -server "$1" create "${root}/$3" "$4" >/dev/null
|
||||
}
|
||||
|
||||
function delete_node() {
|
||||
"$2"/bin/zkCli.sh -server $1 rmr ${root} "" >/dev/null
|
||||
}
|
||||
|
||||
check_node "${zkAddr}" "${zkHome}"
|
||||
|
||||
if [[ $(cat "${tempLog}") =~ "No such file or directory" ]]; then
|
||||
echo " ZK home is error, please enter correct zk home! "
|
||||
exit 1
|
||||
elif [[ $(cat "${tempLog}") =~ "Exception" ]]; then
|
||||
echo " Exception error, please check zk cluster status or if the zk address is entered correctly! "
|
||||
exit 1
|
||||
elif [[ $(cat "${tempLog}") =~ "Node does not exist" ]]; then
|
||||
create_node "${zkAddr}" "${zkHome}"
|
||||
else
|
||||
read -p "${root} node already exists, now delete ${root} node in zk, y/n: " result
|
||||
if [[ ${result} == "y" ]]; then
|
||||
echo "Delete ${root} node..."
|
||||
delete_node "${zkAddr}" "${zkHome}"
|
||||
create_node "${zkAddr}" "${zkHome}"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
COMMENT_START="#"
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
if [[ "$line" =~ ^"${COMMENT_START}".* ]]; then
|
||||
continue
|
||||
fi
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
echo "Set" "${key}" "=" "${value}"
|
||||
create_subNode "${zkAddr}" "${zkHome}" "${key}" "${value}"
|
||||
done
|
||||
@@ -0,0 +1,31 @@
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# App(Logback KafkaAppender) -> Kafka -> Logstash -> Elasticsearch pipeline.
|
||||
|
||||
input {
|
||||
kafka {
|
||||
bootstrap_servers => "localhost:9092"
|
||||
topics => ["logback_to_logstash"]
|
||||
}
|
||||
}
|
||||
|
||||
output{
|
||||
elasticsearch {
|
||||
hosts => ["localhost:9200"]
|
||||
}
|
||||
stdout {
|
||||
codec => rubydebug
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# App(Logback LogstashTcpSocketAppender) -> Logstash -> Elasticsearch pipeline.
|
||||
|
||||
input {
|
||||
# Using TCP protocol
|
||||
tcp {
|
||||
port => 4560
|
||||
# execute command `./logstash-plugin install logstash-codec-json_lines` to install this plugin.
|
||||
codec => json_lines
|
||||
}
|
||||
}
|
||||
|
||||
output{
|
||||
elasticsearch {
|
||||
hosts => ["localhost:9200"]
|
||||
}
|
||||
stdout {
|
||||
codec => rubydebug
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
|
||||
|
||||
-- the table to store GlobalSession data
|
||||
CREATE TABLE "SEATA"."GLOBAL_TABLE"
|
||||
(
|
||||
"XID" VARCHAR2(128) NOT NULL,
|
||||
"TRANSACTION_ID" BIGINT,
|
||||
"STATUS" TINYINT NOT NULL,
|
||||
"APPLICATION_ID" VARCHAR2(32),
|
||||
"TRANSACTION_SERVICE_GROUP" VARCHAR2(32),
|
||||
"TRANSACTION_NAME" VARCHAR2(128),
|
||||
"TIMEOUT" INT,
|
||||
"BEGIN_TIME" BIGINT,
|
||||
"APPLICATION_DATA" VARCHAR2(2000),
|
||||
"GMT_CREATE" TIMESTAMP(0),
|
||||
"GMT_MODIFIED" TIMESTAMP(0),
|
||||
PRIMARY KEY ("XID")
|
||||
);
|
||||
|
||||
CREATE INDEX "IDX_GMT_MODIFIED_STATUS" ON "SEATA"."GLOBAL_TABLE"("GMT_MODIFIED" ASC,"STATUS" ASC);
|
||||
CREATE INDEX "IDX_TRANSACTION_ID" ON "SEATA"."GLOBAL_TABLE"("TRANSACTION_ID" ASC);
|
||||
|
||||
|
||||
-- the table to store BranchSession data
|
||||
CREATE TABLE "SEATA"."BRANCH_TABLE"
|
||||
(
|
||||
"BRANCH_ID" BIGINT NOT NULL,
|
||||
"XID" VARCHAR2(128) NOT NULL,
|
||||
"TRANSACTION_ID" BIGINT,
|
||||
"RESOURCE_GROUP_ID" VARCHAR2(32),
|
||||
"RESOURCE_ID" VARCHAR2(256),
|
||||
"BRANCH_TYPE" VARCHAR2(8),
|
||||
"STATUS" TINYINT,
|
||||
"CLIENT_ID" VARCHAR2(64),
|
||||
"APPLICATION_DATA" VARCHAR2(2000),
|
||||
"GMT_CREATE" TIMESTAMP(0),
|
||||
"GMT_MODIFIED" TIMESTAMP(0),
|
||||
PRIMARY KEY ("BRANCH_ID")
|
||||
);
|
||||
|
||||
CREATE INDEX "IDX_XID" ON "SEATA"."BRANCH_TABLE"("XID" ASC);
|
||||
|
||||
|
||||
-- the table to store lock data
|
||||
CREATE TABLE "SEATA"."LOCK_TABLE"
|
||||
(
|
||||
"ROW_KEY" VARCHAR2(128) NOT NULL,
|
||||
"XID" VARCHAR2(128),
|
||||
"TRANSACTION_ID" BIGINT,
|
||||
"BRANCH_ID" BIGINT NOT NULL,
|
||||
"RESOURCE_ID" VARCHAR2(256),
|
||||
"TABLE_NAME" VARCHAR2(32),
|
||||
"PK" VARCHAR2(36),
|
||||
"STATUS" TINYINT NOT NULL DEFAULT 0,
|
||||
"GMT_CREATE" TIMESTAMP(0),
|
||||
"GMT_MODIFIED" TIMESTAMP(0),
|
||||
PRIMARY KEY ("ROW_KEY")
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN "SEATA"."LOCK_TABLE"."STATUS" IS '0:locked ,1:rollbacking';
|
||||
|
||||
CREATE INDEX "IDX_BRANCH_ID" ON "SEATA"."LOCK_TABLE" ("BRANCH_ID" ASC);
|
||||
CREATE INDEX "IDX_STATUS" ON "SEATA"."LOCK_TABLE" ("STATUS" ASC);
|
||||
|
||||
CREATE TABLE "SEATA"."DISTRIBUTED_LOCK"
|
||||
(
|
||||
"LOCK_KEY" VARCHAR2(20) NOT NULL,
|
||||
"LOCK_VALUE" VARCHAR2(20) NOT NULL,
|
||||
"EXPIRE" BIGINT NOT NULL,
|
||||
PRIMARY KEY ("LOCK_KEY")
|
||||
);
|
||||
|
||||
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('AsyncCommitting', ' ', 0);
|
||||
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryCommitting', ' ', 0);
|
||||
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryRollbacking', ' ', 0);
|
||||
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('TxTimeoutCheck', ' ', 0);
|
||||
@@ -0,0 +1,73 @@
|
||||
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
|
||||
-- the table to store GlobalSession data
|
||||
CREATE TABLE IF NOT EXISTS `global_table`
|
||||
(
|
||||
`xid` VARCHAR(128) NOT NULL,
|
||||
`transaction_id` BIGINT,
|
||||
`status` TINYINT NOT NULL,
|
||||
`application_id` VARCHAR(32),
|
||||
`transaction_service_group` VARCHAR(32),
|
||||
`transaction_name` VARCHAR(128),
|
||||
`timeout` INT,
|
||||
`begin_time` BIGINT,
|
||||
`application_data` VARCHAR(2000),
|
||||
`gmt_create` DATETIME,
|
||||
`gmt_modified` DATETIME,
|
||||
PRIMARY KEY (`xid`),
|
||||
KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
|
||||
KEY `idx_transaction_id` (`transaction_id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
-- the table to store BranchSession data
|
||||
CREATE TABLE IF NOT EXISTS `branch_table`
|
||||
(
|
||||
`branch_id` BIGINT NOT NULL,
|
||||
`xid` VARCHAR(128) NOT NULL,
|
||||
`transaction_id` BIGINT,
|
||||
`resource_group_id` VARCHAR(32),
|
||||
`resource_id` VARCHAR(256),
|
||||
`branch_type` VARCHAR(8),
|
||||
`status` TINYINT,
|
||||
`client_id` VARCHAR(64),
|
||||
`application_data` VARCHAR(2000),
|
||||
`gmt_create` DATETIME(6),
|
||||
`gmt_modified` DATETIME(6),
|
||||
PRIMARY KEY (`branch_id`),
|
||||
KEY `idx_xid` (`xid`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
-- the table to store lock data
|
||||
CREATE TABLE IF NOT EXISTS `lock_table`
|
||||
(
|
||||
`row_key` VARCHAR(128) NOT NULL,
|
||||
`xid` VARCHAR(128),
|
||||
`transaction_id` BIGINT,
|
||||
`branch_id` BIGINT NOT NULL,
|
||||
`resource_id` VARCHAR(256),
|
||||
`table_name` VARCHAR(32),
|
||||
`pk` VARCHAR(36),
|
||||
`status` TINYINT NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
|
||||
`gmt_create` DATETIME,
|
||||
`gmt_modified` DATETIME,
|
||||
PRIMARY KEY (`row_key`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_branch_id` (`branch_id`),
|
||||
KEY `idx_xid` (`xid`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `distributed_lock`
|
||||
(
|
||||
`lock_key` CHAR(20) NOT NULL,
|
||||
`lock_value` VARCHAR(20) NOT NULL,
|
||||
`expire` BIGINT,
|
||||
primary key (`lock_key`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
|
||||
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
|
||||
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
|
||||
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
|
||||
@@ -0,0 +1,72 @@
|
||||
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
|
||||
-- the table to store GlobalSession data
|
||||
CREATE TABLE global_table
|
||||
(
|
||||
xid VARCHAR2(128) NOT NULL,
|
||||
transaction_id NUMBER(19),
|
||||
status NUMBER(3) NOT NULL,
|
||||
application_id VARCHAR2(32),
|
||||
transaction_service_group VARCHAR2(32),
|
||||
transaction_name VARCHAR2(128),
|
||||
timeout NUMBER(10),
|
||||
begin_time NUMBER(19),
|
||||
application_data VARCHAR2(2000),
|
||||
gmt_create TIMESTAMP(0),
|
||||
gmt_modified TIMESTAMP(0),
|
||||
PRIMARY KEY (xid)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_status_gmt_modified ON global_table (status, gmt_modified);
|
||||
CREATE INDEX idx_transaction_id ON global_table (transaction_id);
|
||||
|
||||
-- the table to store BranchSession data
|
||||
CREATE TABLE branch_table
|
||||
(
|
||||
branch_id NUMBER(19) NOT NULL,
|
||||
xid VARCHAR2(128) NOT NULL,
|
||||
transaction_id NUMBER(19),
|
||||
resource_group_id VARCHAR2(32),
|
||||
resource_id VARCHAR2(256),
|
||||
branch_type VARCHAR2(8),
|
||||
status NUMBER(3),
|
||||
client_id VARCHAR2(64),
|
||||
application_data VARCHAR2(2000),
|
||||
gmt_create TIMESTAMP(6),
|
||||
gmt_modified TIMESTAMP(6),
|
||||
PRIMARY KEY (branch_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_xid ON branch_table (xid);
|
||||
|
||||
-- the table to store lock data
|
||||
CREATE TABLE lock_table
|
||||
(
|
||||
row_key VARCHAR2(128) NOT NULL,
|
||||
xid VARCHAR2(128),
|
||||
transaction_id NUMBER(19),
|
||||
branch_id NUMBER(19) NOT NULL,
|
||||
resource_id VARCHAR2(256),
|
||||
table_name VARCHAR2(32),
|
||||
pk VARCHAR2(36),
|
||||
status NUMBER(3) DEFAULT 0 NOT NULL,
|
||||
gmt_create TIMESTAMP(0),
|
||||
gmt_modified TIMESTAMP(0),
|
||||
PRIMARY KEY (row_key)
|
||||
);
|
||||
|
||||
comment on column lock_table.status is '0:locked ,1:rollbacking';
|
||||
CREATE INDEX idx_branch_id ON lock_table (branch_id);
|
||||
CREATE INDEX idx_lock_table_xid ON lock_table (xid);
|
||||
CREATE INDEX idx_status ON lock_table (status);
|
||||
|
||||
CREATE TABLE distributed_lock (
|
||||
lock_key VARCHAR2(20) NOT NULL,
|
||||
lock_value VARCHAR2(20) NOT NULL,
|
||||
expire DECIMAL(18) NOT NULL,
|
||||
PRIMARY KEY (lock_key)
|
||||
);
|
||||
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
|
||||
@@ -0,0 +1,72 @@
|
||||
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
|
||||
-- the table to store GlobalSession data
|
||||
CREATE TABLE IF NOT EXISTS public.global_table
|
||||
(
|
||||
xid VARCHAR(128) NOT NULL,
|
||||
transaction_id BIGINT,
|
||||
status SMALLINT NOT NULL,
|
||||
application_id VARCHAR(32),
|
||||
transaction_service_group VARCHAR(32),
|
||||
transaction_name VARCHAR(128),
|
||||
timeout INT,
|
||||
begin_time BIGINT,
|
||||
application_data VARCHAR(2000),
|
||||
gmt_create TIMESTAMP(0),
|
||||
gmt_modified TIMESTAMP(0),
|
||||
CONSTRAINT pk_global_table PRIMARY KEY (xid)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_status_gmt_modified ON public.global_table (status, gmt_modified);
|
||||
CREATE INDEX idx_transaction_id ON public.global_table (transaction_id);
|
||||
|
||||
-- the table to store BranchSession data
|
||||
CREATE TABLE IF NOT EXISTS public.branch_table
|
||||
(
|
||||
branch_id BIGINT NOT NULL,
|
||||
xid VARCHAR(128) NOT NULL,
|
||||
transaction_id BIGINT,
|
||||
resource_group_id VARCHAR(32),
|
||||
resource_id VARCHAR(256),
|
||||
branch_type VARCHAR(8),
|
||||
status SMALLINT,
|
||||
client_id VARCHAR(64),
|
||||
application_data VARCHAR(2000),
|
||||
gmt_create TIMESTAMP(6),
|
||||
gmt_modified TIMESTAMP(6),
|
||||
CONSTRAINT pk_branch_table PRIMARY KEY (branch_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_xid ON public.branch_table (xid);
|
||||
|
||||
-- the table to store lock data
|
||||
CREATE TABLE IF NOT EXISTS public.lock_table
|
||||
(
|
||||
row_key VARCHAR(128) NOT NULL,
|
||||
xid VARCHAR(128),
|
||||
transaction_id BIGINT,
|
||||
branch_id BIGINT NOT NULL,
|
||||
resource_id VARCHAR(256),
|
||||
table_name VARCHAR(32),
|
||||
pk VARCHAR(36),
|
||||
status SMALLINT NOT NULL DEFAULT 0,
|
||||
gmt_create TIMESTAMP(0),
|
||||
gmt_modified TIMESTAMP(0),
|
||||
CONSTRAINT pk_lock_table PRIMARY KEY (row_key)
|
||||
);
|
||||
|
||||
comment on column public.lock_table.status is '0:locked ,1:rollbacking';
|
||||
CREATE INDEX idx_branch_id ON public.lock_table (branch_id);
|
||||
CREATE INDEX idx_xid ON public.lock_table (xid);
|
||||
CREATE INDEX idx_status ON public.lock_table (status);
|
||||
|
||||
CREATE TABLE distributed_lock (
|
||||
lock_key VARCHAR(20) NOT NULL,
|
||||
lock_value VARCHAR(20) NOT NULL,
|
||||
expire BIGINT NOT NULL,
|
||||
CONSTRAINT pk_distributed_lock_table PRIMARY KEY (lock_key)
|
||||
);
|
||||
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
|
||||
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
|
||||
@@ -0,0 +1,80 @@
|
||||
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
|
||||
-- the table to store GlobalSession data
|
||||
CREATE TABLE [global_table]
|
||||
(
|
||||
[xid] nvarchar(128) NOT NULL,
|
||||
[transaction_id] bigint NULL,
|
||||
[status] tinyint NOT NULL,
|
||||
[application_id] nvarchar(32) NULL,
|
||||
[transaction_service_group] nvarchar(32) NULL,
|
||||
[transaction_name] nvarchar(128) NULL,
|
||||
[timeout] int NULL,
|
||||
[begin_time] bigint NULL,
|
||||
[application_data] nvarchar(2000) NULL,
|
||||
[gmt_create] datetime2 NULL,
|
||||
[gmt_modified] datetime2 NULL,
|
||||
PRIMARY KEY CLUSTERED ([xid])
|
||||
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
|
||||
)
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [idx_gmt_modified_status]
|
||||
ON [global_table] (
|
||||
[gmt_modified],
|
||||
[status]
|
||||
)
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [idx_transaction_id]
|
||||
ON [global_table] (
|
||||
[transaction_id]
|
||||
)
|
||||
GO
|
||||
|
||||
-- the table to store BranchSession data
|
||||
CREATE TABLE [branch_table]
|
||||
(
|
||||
[branch_id] bigint NOT NULL,
|
||||
[xid] nvarchar(128) NOT NULL,
|
||||
[transaction_id] bigint NULL,
|
||||
[resource_group_id] nvarchar(32) NULL,
|
||||
[resource_id] nvarchar(256) NULL,
|
||||
[branch_type] varchar(8) NULL,
|
||||
[status] tinyint NULL,
|
||||
[client_id] nvarchar(64) NULL,
|
||||
[application_data] nvarchar(2000) NULL,
|
||||
[gmt_create] datetime2 NULL,
|
||||
[gmt_modified] datetime2 NULL,
|
||||
PRIMARY KEY CLUSTERED ([branch_id])
|
||||
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
|
||||
)
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [idx_xid]
|
||||
ON [branch_table] (
|
||||
[xid]
|
||||
)
|
||||
GO
|
||||
|
||||
-- the table to store lock data
|
||||
CREATE TABLE [lock_table]
|
||||
(
|
||||
[row_key] nvarchar(128) NOT NULL,
|
||||
[xid] nvarchar(128) NULL,
|
||||
[transaction_id] bigint NULL,
|
||||
[branch_id] bigint NOT NULL,
|
||||
[resource_id] nvarchar(256) NULL,
|
||||
[table_name] nvarchar(32) NULL,
|
||||
[pk] nvarchar(36) NULL,
|
||||
[gmt_create] datetime2 NULL,
|
||||
[gmt_modified] datetime2 NULL,
|
||||
PRIMARY KEY CLUSTERED ([row_key])
|
||||
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
|
||||
)
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [idx_branch_id]
|
||||
ON [lock_table] (
|
||||
[branch_id]
|
||||
)
|
||||
GO
|
||||
@@ -0,0 +1,10 @@
|
||||
version: "3"
|
||||
services:
|
||||
seata-server:
|
||||
image: seataio/seata-server
|
||||
hostname: seata-server
|
||||
ports:
|
||||
- "8091:8091"
|
||||
environment:
|
||||
- SEATA_PORT=8091
|
||||
- STORE_MODE=file
|
||||
@@ -0,0 +1,22 @@
|
||||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
appVersion: "1.0"
|
||||
description: Seata Server
|
||||
name: seata-server
|
||||
version: 1.0.0
|
||||
@@ -0,0 +1,15 @@
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "seata-server.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "seata-server.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "seata-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "seata-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl port-forward $POD_NAME 8080:80
|
||||
{{- end }}
|
||||
@@ -0,0 +1,56 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "seata-server.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "seata-server.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "seata-server.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "seata-server.labels" -}}
|
||||
app.kubernetes.io/name: {{ include "seata-server.name" . }}
|
||||
helm.sh/chart: {{ include "seata-server.chart" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "seata-server.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "seata-server.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,71 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
{{- if .Values.namespace }}
|
||||
namespace: {{ .Values.namespace }}
|
||||
{{- end}}
|
||||
name: {{ include "seata-server.name" . }}
|
||||
labels:
|
||||
{{ include "seata-server.labels" . | indent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ include "seata-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ include "seata-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8091
|
||||
protocol: TCP
|
||||
{{- if .Values.volume }}
|
||||
volumeMounts:
|
||||
{{- range .Values.volume }}
|
||||
- name: {{ .name }}
|
||||
mountPath: {{ .mountPath }}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- if .Values.env }}
|
||||
env:
|
||||
{{- if .Values.env.seataIp }}
|
||||
- name: SEATA_IP
|
||||
value: {{ .Values.env.seataIp | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.env.seataPort }}
|
||||
- name: SEATA_PORT
|
||||
value: {{ .Values.env.seataPort | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.env.seataEnv }}
|
||||
- name: SEATA_ENV
|
||||
value: {{ .Values.env.seataEnv }}
|
||||
{{- end }}
|
||||
{{- if .Values.env.seataConfigName }}
|
||||
- name: SEATA_CONFIG_NAME
|
||||
value: {{ .Values.env.seataConfigName }}
|
||||
{{- end }}
|
||||
{{- if .Values.env.serverNode }}
|
||||
- name: SERVER_NODE
|
||||
value: {{ .Values.env.serverNode | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.env.storeMode }}
|
||||
- name: STORE_MODE
|
||||
value: {{ .Values.env.storeMode }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.volume }}
|
||||
volumes:
|
||||
{{- range .Values.volume }}
|
||||
- name: {{ .name }}
|
||||
hostPath:
|
||||
path: {{ .hostPath}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "seata-server.fullname" . }}
|
||||
labels:
|
||||
{{ include "seata-server.labels" . | indent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "seata-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ include "seata-server.fullname" . }}-test-connection"
|
||||
labels:
|
||||
{{ include "seata-server.labels" . | indent 4 }}
|
||||
annotations:
|
||||
"helm.sh/hook": test-success
|
||||
spec:
|
||||
containers:
|
||||
- name: wget
|
||||
image: busybox
|
||||
command: ['wget']
|
||||
args: ['{{ include "seata-server.fullname" . }}:{{ .Values.service.port }}']
|
||||
restartPolicy: Never
|
||||
@@ -0,0 +1,17 @@
|
||||
replicaCount: 1
|
||||
|
||||
namespace: default
|
||||
|
||||
image:
|
||||
repository: seataio/seata-server
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
service:
|
||||
type: NodePort
|
||||
port: 30091
|
||||
|
||||
env:
|
||||
seataPort: "8091"
|
||||
storeMode: "file"
|
||||
serverNode: "1"
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: seata-server
|
||||
namespace: default
|
||||
labels:
|
||||
k8s-app: seata-server
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 8091
|
||||
nodePort: 30091
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
k8s-app: seata-server
|
||||
|
||||
---
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: seata-server
|
||||
namespace: default
|
||||
labels:
|
||||
k8s-app: seata-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: seata-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: seata-server
|
||||
spec:
|
||||
containers:
|
||||
- name: seata-server
|
||||
image: docker.io/seataio/seata-server:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SEATA_PORT
|
||||
value: "8091"
|
||||
- name: STORE_MODE
|
||||
value: file
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8091
|
||||
protocol: TCP
|
||||
Reference in new issue
Block a user