This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch one_process_iotdb in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 7d4baf48e6bd70e76f4f83e604cb163eb1128000 Author: HTHou <[email protected]> AuthorDate: Mon Jun 12 16:49:33 2023 +0800 one process iotdb --- distribution/pom.xml | 6 + distribution/src/assembly/all.xml | 10 + pom.xml | 1 + standalone/pom.xml | 67 ++++++ .../src/assembly/resources/conf/iotdb-env.sh | 248 +++++++++++++++++++++ .../assembly/resources/conf/logback-confignode.xml | 140 ++++++++++++ .../src/assembly/resources/conf/logback-tool.xml | 36 +++ .../src/assembly/resources/sbin/start-iotdb.sh | 186 ++++++++++++++++ standalone/src/assembly/standalone.xml | 55 +++++ .../java/org/apache/iotdb/StandaloneIoTDB.java | 32 +++ 10 files changed, 781 insertions(+) diff --git a/distribution/pom.xml b/distribution/pom.xml index 15826a0523c..a44b81fc47d 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -113,6 +113,12 @@ <version>${project.version}</version> <type>zip</type> </dependency> + <dependency> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-standalone</artifactId> + <version>${project.version}</version> + <type>zip</type> + </dependency> <dependency> <groupId>org.apache.iotdb</groupId> <artifactId>iotdb-grafana-connector</artifactId> diff --git a/distribution/src/assembly/all.xml b/distribution/src/assembly/all.xml index 52c28895e30..e87a35e0d18 100644 --- a/distribution/src/assembly/all.xml +++ b/distribution/src/assembly/all.xml @@ -32,6 +32,7 @@ <include>*:iotdb-server:zip:*</include> <include>*:iotdb-cli:zip:*</include> <include>*:iotdb-confignode:zip:*</include> + <include>*:iotdb-standalone:zip:*</include> </includes> <outputDirectory>${file.separator}</outputDirectory> <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping> @@ -58,6 +59,10 @@ <outputDirectory>conf</outputDirectory> <directory>${maven.multiModuleProjectDirectory}/node-commons/src/assembly/resources/conf</directory> </fileSet> + <fileSet> + <outputDirectory>conf</outputDirectory> + <directory>${maven.multiModuleProjectDirectory}/standalone/src/assembly/resources/conf</directory> + </fileSet> <fileSet> <outputDirectory>sbin</outputDirectory> <directory>${maven.multiModuleProjectDirectory}/server/src/assembly/resources/sbin</directory> @@ -73,6 +78,11 @@ <directory>${maven.multiModuleProjectDirectory}/node-commons/src/assembly/resources/sbin</directory> <fileMode>0755</fileMode> </fileSet> + <fileSet> + <outputDirectory>sbin</outputDirectory> + <directory>${maven.multiModuleProjectDirectory}/standalone/src/assembly/resources/sbin</directory> + <fileMode>0755</fileMode> + </fileSet> <fileSet> <outputDirectory>tools</outputDirectory> <directory>${maven.multiModuleProjectDirectory}/server/src/assembly/resources/tools</directory> diff --git a/pom.xml b/pom.xml index d7da67d1b7b..4b93c503e25 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,7 @@ <module>mlnode</module> <module>iotdb-api/pipe-api</module> <module>iotdb-api/subscription-api</module> + <module>standalone</module> </modules> <!-- Properties Management --> <properties> diff --git a/standalone/pom.xml b/standalone/pom.xml new file mode 100644 index 00000000000..dd191303f20 --- /dev/null +++ b/standalone/pom.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-parent</artifactId> + <version>1.3.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>iotdb-standalone</artifactId> + <name>IoTDB Standalone</name> + <dependencies> + <dependency> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-confignode</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>${maven.assembly.version}</version> + <executions> + <!-- Package binaries--> + <execution> + <id>standalone-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/assembly/standalone.xml</descriptor> + </descriptors> + <appendAssemblyId>false</appendAssemblyId> + <archive> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> + </manifest> + </archive> + </configuration> + </execution> + </executions> + </plugin> + <!-- generate test codes into test-jar--> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/standalone/src/assembly/resources/conf/iotdb-env.sh b/standalone/src/assembly/resources/conf/iotdb-env.sh new file mode 100644 index 00000000000..4ae49358289 --- /dev/null +++ b/standalone/src/assembly/resources/conf/iotdb-env.sh @@ -0,0 +1,248 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + +# You can put your env variable here +# export JAVA_HOME=$JAVA_HOME + +# Set max number of open files +max_num=$(ulimit -n) +if [ $max_num -le 65535 ]; then + ulimit -n 65535 + if [ $? -ne 0 ]; then + echo "Warning: Failed to set max number of files to be 65535, maybe you need to use 'sudo ulimit -n 65535' to set it when you use iotdb in production environments." + fi +fi + +# Set somaxconn to a better value to avoid meaningless connection reset issues when the system is under high load. +# The original somaxconn will be set back when the system reboots. +# For more detail, see: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4 +SOMAXCONN=65535 +case "$(uname)" in + Linux) + somaxconn=$(sysctl -n net.core.somaxconn) + if [ "$somaxconn" -lt $SOMAXCONN ]; then + echo "WARN:" + echo "WARN: the value of net.core.somaxconn (=$somaxconn) is too small, please set it to a larger value using the following command." + echo "WARN: sudo sysctl -w net.core.somaxconn=$SOMAXCONN" + echo "WARN: The original net.core.somaxconn value will be set back when the os reboots." + echo "WARN:" + fi + ;; + FreeBSD | Darwin) + somaxconn=$(sysctl -n kern.ipc.somaxconn) + if [ "$somaxconn" -lt $SOMAXCONN ]; then + echo "WARN:" + echo "WARN: the value of kern.ipc.somaxconn (=$somaxconn) is too small, please set it to a larger value using the following command." + echo "WARN: sudo sysctl -w kern.ipc.somaxconn=$SOMAXCONN" + echo "WARN: The original kern.ipc.somaxconn value will be set back when the os reboots." + echo "WARN:" + fi + ;; +esac + +# whether we allow enable heap dump files +IOTDB_ALLOW_HEAP_DUMP="true" + +calculate_heap_sizes() +{ + case "`uname`" in + Linux) + system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'` + system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` + ;; + FreeBSD) + system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + SunOS) + system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` + system_cpu_cores=`psrinfo | wc -l` + ;; + Darwin) + system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` + system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` + system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` + ;; + *) + # assume reasonable defaults for e.g. a modern desktop or + # cheap server + system_memory_in_mb="2048" + system_cpu_cores="2" + ;; + esac + + # some systems like the raspberry pi don't report cores, use at least 1 + if [ "$system_cpu_cores" -lt "1" ] + then + system_cpu_cores="1" + fi + + # set max heap size based on the following + # max(min(1/2 ram, 1024MB), min(1/4 ram, 64GB)) + # calculate 1/2 ram and cap to 1024MB + # calculate 1/4 ram and cap to 65536MB + # pick the max + half_system_memory_in_mb=`expr $system_memory_in_mb / 2` + quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` + if [ "$half_system_memory_in_mb" -gt "1024" ] + then + half_system_memory_in_mb="1024" + fi + if [ "$quarter_system_memory_in_mb" -gt "65536" ] + then + quarter_system_memory_in_mb="65536" + fi + if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] + then + max_heap_size_in_mb="$half_system_memory_in_mb" + else + max_heap_size_in_mb="$quarter_system_memory_in_mb" + fi + MAX_HEAP_SIZE="${max_heap_size_in_mb}M" + + # if the heap size is larger than 16GB, we will forbid writing the heap dump file + if [ "$max_heap_size_in_mb" -gt "16384" ] + then + echo "IoTDB memory is too large ($max_heap_size_in_mb MB), will forbid writing heap dump file" + IOTDB_ALLOW_HEAP_DUMP="false" + fi + + # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) + max_sensible_yg_per_core_in_mb="100" + max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` + + desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` + + if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] + then + HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" + else + HEAP_NEWSIZE="${desired_yg_in_mb}M" + fi +} + + +# find java in JAVA_HOME +if [ -n "$JAVA_HOME" ]; then + for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do + if [ -x "$java" ]; then + JAVA="$java" + break + fi + done +else + JAVA=java +fi + +if [ -z $JAVA ] ; then + echo Unable to find java executable. Check JAVA_HOME and PATH environment variables. > /dev/stderr + exit 1; +fi + +# Determine the sort of JVM we'll be running on. +java_ver_output=`"$JAVA" -version 2>&1` +jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}' | cut -d\- -f1` +JVM_VERSION=${jvmver%_*} +JVM_PATCH_VERSION=${jvmver#*_} +if [ "$JVM_VERSION" \< "1.8" ] ; then + echo "IoTDB requires Java 8u40 or later." + exit 1; +fi + +if [ "$JVM_VERSION" \< "1.8" ] && [ "$JVM_PATCH_VERSION" -lt 40 ] ; then + echo "IoTDB requires Java 8u40 or later." + exit 1; +fi + +version_arr=(${JVM_VERSION//./ }) + +illegal_access_params="" +#GC log path has to be defined here because it needs to access IOTDB_HOME +if [ "${version_arr[0]}" = "1" ] ; then + # Java 8 + MAJOR_VERSION=${version_arr[1]} + echo "$IOTDB_JMX_OPTS" | grep -q "^-[X]loggc" + if [ "$?" = "1" ] ; then # [X] to prevent ccm from replacing this line + # only add -Xlog:gc if it's not mentioned in jvm-server.options file + mkdir -p ${IOTDB_HOME}/logs + if [ "$#" -ge "1" -a "$1" == "printgc" ]; then + IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xloggc:${IOTDB_HOME}/logs/gc.log -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M" + fi + fi +else + #JDK 11 and others + MAJOR_VERSION=${version_arr[0]} + # See description of https://bugs.openjdk.java.net/browse/JDK-8046148 for details about the syntax + # The following is the equivalent to -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M + echo "$IOTDB_JMX_OPTS" | grep -q "^-[X]log:gc" + if [ "$?" = "1" ] ; then # [X] to prevent ccm from replacing this line + # only add -Xlog:gc if it's not mentioned in jvm-server.options file + mkdir -p ${IOTDB_HOME}/logs + if [ "$#" -ge "1" -a "$1" == "printgc" ]; then + IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xlog:gc=info,heap*=info,age*=info,safepoint=info,promotion*=info:file=${IOTDB_HOME}/logs/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760" + fi + fi + # Add argLine for Java 11 and above, due to [JEP 396: Strongly Encapsulate JDK Internals by Default] (https://openjdk.java.net/jeps/396) + illegal_access_params="$illegal_access_params --add-opens=java.base/java.util.concurrent=ALL-UNNAMED" + illegal_access_params="$illegal_access_params --add-opens=java.base/java.lang=ALL-UNNAMED" + illegal_access_params="$illegal_access_params --add-opens=java.base/java.util=ALL-UNNAMED" + illegal_access_params="$illegal_access_params --add-opens=java.base/java.nio=ALL-UNNAMED" + illegal_access_params="$illegal_access_params --add-opens=java.base/java.io=ALL-UNNAMED" + illegal_access_params="$illegal_access_params --add-opens=java.base/java.net=ALL-UNNAMED" +fi + + + +calculate_heap_sizes + +## Set heap size by percentage of total memory +#max_percentage=90 +#min_percentage=50 +#MAX_HEAP_SIZE="`expr $system_memory_in_mb \* $max_percentage / 100`M" +#HEAP_NEWSIZE="`expr $system_memory_in_mb \* $min_percentage / 100`M" + +# Maximum heap size +#MAX_HEAP_SIZE="2G" +# Minimum heap size +#HEAP_NEWSIZE="2G" +# Maximum direct memory size +MAX_DIRECT_MEMORY_SIZE=${MAX_HEAP_SIZE} + +# threads number that may use direct memory, including query threads(8) + merge threads(4) + space left for system(4) +threads_number="16" +# the size of buffer cache pool(IOV_MAX) depends on operating system +temp_buffer_pool_size="1024" +# Max cached buffer size, Note: unit can only be B! +# which equals DIRECT_MEMORY_SIZE / threads_number / temp_buffer_pool_size +MAX_CACHED_BUFFER_SIZE=`expr $max_heap_size_in_mb \* 1024 \* 1024 / $threads_number / $temp_buffer_pool_size` + +#true or false +JMX_LOCAL="true" + +IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Diotdb.jmx.local=$JMX_LOCAL" +IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xms${HEAP_NEWSIZE}" +IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Xmx${MAX_HEAP_SIZE}" +IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:MaxDirectMemorySize=${MAX_DIRECT_MEMORY_SIZE}" +IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Djdk.nio.maxCachedBufferSize=${MAX_CACHED_BUFFER_SIZE}" + +echo "Maximum memory allocation pool = ${MAX_HEAP_SIZE}B, initial memory allocation pool = ${HEAP_NEWSIZE}B" +echo "If you want to change this configuration, please check conf/iotdb-env.sh(Unix or OS X, if you use Windows, check conf/iotdb-env.bat)." + diff --git a/standalone/src/assembly/resources/conf/logback-confignode.xml b/standalone/src/assembly/resources/conf/logback-confignode.xml new file mode 100644 index 00000000000..5c9d7657721 --- /dev/null +++ b/standalone/src/assembly/resources/conf/logback-confignode.xml @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. + +--> +<configuration scan="true" scanPeriod="60 seconds"> + <jmxConfigurator/> + <!-- prevent logback from outputting its own status at the start of every log --> + <statusListener class="ch.qos.logback.core.status.NopStatusListener"/> + <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEERROR"> + <file>${CONFIGNODE_HOME}/logs/log_confignode_error.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${CONFIGNODE_HOME}/logs/log-confignode-error-%d{yyyyMMdd}.%i.log.gz</fileNamePattern> + <maxFileSize>10MB</maxFileSize> + <maxHistory>168</maxHistory> + <totalSizeCap>512MB</totalSizeCap> + </rollingPolicy> + <append>true</append> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>error</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEWARN"> + <file>${CONFIGNODE_HOME}/logs/log_confignode_warn.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${CONFIGNODE_HOME}/logs/log-confignode-warn-%d{yyyyMMdd}.%i.log.gz</fileNamePattern> + <maxFileSize>10MB</maxFileSize> + <maxHistory>168</maxHistory> + <totalSizeCap>512MB</totalSizeCap> + </rollingPolicy> + <append>true</append> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>WARN</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEINFO"> + <file>${CONFIGNODE_HOME}/logs/log_confignode_info.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${CONFIGNODE_HOME}/logs/log-confignode-info-%d{yyyyMMdd}.%i.log.gz</fileNamePattern> + <maxFileSize>50MB</maxFileSize> + <maxHistory>168</maxHistory> + <totalSizeCap>5GB</totalSizeCap> + </rollingPolicy> + <append>true</append> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>INFO</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEDEBUG"> + <file>${CONFIGNODE_HOME}/logs/log_confignode_debug.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${CONFIGNODE_HOME}/logs/log-confignode-debug-%d{yyyyMMdd}.%i.log.gz</fileNamePattern> + <maxFileSize>50MB</maxFileSize> + <maxHistory>168</maxHistory> + <totalSizeCap>5GB</totalSizeCap> + </rollingPolicy> + <append>true</append> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>DEBUG</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout"> + <Target>System.out</Target> + <encoder> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>${CONSOLE_LOG_LEVEL:-DEBUG}</level> + </filter> + </appender> + <!-- a log appender that collect all log records whose level is greater than debug--> + <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEALL"> + <file>${CONFIGNODE_HOME}/logs/log_confignode_all.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${CONFIGNODE_HOME}/logs/log-confignode-all-%d{yyyyMMdd}.%i.log.gz</fileNamePattern> + <maxFileSize>50MB</maxFileSize> + <maxHistory>168</maxHistory> + <totalSizeCap>5GB</totalSizeCap> + </rollingPolicy> + <append>true</append> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + </appender> + <root level="info"> + <appender-ref ref="FILEDEBUG"/> + <appender-ref ref="FILEWARN"/> + <appender-ref ref="FILEERROR"/> + <appender-ref ref="FILEINFO"/> + <appender-ref ref="FILEALL"/> + <appender-ref ref="stdout"/> + </root> + <logger level="info" name="org.apache.iotdb.confignode"/> + <logger level="info" name="org.apache.ratis"/> +</configuration> diff --git a/standalone/src/assembly/resources/conf/logback-tool.xml b/standalone/src/assembly/resources/conf/logback-tool.xml new file mode 100644 index 00000000000..7b0e9b8295e --- /dev/null +++ b/standalone/src/assembly/resources/conf/logback-tool.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. + +--> +<configuration scan="true" scanPeriod="60 seconds"> + <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout"> + <Target>System.out</Target> + <encoder> + <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern> + <charset>utf-8</charset> + </encoder> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>ERROR</level> + </filter> + </appender> + <root level="error"> + <appender-ref ref="stdout"/> + </root> +</configuration> diff --git a/standalone/src/assembly/resources/sbin/start-iotdb.sh b/standalone/src/assembly/resources/sbin/start-iotdb.sh new file mode 100644 index 00000000000..0bc71301252 --- /dev/null +++ b/standalone/src/assembly/resources/sbin/start-iotdb.sh @@ -0,0 +1,186 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 ---------------------------- +echo Starting Standalone IoTDB +echo ---------------------------- + + + +source "$(dirname "$0")/iotdb-common.sh" + +# iotdb server runs on foreground by default +foreground="yes" + +IOTDB_HEAP_DUMP_COMMAND="" + +if [ $# -ne 0 ]; then + echo "All parameters are $*" +fi + +while true; do + case "$1" in + -c) + IOTDB_CONF="$2" + shift 2 + ;; + -p) + pidfile="$2" + shift 2 + ;; + -f) + foreground="yes" + shift + ;; + -d) + foreground="" + shift + ;; + -g) + PRINT_GC="yes" + shift + ;; + -H) + IOTDB_HEAP_DUMP_COMMAND="$IOTDB_HEAP_DUMP_COMMAND -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$2" + shift 2 + ;; + -E) + IOTDB_JVM_OPTS="$IOTDB_JVM_OPTS -XX:ErrorFile=$2" + shift 2 + ;; + -D) + IOTDB_JVM_OPTS="$IOTDB_JVM_OPTS -D$2" + #checkEnvVariables is in iotdb-common.sh + checkEnvVariables $2 + shift 2 + ;; + -X) + IOTDB_JVM_OPTS="$IOTDB_JVM_OPTS -XX:$2" + shift 2 + ;; + -h) + echo "Usage: $0 [-v] [-f] [-d] [-h] [-p pidfile] [-c configFolder] [-H HeapDumpPath] [-E JvmErrorFile] [printgc]" + exit 0 + ;; + -v) + #SHOW_VERSION="yes" + break + echo "show version is not supported in current version on IoTDB" + exit 1 + ;; + --) + shift + #all others are args to the program + PARAMS=$* + break + ;; + "") + #if we do not use getopt, we then have to process the case that there is no argument. + #in some systems, when there is no argument, shift command may throw error, so we skip directly + #all others are args to the program + PARAMS=$* + break + ;; + *) + echo "Error parsing arguments! Unknown argument \"$1\"" >&2 + exit 1 + ;; + esac +done + +if [ "$(id -u)" -ne 0 ]; then + echo "Notice: in some systems, IoTDB must run in sudo mode to write data. The process may fail." +fi + +#checkAllVariables is in iotdb-common.sh +checkAllConfigNodeVariables + +#checkConfigNodePortUsages is in iotdb-common.sh +checkConfigNodePortUsages + +#checkAllVariables is in iotdb-common.sh +checkAllVariables + +#checkDataNodePortUsages is in iotdb-common.sh +checkDataNodePortUsages + +PARAMS="-s $PARAMS" + +#initEnv is in iotdb-common.sh +initEnv + + +CLASSPATH="" +for f in "${IOTDB_HOME}"/lib/*.jar; do + CLASSPATH=${CLASSPATH}":"$f +done +classname=org.apache.iotdb.StandaloneIoTDB + +launch_service() { + class="$1" + iotdb_parms="-Dlogback.configurationFile=${IOTDB_LOG_CONFIG}" + iotdb_parms="$iotdb_parms -DIOTDB_HOME=${IOTDB_HOME}" + iotdb_parms="$iotdb_parms -DCONFIGNODE_HOME=${IOTDB_HOME}" + iotdb_parms="$iotdb_parms -DIOTDB_DATA_HOME=${IOTDB_DATA_HOME}" + iotdb_parms="$iotdb_parms -DCONFIGNODE_DATA_HOME=${IOTDB_DATA_HOME}" + iotdb_parms="$iotdb_parms -DTSFILE_HOME=${IOTDB_HOME}" + iotdb_parms="$iotdb_parms -DIOTDB_CONF=${IOTDB_CONF}" + iotdb_parms="$iotdb_parms -DCONFIGNODE_CONF=${IOTDB_CONF}" + iotdb_parms="$iotdb_parms -DTSFILE_CONF=${IOTDB_HOME}" + iotdb_parms="$iotdb_parms -Dname=iotdb\.IoTDB" + iotdb_parms="$iotdb_parms -DIOTDB_LOG_DIR=${IOTDB_LOG_DIR}" + iotdb_parms="$iotdb_parms -DCONFIGNODE_LOGS=${IOTDB_LOG_DIR}" + + if [ "x$pidfile" != "x" ]; then + iotdb_parms="$iotdb_parms -Diotdb-pidfile=$pidfile" + fi + + # The iotdb-foreground option will tell IoTDB not to close stdout/stderr, but it's up to us not to background. + if [ "x$foreground" == "xyes" ]; then + iotdb_parms="$iotdb_parms -Diotdb-foreground=yes" + if [ "x$JVM_ON_OUT_OF_MEMORY_ERROR_OPT" != "x" ]; then + [ -n "$pidfile" ] && printf "%d" $! > "$pidfile" + # shellcheck disable=SC2154 + exec $NUMACTL "$JAVA" $JVM_OPTS "$JVM_ON_OUT_OF_MEMORY_ERROR_OPT" $illegal_access_params $iotdb_parms $IOTDB_JVM_OPTS -cp "$CLASSPATH" $IOTDB_JVM_OPTS "$class" $PARAMS + else + [ -n "$pidfile" ] && printf "%d" $! > "$pidfile" + exec $NUMACTL "$JAVA" $JVM_OPTS $illegal_access_params $iotdb_parms $IOTDB_JVM_OPTS -cp "$CLASSPATH" $IOTDB_JVM_OPTS "$class" $PARAMS + fi + # Startup IoTDB, background it, and write the pid. + else + if [ "x$JVM_ON_OUT_OF_MEMORY_ERROR_OPT" != "x" ]; then + exec $NUMACTL "$JAVA" $JVM_OPTS "$JVM_ON_OUT_OF_MEMORY_ERROR_OPT" $illegal_access_params $iotdb_parms $IOTDB_JVM_OPTS -cp "$CLASSPATH" $IOTDB_JVM_OPTS "$class" $PARAMS 2>&1 > /dev/null <&- & + [ -n "$pidfile" ] && printf "%d" $! > "$pidfile" + true + else + exec $NUMACTL "$JAVA" $JVM_OPTS $illegal_access_params $iotdb_parms $IOTDB_JVM_OPTS -cp "$CLASSPATH" $IOTDB_JVM_OPTS "$class" $PARAMS 2>&1 > /dev/null <&- & + [ -n "$pidfile" ] && printf "%d" $! > "$pidfile" + true + fi + fi + + return $? + +} + +# Start up the service +launch_service "$classname" + +exit $? diff --git a/standalone/src/assembly/standalone.xml b/standalone/src/assembly/standalone.xml new file mode 100644 index 00000000000..5aef01b8977 --- /dev/null +++ b/standalone/src/assembly/standalone.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. + +--> +<assembly> + <id>standalone</id> + <formats> + <format>dir</format> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <outputDirectory>lib</outputDirectory> + </dependencySet> + </dependencySets> + <fileSets> + <fileSet> + <directory>src/assembly/resources/conf</directory> + <outputDirectory>conf</outputDirectory> + </fileSet> + <fileSet> + <directory>src/assembly/resources/sbin</directory> + <outputDirectory>sbin</outputDirectory> + <fileMode>0755</fileMode> + </fileSet> + </fileSets> + <files> + <file> + <source>${maven.multiModuleProjectDirectory}/node-commons/src/assembly/resources/conf/iotdb-common.properties</source> + <destName>conf/iotdb-common.properties</destName> + </file> + <file> + <source>${maven.multiModuleProjectDirectory}/node-commons/src/assembly/resources/sbin/iotdb-common.sh</source> + <destName>sbin/iotdb-common.sh</destName> + </file> + </files> +</assembly> diff --git a/standalone/src/main/java/org/apache/iotdb/StandaloneIoTDB.java b/standalone/src/main/java/org/apache/iotdb/StandaloneIoTDB.java new file mode 100644 index 00000000000..43610d9c1dc --- /dev/null +++ b/standalone/src/main/java/org/apache/iotdb/StandaloneIoTDB.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.iotdb; + +import org.apache.iotdb.confignode.service.ConfigNodeCommandLine; +import org.apache.iotdb.db.service.DataNodeServerCommandLine; + +public class StandaloneIoTDB { + + public static void main(String[] args) throws InterruptedException { + new ConfigNodeCommandLine().doMain(args); + Thread.sleep(3000); + new DataNodeServerCommandLine().doMain(args); + } +}
