> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/th/phatthana/phuenthan/tho-chiliz-chain/run-node.md).

# รัน Chiliz Chain Node

การรัน Chiliz Chain node ของคุณเองช่วยให้คุณมีการควบคุม ความเป็นส่วนตัว และความน่าเชื่อถือที่ดีขึ้น แต่ต้องใช้ความเชี่ยวชาญด้านเทคนิคและทรัพยากรมากกว่าการใช้ RPC endpoint ที่มีอยู่แล้ว

สิ่งนี้ช่วยให้คุณทำธุรกรรมและสื่อสารกับ smart contract บน Chiliz Chain ได้

{% hint style="info" %}
โปรดทราบว่ามีหน้าเอกสารสำหรับการรัน node สำหรับ Validator โดยเฉพาะ: [https://github.com/chiliz-chain/docs/blob/master/th/learn/about-validators/running-a-validator-node.md](https://github.com/chiliz-chain/docs/blob/master/th/learn/about-validators/running-a-validator-node.md "mention")
{% endhint %}

## **ข้อกำหนดเบื้องต้น**

ในการรัน Chiliz Chain node คุณต้องติดตั้ง [Docker](https://www.docker.com/) ไว้บนเครื่องหรือเซิร์ฟเวอร์ของคุณ ดังนั้น โปรดทำการ [ติดตั้ง Docker](https://docs.docker.com/engine/install/) ให้เสร็จสิ้นก่อนดำเนินการต่อ

### **Docker image สำเร็จรูป**

คุณสามารถใช้ Docker image สำเร็จรูปจาก [Chiliz Chain 2.0 public repository บน Docker hub](https://hub.docker.com/repository/docker/chilizchain/ccv2-geth)

## **เปิดใช้งาน node และเริ่มการซิงค์**

จุดเริ่มต้นที่แนะนำในการรัน Chiliz Chain node คือการใช้ mounted data volume หากใช้วิธีนี้ในการสร้าง Docker container ใหม่ ข้อมูลจะถูกเก็บไว้ในไดเรกทอรีและสามารถนำมาใช้ซ้ำหรือโคลนไปยัง node อื่นได้ง่าย

### **ขั้นตอนที่ 1: สร้างไดเรกทอรี**

สร้างไดเรกทอรีและชี้ไปยังมันในพารามิเตอร์ `-v` ในคำสั่งต่อไปนี้:

```bash
docker run \
-v $(pwd)/my-datadir:/datadir \
--name ccv2-node \
-p 8545:8545 \
-p 8546:8546 \
chilizchain/ccv2-geth:latest \
--chiliz # for Chiliz Mainnet. Use --spicy for Spicy Testnet.
--datadir=/datadir \
--ipcdisable
```

### **ขั้นตอนที่ 2: เชื่อมต่อ Client**

ในการเชื่อมต่อ client กับ node คุณต้องเปิดใช้งานเซิร์ฟเวอร์ RPC HTTP และ/หรือ WebSocket โดยระบุกลุ่มพารามิเตอร์ `--http` และ/หรือ `--ws` ตามลำดับ

ตัวอย่างเช่น:

```bash
docker run \
-v $(pwd)/my-datadir:/datadir \
--name ccv2-node \
-p 8545:8545 \
-p 8546:8546 \
chilizchain/ccv2-geth:latest \
--chiliz \ # for Chiliz Mainnet. Use --spicy for Spicy Testnet.
--datadir=/datadir \
--ipcdisable \
--http \
--http.addr=0.0.0.0 \
--http.api=eth,net,web3,debug,txpool \
--http.port=8545 \
--http.corsdomain="*" \
--http.vhosts="*" \
--ws \
--ws.addr=0.0.0.0 \
--ws.api=eth,net,web3,debug,txpool \
--ws.port=8546 \
--ws.origins="*" \
```

{% hint style="warning" %}
**คำเตือน**

เพื่อความปลอดภัย ให้ตั้งค่าที่เหมาะสมสำหรับพารามิเตอร์ต่อไปนี้:

`--http.corsdomain`

`--http.vhosts`

`--ws.origins`
{% endhint %}

## **ข้อมูลการบำรุงรักษา Node**

### เปลี่ยนระดับ verbosity เมื่อทำการ debug

​ในบางกรณี คุณอาจต้องการเพิ่มระดับ verbosity ของ node เช่น เมื่อต้องทำการ debug node หรือ client ที่เชื่อมต่ออยู่

ในการทำเช่นนั้น คุณสามารถกำหนดพารามิเตอร์ `--verbosity` ซึ่งรับค่าต่อไปนี้ได้ (ค่าเริ่มต้นคือ 3):

* 0=silent
* 1=error
* 2=warn
* 3=info
* 4=debug
* 5=detail

### หยุด node และทำความสะอาด

หากคุณเปิดใช้งาน node โดยใช้คำสั่งใดคำสั่งหนึ่งข้างต้น กระบวนการ node ของคุณจะทำงานต่อเนื่องในเบื้องหน้า ในการหยุดกระบวนการนี้ ให้กด CTRL+C

รันคำสั่งต่อไปนี้เพื่อลบ Docker container:

```bash
docker rm ccv2-node
```

### **ลบไดเรกทอรี**

รันคำสั่งต่อไปนี้เพื่อลบไดเรกทอรี:

```bash
rm my-datadir
```

## อัปเดต Node ของคุณ

ทีม Chiliz Chain มุ่งมั่นที่จะรักษา Chiliz Chain ให้ปลอดภัยและทันสมัย และเราจะทำการ hard fork เป็นครั้งคราวในแต่ละปี เช่น Dragon8 hard fork

ในกรณีที่เกิด hard fork node ของคุณจะไม่ซิงค์กับ เครือข่าย ดังนั้นจึงเป็นสิ่งสำคัญที่จะต้องติดตามประกาศของเรา และอัปเดต node ของคุณ

เพื่อให้ node ของคุณได้รับการอัปเดตอยู่เสมอ คุณสามารถทำตามขั้นตอนต่อไปนี้

**หากคุณใช้ Docker:**

1. ตรวจสอบให้แน่ใจว่าคุณหยุดและลบ Docker container ที่มีอยู่ในขณะที่รักษา volume ที่มีฐานข้อมูลของคุณไว้
2. เปิดใช้งาน node ของคุณโดยใช้ [Docker image สำเร็จรูปล่าสุดที่มีอยู่](https://hub.docker.com/repository/docker/chilizchain/ccv2-geth)

**หากคุณใช้ไบนารีของคุณเอง:**

1. [ดาวน์โหลด release ล่าสุดจาก GitHub repository ของเรา](https://github.com/chiliz-chain/v2/releases)
2. สร้างจากที่นั่นด้วยชุดเครื่องมือของคุณ

## การรัน archive node

ในการรัน node ในโหมด archive คุณควรเพิ่มพารามิเตอร์ 2 ตัวต่อไปนี้ในการเรียก `ccv2-geth` ที่นำเสนอข้างต้น:

```bash
--syncmode=full \
--gcmode=archive \
```

## การรัน Chiliz Chain Node จาก Snapshot หรือการสำรองข้อมูล

เพื่อเร่งกระบวนการซิงโครไนซ์ของ Chiliz Chain node ของคุณ คุณสามารถพึ่งพา snapshot — สำเนาล่าสุด (หรือ archive/backup) ของไดเรกทอรีข้อมูล blockchain (`datadir`) วิธีนี้ช่วยให้ node ของคุณพร้อมใช้งานได้เร็วกว่าการซิงค์จากศูนย์

{% hint style="info" %}
แนะนำให้เก็บ snapshot ไว้สำหรับการตั้งค่า node ใหม่\
การเขียนทับ datadir ที่มีอยู่ด้วย snapshot อาจนำไปสู่ความไม่สอดคล้องกัน
{% endhint %}

### Snapshot ที่มีอยู่

แต่ละ เครือข่าย มี snapshot เฉพาะ:

* Spicy Testnet: [chaindata\_snapshot.tar.gz](https://s3.eu-west-3.amazonaws.com/spicy-snapshots.chiliz.com/chaindata_snapshot.tar.gz)
* Chiliz Chain Mainnet: [chaindata\_snapshot.tar.gz](https://s3.eu-west-3.amazonaws.com/snapshots.chiliz.com/chaindata_snapshot.tar.gz)

{% hint style="info" %}
**การล้างข้อมูลที่มีอยู่**

หากคุณตั้งใจจะใช้ snapshot กับ node ที่มีอยู่ ตรวจสอบให้แน่ใจว่าคุณลบไดเรกทอรีและไฟล์ต่อไปนี้ภายใน datadir ของคุณก่อนรีสตาร์ท node:

```bash
rm -rf blobpool transactions.rlp LOCK lightchaindata triecache
```

ขั้นตอนนี้ช่วยป้องกันความขัดแย้งที่อาจเกิดขึ้นจากข้อมูลที่เหลืออยู่
{% endhint %}

### ขั้นตอนในการรัน Node จาก Snapshot:

1. สร้างไดเรกทอรีข้อมูล:

```bash
mkdir -p ~/chiliz-node/my-datadir
```

2. ดาวน์โหลด Snapshot:

แทนที่ URL ด้วย URL ของ Mainnet snapshot หากต้องการ

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~/chiliz-node/my-datadir
nohup curl -L --retry 5 -o chaindata.tar.gz https://s3.eu-west-3.amazonaws.com/spicy-snapshots.chiliz.com/chaindata_snapshot.tar.gz > download.log 2>&1 &
```

{% endcode %}

{% hint style="info" %}
หากต้องการตรวจสอบความคืบหน้าของการดาวน์โหลด ให้ใช้:\
`tail -f download.log`
{% endhint %}

3. แตกไฟล์ Snapshot:

```bash
tar -xzf chaindata.tar.gz
```

4. รัน Chiliz Chain Node:

{% code lineNumbers="true" %}

```bash
docker run \
  -v ~/chiliz-node/my-datadir:/datadir \
  --name ccv2-node \
  -p 8545:8545 \
  -p 8546:8546 \
  chilizchain/ccv2-geth:latest \
  --spicy \  # Use --chiliz for Mainnet
  --datadir=/datadir \
  --ipcdisable \
  --http \
  --http.addr=0.0.0.0 \
  --http.api=eth,net,web3,debug,txpool \
  --http.port=8545 \
  --http.corsdomain="*" \
  --http.vhosts="*" \
  --ws \
  --ws.addr=0.0.0.0 \
  --ws.api=eth,net,web3,debug,txpool \
  --ws.port=8546 \
  --ws.origins="*"
```

{% endcode %}

## ข้อมูลเพิ่มเติมเกี่ยวกับ Geth

เยี่ยมชม [command-line options](https://geth.ethereum.org/docs/fundamentals/command-line-options) ของ Geth เพื่อดูรายการพารามิเตอร์ Geth ทั้งหมดที่มีอยู่


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.chiliz.com/th/phatthana/phuenthan/tho-chiliz-chain/run-node.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
