### Development Environment Setup Source: https://github.com/dolphindb/tutorials_cn/blob/master/vscode_extension.md Commands to install dependencies and build the DolphinDB VSCode extension from source. ```shell # 安装最新版的 nodejs # https://nodejs.org/en/download/current/ # 安装 pnpm 包管理器 corepack enable corepack prepare pnpm@latest --activate git clone https://github.com/dolphindb/vscode-extension.git cd vscode-extension # 安装项目依赖 pnpm install # 将 .vscode/settings.template.json 复制为 .vscode/settings.json cp .vscode/settings.template.json .vscode/settings.json # 参考 package.json 中的 scripts # 构建开发版本 pnpm run dev # 在 VSCode 中切换到调试面板,启动 ddb.ext 调试任务(需要先禁用或卸载已安装的 dolphindb 插件) ``` -------------------------------- ### Install and Load Redis Plugin Source: https://github.com/dolphindb/tutorials_cn/blob/master/script/redis_plugin_tutorial/example3-kafka.txt Initial setup to enable Redis functionality in DolphinDB. ```DolphinDB installPlugin("redis") loadPlugin("redis") ``` -------------------------------- ### Start Cluster Components Source: https://github.com/dolphindb/tutorials_cn/blob/master/ha_cluster_deployment.md Commands to start the controller and agent nodes after an upgrade. ```shell sh startController.sh ``` ```shell sh startagent.sh ``` -------------------------------- ### Install and Configure Go Environment Source: https://github.com/dolphindb/tutorials_cn/blob/master/DolphinDB_Telegraf_Grafana.md Commands to install Go and configure the environment variables for compilation. ```bash rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz ``` ```bash export PATH=$PATH:/usr/local/go/bin source /etc/profile ``` ```bash go version ``` -------------------------------- ### Start controller node Source: https://github.com/dolphindb/tutorials_cn/blob/master/multi_machine_cluster_deployment.md Command to start the controller process. ```shell sh startController.sh ``` -------------------------------- ### Start Cluster Nodes Source: https://github.com/dolphindb/tutorials_cn/blob/master/ha_cluster_deployment.md Commands to set permissions and start controller and agent nodes. ```shell chmod +x dolphindb ``` ```shell sh startController.sh ``` ```shell ps aux|grep dolphindb ``` ```shell sh startagent.sh ``` -------------------------------- ### Installing and Initializing Airflow Source: https://github.com/dolphindb/tutorials_cn/blob/master/Best_Practices_for_DolphinDB_and_Python_AirFlow.md Commands to install the DolphinDB provider for Airflow and initialize the environment. ```bash pip install airflow-provider-dolphindb ``` ```bash #初始化数据库 airflow db init #创建用户 airflow users create --username admin --firstname Peter --lastname Parker --role Admin --email spiderman@superhero.org --password admin # 守护进程运行 webserver airflow webserver --port 8080 -D # 守护进程运行 scheduler airflow scheduler -D ``` ```bash ps -aux|grep airflow ``` -------------------------------- ### Start HAProxy Service Source: https://github.com/dolphindb/tutorials_cn/blob/master/haProxy_best_practices.md Commands to start HAProxy on host or via Docker. ```bash $ haproxy -f /haproxy/haproxy.cfg ``` ```bash $ docker run -itd --name ddb_haproxy -p 8080:8080 -p 1080:1080 -v /haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg --privileged=true haproxy:2.6.2-alpine ``` -------------------------------- ### Compile and Install HAProxy Source: https://github.com/dolphindb/tutorials_cn/blob/master/haProxy_best_practices.md Compile the source code and install it to the specified directory. ```bash $ cd haproxy-2.6.2 $ make clean $ make -j 8 TARGET=linux-glibc USE_THREAD=1 $ make PREFIX=${/haproxy} SBINDIR=${/haproxy/bin} install # 根据实际情况将 `${/haproxy}` 和 `${/haproxy/bin}` 替换为实际路径 ``` -------------------------------- ### Install and Generate Requirements Source: https://github.com/dolphindb/tutorials_cn/blob/master/python_api_install_offline.md Install the package to resolve dependencies and export the list to a requirements file. ```bash pip install dolphindb -i https://pypi.tuna.tsinghua.edu.cn/simple ``` ```bash pip freeze dolphindb > requirements.txt ``` -------------------------------- ### Install Java Environment Source: https://github.com/dolphindb/tutorials_cn/blob/master/Debezium_and_Kafka_data_sync.md Commands to install Java 17 and configure the necessary environment variables. ```bash cd /opt sudo mkdir -p /usr/local/java sudo tar -xvf jdk-17.0.7_linux-x64_bin.tar.gz sudo mv jdk-17.0.7 /usr/local/java/java17 ``` ```bash vim ~/.bashrc # 输入下面代码 JAVA_HOME=/usr/local/java/java17 PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH source ~/.bashrc java --version ``` -------------------------------- ### Configure ODBC URL Source: https://github.com/dolphindb/tutorials_cn/blob/master/Migrate_data_from_Redshift_to_DolphinDB.md Example configuration for the /etc/odbc.ini file. ```ini [Redshift] Driver=Amazon Redshift (x64); Server=Your server; Database=Your database ``` -------------------------------- ### 配置用户启动脚本路径 Source: https://github.com/dolphindb/tutorials_cn/blob/master/streaming_auto_sub.md 在配置文件中指定 startup 参数,以在节点启动时自动加载并执行指定的脚本文件。 ```shell startup=/opt/DolphinDB/server/startup.dos ``` -------------------------------- ### Full Example: select * from t Source: https://github.com/dolphindb/tutorials_cn/blob/master/plugin_development_tutorial.md Complete workflow for creating a table, registering it, and executing a select all query. ```cpp vector colNames {"id", "x"}; vector colTypes {DT_SYMBOL, DT_DOUBLE}; TableSP t = Util::createTable(colNames, colTypes, 0, 8); ConstantSP idData = Util::createVector(DT_SYMBOL, 0, 0); ConstantSP xData = Util::createVector(DT_DOUBLE, 0, 0); string testId("APPL"); double testX(100.1); ((Vector*)(idData.get()))->appendString(&testId, 1); ((Vector*)(xData.get()))->appendDouble(&testX, 1); vector data = {idData, xData}; INDEX rows=0; string errMsg; t->append(data, rows, errMsg); heap->addItem("t", t); string strData = t->getString(); string sql = "select * from t"; ConstantSP sqlArg =  new String(DolphinString(sql)); vector args{sqlArg}; ObjectSP sqlObj = heap->currentSession()->getFunctionDef("parseExpr")->call(heap, args); vector evalArgs{sqlObj}; ConstantSP ret = heap->currentSession()->getFunctionDef("eval")->call(heap, evalArgs); ``` -------------------------------- ### Synchronization Time Log Source: https://github.com/dolphindb/tutorials_cn/blob/master/SQLServer_to_DolphinDB.md Example output showing start and end times for a synchronization task. ```text startTime endTime 2022.11.28 11:51:18.092 2022.11.28 11:53:20.198 ``` -------------------------------- ### Implement startup.dos Script Source: https://github.com/dolphindb/tutorials_cn/blob/master/best_implementation_for_NSQ_Plugin.md The startup script initializes the NSQ plugin, connects to the server, creates necessary databases and tables, and enables persistent stream tables. ```dolphindb //加载插件 try{loadPlugin("/DolphinDB/server/plugins/nsq/PluginNsq.txt")} catch(ex){print(ex)} go //连接行情服务器 nsq::connect("/DolphinDB/server/plugins/nsq/nsq_sdk_config.ini") go //获取行情数据的表结构 ordersSchema = nsq::getSchema(`orders) tradeSchema = nsq::getSchema(`trade) snapshotSchema = nsq::getSchema(`snapshot) go //登陆账号 login("admin", "123456") //Level2行情数据存储数据库 dbName = "dfs://stockL2" if(existsDatabase(dbName) == false){ dbDate = database("", VALUE, 2022.01.01..2022.12.01) dbSymbol = database("", HASH, [SYMBOL, 20]) database(dbName, COMPO, [dbDate, dbSymbol], , "TSDB") print("Database created successfully !") } else{ print("Database and table have been created !") } //上交所逐笔委托 tbName = "orders_sh" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table=table(1:0, ordersSchema.name, ordersSchema.type), tableName=tbName, partitionColumns=`TradeDate`InstrumentID, sortColumns=`InstrumentID`TransactTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } //深交所逐笔委托 tbName = "orders_sz" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table=table(1:0, ordersSchema.name, ordersSchema.type), tableName=tbName, partitionColumns=`TradeDate`InstrumentID, sortColumns=`InstrumentID`TransactTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } //上交所逐笔成交 tbName = "trade_sh" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table=table(1:0, tradeSchema.name, tradeSchema.type), tableName=tbName, partitionColumns=`Tradedate`InstrumentID, sortColumns=`InstrumentID`TransactTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } //深交所逐笔成交 tbName = "trade_sz" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table=table(1:0, tradeSchema.name, tradeSchema.type), tableName=tbName, partitionColumns=`Tradedate`InstrumentID, sortColumns=`InstrumentID`TransactTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } //上交所L2快照 tbName = "snapshot_sh" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table(1:0, snapshotSchema.name, snapshotSchema.type), tbName, `TradeDate`InstrumentID, sortColumns=`InstrumentID`UpdateTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } //深交所L2快照 tbName = "snapshot_sz" if(existsTable(dbName, tbName) == false){ db = database(dbName) db.createPartitionedTable(table(1:0, snapshotSchema.name, snapshotSchema.type), tbName, `TradeDate`InstrumentID, sortColumns=`InstrumentID`UpdateTime, keepDuplicates=ALL) print("DFS table created successfully !") } else{ print("DFS table have been created !") } go //创建共享的异步持久化流数据表:上交所逐笔委托 enableTableShareAndPersistence(table=streamTable(1:0, ordersSchema.name, ordersSchema.type), tableName=`orders_sh_stream, cacheSize=1000000, preCache=1000) //创建共享的异步持久化流数据表:深交所逐笔委托 enableTableShareAndPersistence(table=streamTable(1:0, ordersSchema.name, ordersSchema.type), tableName=`orders_sz_stream, cacheSize=1000000, preCache=1000) //创建共享的异步持久化流数据表:上交所逐笔成交 enableTableShareAndPersistence(table=streamTable(1:0, tradeSchema.name, tradeSchema.type), tableName=`trade_sh_stream, cacheSize=1000000, preCache=1000) //创建共享的异步持久化流数据表:深交所逐笔成交 enableTableShareAndPersistence(table=streamTable(1:0, tradeSchema.name, tradeSchema.type), tableName=`trade_sz_stream, cacheSize=1000000, preCache=1000) //创建共享的异步持久化流数据表:上交所L2快照 enableTableShareAndPersistence(table=streamTable(1:0, snapshotSchema.name, snapshotSchema.type), tableName=`snapshot_sh_stream, cacheSize=1000000, preCache=1000) //创建共享的异步持久化流数据表:深交所L2快照 enableTableShareAndPersistence(table=streamTable(1:0, snapshotSchema.name, snapshotSchema.type), tableName=`snapshot_sz_stream, cacheSize=1000000, preCache=1000) ``` -------------------------------- ### Identify Incompatible Java VM Source: https://github.com/dolphindb/tutorials_cn/blob/master/iot_examples.md Example output indicating an incompatible Client VM that will prevent the GUI from starting. ```text Java HotSpot(TM) Client VM ``` -------------------------------- ### Configure Single Node Server Source: https://github.com/dolphindb/tutorials_cn/blob/master/user_level_resource_tracking.md Commands to navigate to the installation directory and edit the configuration file for a single-node setup. ```shell cd /server vim ./dolphindb.cfg ``` -------------------------------- ### Initialize Environment and MQTT Plugin Source: https://github.com/dolphindb/tutorials_cn/blob/master/data/DolphinDB_streaming_application_in_IOT/deviceState.txt Logs into the system and loads the MQTT plugin required for streaming data. ```DolphinDB login(`admin,`123456) try{loadPlugin(getHomeDir()+"/plugins/mqtt/PluginMQTTClient.txt")} catch(ex) {print(ex)} go use mqtt; ``` -------------------------------- ### Verify Java Version Source: https://github.com/dolphindb/tutorials_cn/blob/master/iot_examples.md Command to check the installed Java version and example output for a compatible 64-bit Server VM. ```bash java -version ``` ```text java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) ``` -------------------------------- ### Create Configuration Directory and File Source: https://github.com/dolphindb/tutorials_cn/blob/master/Debezium_and_Kafka_data_sync.md Commands to prepare the directory and file for the MySQL source connector configuration. ```bash mkdir /KFDATA/datasyn-config cd /KFDATA/datasyn-config vim source-mysql.json ``` -------------------------------- ### Identify Port Conflict Error Source: https://github.com/dolphindb/tutorials_cn/blob/master/multi_machine_cluster_deployment.md Example log entry indicating that a node failed to start because the assigned port is already in use. ```log :Failed to bind the socket on port 8900 with error code 98 ``` -------------------------------- ### Start DolphinDB Controller with HTTPS Source: https://github.com/dolphindb/tutorials_cn/blob/master/ACL_and_Security.md Example command to launch a DolphinDB controller with HTTPS enabled and a specified public domain name for certificate generation. ```bash ./dolphindb -enableHTTPS true -home master -publicName www.ABCD.com -mode controller -localSite 192.168.1.30:8500:rh8500 -logFile ./log/master.log ``` -------------------------------- ### Initialize Database and Tables Source: https://github.com/dolphindb/tutorials_cn/blob/master/script/Standard_SQL_in_DolphinDB/create_db_table_sql.txt Create a partitioned database and populate tables with data from CSV files. ```DolphinDB drop database if exists "dfs://hr" create database "dfs://hr" partitioned by HASH([INT, 10]) dir = "/hdd/data/sqlstd/" // 创建数据表 jobs jobs_tmp = loadText(dir+"JOBS.csv") create table "dfs://hr"."jobs" ( JOB_ID SYMBOL, JOB_TITLE STRING, MIN_SALARY INT, MAX_SALARY INT ) jobs = loadTable("dfs://hr", "jobs") jobs.append!(jobs_tmp) select * from jobs // 创建数据表 job_history job_history_tmp=loadText(dir+"JOB_HISTORY.csv") create table "dfs://hr"."job_history" ( EMPLOYEE_ID INT, START_DATE DATE, END_DATE DATE, JOB_ID SYMBOL, DEPARTMENT_ID INT ) partitioned by EMPLOYEE_ID job_history = loadTable("dfs://hr", "job_history") job_history.append!(job_history_tmp) select * from job_history // 创建数据表 locations locations_tmp=loadText(dir+"LOCATIONS.csv") create table "dfs://hr"."locations" ( LOCATION_ID INT, STREET_ADDRESS STRING, POSTAL_CODE LONG, CITY STRING, STATE_PROVINCE STRING, COUNTRY_ID SYMBOL ) locations = loadTable("dfs://hr", "locations") locations.append!(locations_tmp) select * from locations // 创建数据表 regions regions_tmp=loadText(dir+"REGIONS.csv") create table "dfs://hr"."regions" ( REGION_ID INT, REGION_NAME STRING ) regions = loadTable("dfs://hr", "regions") regions.append!(regions_tmp) select * from regions // 创建数据表 employees employees_tmp=loadText(dir+"EMPLOYEES.csv") create table "dfs://hr"."employees" ( EMPLOYEE_ID INT, FIRST_NAME STRING, LAST_NAME STRING, EMAIL STRING, PHONE_NUMBER STRING, HIRE_DATE DATE, JOB_ID SYMBOL, SALARY INT, COMMISSION_PCT DOUBLE, MANAGER_ID INT, DEPARTMENT_ID INT ) employees = loadTable("dfs://hr", "employees") employees.append!(employees_tmp) select * from employees // 创建数据表 departments departments_tmp=loadText(dir+"DEPARTMENTS.csv") create table "dfs://hr"."departments" ( DEPARTMENT_ID INT, DEPARTMENT_NAME STRING, MANAGER_ID INT, LOCATION_ID INT ) departments = loadTable("dfs://hr", "departments") departments.append!(departments_tmp) select * from departments // 创建数据表 countries countries_tmp=loadText(dir+"COUNTRIES.csv") create table "dfs://hr"."countries" ( COUNTRY_ID SYMBOL, COUNTRY_NAME STRING, REGION_ID INT ) countries= loadTable("dfs://hr", "countries") countries.append!(countries_tmp) select * from countries ``` -------------------------------- ### Start Alertmanager Source: https://github.com/dolphindb/tutorials_cn/blob/master/cluster_monitor.md Run the Alertmanager binary with the specified configuration and network settings. ```bash nohup ./alertmanager --config.file=alertmanager.yml --web.listen-address=":9093" --cluster.listen-address=localhost:9095 & ``` -------------------------------- ### Accessing Array Vector Columns via Slicing Source: https://github.com/dolphindb/tutorials_cn/blob/master/Array_Vector.md Use x[start:end] to retrieve a range of columns. Requires start >= 0 and start < end. ```DolphinDB // end 不为空 x = array(INT[], 0).append!([1 2 3, 4 5, 6 7 8, 9 10]) x[0:2] /* [[1,2],[4,5],[6,7],[9,10]] */ y = [1 2 3, 4 5, 6 7 8, 9 10].setColumnarTuple!() y[0:2] /* [[1,2],[4,5],[6,7],[9,10]] */ // end 为空 x = array(INT[], 0).append!([1 2 3, 4 5, 6 7 8, 9 10]) x[1:] /* [[2,3],[5],[7,8],[10]] */ y = [1 2 3, 4 5, 6 7 8, 9 10].setColumnarTuple!() y[1:] /* ([2,3],[5],[7,8],[10]) */ // 当 index 越界时,空值填充 x = array(INT[], 0).append!([1 2 3, 4 5, 6 7 8, 9 10]) x[1:4] /* [[2,3,],[5,,],[7,8,],[10,,]] */ y = [1 2 3, 4 5, 6 7 8, 9 10].setColumnarTuple!() y[1:4] /* [[2,3,],[5,,],[7,8,],[10,,]] */ ``` -------------------------------- ### Configure Startup Script Path Source: https://github.com/dolphindb/tutorials_cn/blob/master/insight_plugin.md Set the startup parameter in the configuration file to point to the custom startup script. ```text startup=/DolphinDB/server/startup.dos` ``` -------------------------------- ### Start agent node Source: https://github.com/dolphindb/tutorials_cn/blob/master/multi_machine_cluster_deployment.md Command to start the agent process. ```shell sh startagent.sh ``` -------------------------------- ### Verify Installation Source: https://github.com/dolphindb/tutorials_cn/blob/master/python_api_install_offline.md Check installed packages and test the DolphinDB connection. ```bash C:\pythonApi>pip list Package Version --------------- --------- dolphindb 1.30.19.2 future 0.18.2 numpy 1.22.3 pandas 1.5.1 pip 21.1.1 python-dateutil 2.8.2 pytz 2022.6 setuptools 56.0.0 six 1.16.0 ``` ```python import dolphindb as ddb s = ddb.session() s.connect("192.168.1.157", 8848, "admin", "123456") s.run("print(\"Welcome to DolphinDB!\")") s.close() ``` ```bash D:\pythonApi>python hello_ddb.py Welcome to DolphinDB! ``` -------------------------------- ### 配置自动加载 Source: https://github.com/dolphindb/tutorials_cn/blob/master/best_implementation_for_NSQ_Plugin.md 在 startup.dos 文件中配置插件自动加载逻辑。 ```dolphindb try{loadPlugin("/DolphinDB/server/plugins/nsq/PluginNsq.txt")} catch(ex){print(ex)} ``` -------------------------------- ### Offline Installation Source: https://github.com/dolphindb/tutorials_cn/blob/master/python_api_install_offline.md Install packages from the requirements file in an offline environment. ```bash pip install -r requirements.txt ``` ```bash D:\pythonApi>pip install -r requirements.txt Processing d:\pythonapi\dolphindb-1.30.19.2-cp38-cp38-win_amd64.whl Processing d:\pythonapi\numpy-1.22.3-cp38-cp38-win_amd64.whl Processing d:\pythonapi\pandas-1.5.1-cp38-cp38-win_amd64.whl Processing d:\pythonapi\python_dateutil-2.8.2-py2.py3-none-any.whl Processing d:\pythonapi\pytz-2022.6-py2.py3-none-any.whl Processing d:\pythonapi\six-1.16.0-py2.py3-none-any.whl Collecting future==0.18.2 Using cached future-0.18.2-py3-none-any.whl Installing collected packages: six, pytz, python-dateutil, numpy, pandas, future, dolphindb Successfully installed dolphindb-1.30.19.2 future-0.18.2 numpy-1.22.3 pandas-1.5.1 python-dateutil-2.8.2 pytz-2022.6 six-1.16.0 ``` -------------------------------- ### Full Example: select avg(x) from t Source: https://github.com/dolphindb/tutorials_cn/blob/master/plugin_development_tutorial.md Complete workflow for creating a table, registering it, and executing an aggregation query. ```cpp vector colNames {"id", "x"}; vector colTypes {DT_SYMBOL, DT_DOUBLE}; TableSP t = Util::createTable(colNames, colTypes, 0, 8); ConstantSP idData = Util::createVector(DT_SYMBOL, 0, 0); ConstantSP xData = Util::createVector(DT_DOUBLE, 0, 0); string testId("APPL"); double testX(100.1); ((Vector*)(idData.get()))->appendString(&testId, 1); ((Vector*)(xData.get()))->appendDouble(&testX, 1); vector data = {idData, xData}; INDEX rows=0; string errMsg; t->append(data, rows, errMsg); heap->addItem("t", t); string strData = t->getString(); string sql = "select avg(x) from t"; ConstantSP sqlArg =  new String(DolphinString(sql)); vector args{sqlArg}; ObjectSP sqlObj = heap->currentSession()->getFunctionDef("parseExpr")->call(heap, args); vector evalArgs{sqlObj}; ConstantSP ret = heap->currentSession()->getFunctionDef("eval")->call(heap, evalArgs); ``` -------------------------------- ### Install Perl Source: https://github.com/dolphindb/tutorials_cn/blob/master/ODBC_plugin_user_guide.md Install the Perl dependency required for OpenSSL compilation. ```bash 1yum install perl ``` -------------------------------- ### Install Zookeeper Source: https://github.com/dolphindb/tutorials_cn/blob/master/Debezium_and_Kafka_data_sync.md Commands to extract and prepare the Zookeeper installation directory. ```bash cd /opt sudo tar -xvf apache-zookeeper-3.7.1-bin.tar.gz sudo mv apache-zookeeper-3.7.1-bin zookeeper sudo chown -R root:root zookeeper sudo chmod -R 755 zookeeper ``` -------------------------------- ### Plugin Configuration File Source: https://github.com/dolphindb/tutorials_cn/blob/master/plugin_advance.md Example content for the PluginTest.txt configuration file. ```text test,libPluginTest.so myFunc1,myFunc1,system,2,2,0 myFunc2,myFunc2,system,0,0,0 ``` -------------------------------- ### Setup Persistent Database and Subscription Source: https://github.com/dolphindb/tutorials_cn/blob/master/script/iot_demo_script.txt Creates a partitioned database and subscribes the stream table to persist data into it. ```DolphinDB if(exists("dfs://iotDemoDB")){ dropDatabase("dfs://iotDemoDB") } db1 = database("",VALUE, today()..(today()+30)) db2 = database("",RANGE, 0..10*100) db = database("dfs://iotDemoDB",COMPO,[db1,db2]) tableSchema=table(1:0,`hardwareId`ts`temp1`temp2`temp3,[INT,TIMESTAMP,DOUBLE,DOUBLE,DOUBLE]) dfsTable = db.createPartitionedTable(tableSchema,"sensorTemp",`ts`hardwareId) subscribeTable(tableName="sensorTemp", actionName="sensorTemp", offset=-1, handler=append!{dfsTable}, msgAsTable=true, batchSize=1000000, throttle=10) jobId = submitJob("simulateData", "simulate sensor data", writeData) ``` -------------------------------- ### Install Grafana Source: https://github.com/dolphindb/tutorials_cn/blob/master/DolphinDB_Telegraf_Grafana.md Download and install the Grafana enterprise RPM package. ```bash wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.3.2-1.x86_64.rpm sudo yum install grafana-enterprise-9.3.2-1.x86_64.rpm ``` -------------------------------- ### Create MySQL Database Source: https://github.com/dolphindb/tutorials_cn/blob/master/Debezium_and_Kafka_data_sync.md Initializes a new database named basicinfo. ```sql create database basicinfo; ``` -------------------------------- ### Install NTP Daemon Source: https://github.com/dolphindb/tutorials_cn/blob/master/deploy_dolphindb_on_new_server.md Install the ntp package on both server and client machines. ```console # yum install ntp ``` -------------------------------- ### Create Partitioned Table and Execute Explain Query Source: https://github.com/dolphindb/tutorials_cn/blob/master/DolphinDB_Explain.md Sets up a TSDB partitioned table and executes a query with the [HINT_EXPLAIN] hint to view the execution plan. ```DolphinDB // 导入股票数据,按月分区;csv的数据请见附录。 login(`admin,`123456); dbpath = "dfs://stocks";if(existsDatabase(dbpath)) dropDatabase(dbpath); db1=database(,HASH,[SYMBOL,40]); db2=database(,VALUE,2020.01M..2022.01M); db=database(dbpath,COMPO,[db1, db2],,"TSDB") // 这里YOURDIR替换为实际的目录 schema=extractTextSchema("YOURDIR/20200601.csv") t=table(1:0,schema.name,schema.type) db.createPartitionedTable(t,`quotes, `symbol`date,,`symbol`date`time) def transDate(mutable t, diff){ return t.replaceColumn!(`date,t.date+diff); } diffs = [20,60]; for(diff in diffs){ // 这里YOURDIR替换为实际的目录 loadTextEx(dbHandle=db,tableName=`quotes,partitionColumns=`symbol`date,filename="YOURDIR/20200601.csv",transform=transDate{,diff}) } select [HINT_EXPLAIN] symbol from loadTable("dfs://stocks","quotes") group by symbol; ``` -------------------------------- ### Initialize Database and Partitioning Source: https://github.com/dolphindb/tutorials_cn/blob/master/data/demoScript.txt Defines the database path, partition ranges, and creates a partitioned table structure. ```DolphinDB login(`admin,`123456) dbPath = "dfs://SAMPLE_TRDDB" tableName = `tradingDay rootDir="/home/data/sample" yearRange =date(2008.01M + 12*0..22) symbols = array(SYMBOL, 0, 100) yearDirs = files(rootDir)[`filename] for(yearDir in yearDirs){ path = rootDir + "/" + yearDir symbols = files(path)[`filename].upper().strReplace(".CSV","") } symbols = symbols.distinct().sort!().append!("999999"); symRanges = symbols.cutPoints(100) dbDate=database("", RANGE, yearRange) dbID=database("", RANGE, symRanges) db = database(dbPath, COMPO, [dbDate, dbID]) pt=db.createPartitionedTable(table(1000000:0, `symbol`exchange`cycle`tradingDay`date`time`open`high`low`close`volume`turnover`unixTime, [SYMBOL,SYMBOL,INT,DATE,DATE,TIME,DOUBLE,DOUBLE,DOUBLE,DOUBLE,LONG,DOUBLE,LONG]), tableName, `tradingDay`symbol) ``` -------------------------------- ### Main Execution Logic Source: https://github.com/dolphindb/tutorials_cn/blob/master/data/DolphinDB_streaming_application_in_IOT/deviceState.txt Orchestrates the environment setup, streaming consumption, and data publication. ```DolphinDB def main(){ clearEnv() createInOutTable() consume() host="127.0.0.1" port=1883 topic="sensor/test" writeStreamTable(host, port, topic) t=loadText(getHomeDir()+"/deviceState.csv") //myFormat=take("", 3) f= mqtt::createCsvFormatter(myFormat, ',', ';') f = createJsonFormatter() batchsize=100 submitJob("submit_pub1", "submit_p1", publishTableData{host,topic,f, batchsize,t}) } main() ``` -------------------------------- ### Install patchelf Source: https://github.com/dolphindb/tutorials_cn/blob/master/performance_optimization_based_on_glibc.md Command to install the patchelf utility used for modifying ELF binaries. ```bash sudo yum install patchelf ``` -------------------------------- ### Install PostgreSQL ODBC Driver Source: https://github.com/dolphindb/tutorials_cn/blob/master/migrate_data_from_Postgre_and_Greenplum_to_DolphinDB.md Install the PostgreSQL ODBC driver on a Centos system. ```bash yum install -y postgresql-odbc.x86_64 ``` -------------------------------- ### Configure MongoDB Database and Sharding Source: https://github.com/dolphindb/tutorials_cn/blob/master/benchmark/DolphinDB vs MongoDB/mongodb_taq_partitioned.txt Initial database setup and sharding configuration commands. ```javascript use config db.chunks.find() db.settings.save({"_id":"chunksize","value":1024}) use admin sh.enableSharding("taq_pt_db") ``` -------------------------------- ### Install HAProxy Dependencies Source: https://github.com/dolphindb/tutorials_cn/blob/master/haProxy_best_practices.md Install required system packages before compiling HAProxy from source. ```bash $ yum -y install epel-release gcc systemd-devel ``` -------------------------------- ### Initialize Table for loadMyDataEx Source: https://github.com/dolphindb/tutorials_cn/blob/master/plugin_development_tutorial.md Checks for the existence of a table and either loads it or creates a new partitioned table based on the provided schema. ```cpp string dbPath = ((SystemHandleSP) dbHandle)->getDatabaseDir(); long long fileLength = Util::getFileLength(path->getString()); vector existsTableArgs = {new String(dbPath), tableName}; bool existsTable = heap->currentSession()->getFunctionDef("existsTable")->call(heap, existsTableArgs)->getBool(); // 相当于 existsTable(dbPath, tableName) ConstantSP result; if (existsTable) { // 若表存在,加载表 vector loadTableArgs = {dbHandle, tableName}; result = heap->currentSession()->getFunctionDef("loadTable")->call(heap, loadTableArgs); // 相当于 loadTable(dbHandle, tableName) } else { // 若表不存在,创建表 TableSP schema = extractMyDataSchema(new Void(), new Void()); ConstantSP dummyTable = DBFileIO::createEmptyTableFromSchema(schema); vector createTableArgs = {dbHandle, dummyTable, tableName, partitionColumns}; result = heap->currentSession()->getFunctionDef("createPartitionedTable")->call(heap, createTableArgs); // 相当于 createPartitionedTable(db, dummyTable, tableName, partitionColumns) } ``` -------------------------------- ### Install ODBC Dependencies on CentOS Source: https://github.com/dolphindb/tutorials_cn/blob/master/SQLServer_to_DolphinDB.md Commands to install freeTDS and unixODBC libraries on CentOS. ```bash # 安装 freeTDS yum install -y freetds # 安装 unixODBC 库 yum install unixODBC-devel ``` -------------------------------- ### Granting DBOBJ_CREATE and Creating a Partitioned Table Source: https://github.com/dolphindb/tutorials_cn/blob/master/Permission_Management.md Demonstrates setting up users, granting database ownership, and creating a partitioned table in a DFS database. ```DolphinDB login("admin", "123456") createUser("user1","123456",,true) createUser("user2","123456",,true) grant(`user1, DB_OWNER,"dfs://test*") login("user1", "123456") dbName = "dfs://test" if(existsDatabase(dbName)){ dropDatabase(dbName) } t = table(1..10 as id , rand(100, 10) as val) db=database(dbName, VALUE, 1..10) grant(`user2, DBOBJ_CREATE ,"dfs://test") login("user2", "123456") pt1= db.createPartitionedTable(t, "pt1",`id).append!(t) ``` -------------------------------- ### Initialize Database and Stream Table Source: https://github.com/dolphindb/tutorials_cn/blob/master/ddb_cpp_api_connector.md Server-side script to set up a partitioned table and a stream table for MTW ingestion. ```dolphindb // 建立分布式数据库及分区表 dbname="dfs://db_demo" tablename="collect" cols_info=`ts`deviceCdoe`logicalPostionId`physicalPostionId`propertyCode`propertyValue cols_type=[DATETIME,SYMBOL,SYMBOL,SYMBOL,SYMBOL,INT] t=table(1:0,cols_info,cols_type) db=database(dbname,VALUE,[2022.11.01],engine=`TSDB) pt=createPartitionedTable(db,t,tablename,`ts,,`deviceCdoe`ts) ``` ```dolphindb // 建立流表 def saveToDFS(mutable dfstable, msg): dfstable.append!(msg) share streamTable(1:0, cols_info, cols_type) as streamtable; subscribeTable(tableName="streamtable", actionName="savetodfs", offset=0, handler=saveToDFS{pt}, msgAsTable=true, batchSize=1000, throttle=1) ``` -------------------------------- ### Create Database and Load Data Source: https://github.com/dolphindb/tutorials_cn/blob/master/script/fund_factor_contrasted_by_py/fund_data_load.txt Initializes a composite partitioned database and appends the processed data. ```DolphinDB dbName = "dfs://fund_OLAP" dataDate = database(, VALUE, 2021.01.01..2021.12.31) symbol = database(, HASH, [SYMBOL, 20]) if(existsDatabase(dbName)){ dropDatabase(dbName) } db = database(dbName, COMPO, [dataDate, symbol]) name = `tradingDate`fundNum`value type = `DATE`SYMBOL`DOUBLE tbTemp = table(1:0, name, type) tbName1 = "fund_OLAP" db.createTable(tbTemp, tbName1) loadTable(dbName, tbName1).append!(result) tbName2 = "fund_hs_OLAP" db.createTable(tbTemp, tbName2) loadTable(dbName, tbName2).append!(result1) ``` -------------------------------- ### Install unixODBC on Linux Source: https://github.com/dolphindb/tutorials_cn/blob/master/ClickHouse_to_DolphinDB.md Commands to install the unixODBC library on Centos and Ubuntu systems. ```bash # 安装 unixODBC 库 yum install unixODBC unixODBC-devel ``` ```bash # 安装 unixODBC 库 apt-get install unixodbc unixodbc-dev ``` -------------------------------- ### Configure Startup Path Source: https://github.com/dolphindb/tutorials_cn/blob/master/best_implementation_for_NSQ_Plugin.md Set the startup script path in the DolphinDB configuration file. ```text startup=/DolphinDB/server/startup.dos ```