# 设置完整节点 (Setting up the full node)

在启动完整节点之前，需要链的唯一标识符 `chain-id`，该标识符将在创世文件准备好后发布。

### 加入网络 (Join the network)

一旦 `chain-id` 已经分发，就可以使用 `CHAIN_ID` 加入网络：

```
  export CHAIN_ID="namada-mainnet" ## (replace with the actual chain-id)
  namada client utils join-network --chain-id $CHAIN_ID
```

### 启动您的节点并同步 (Start your node and sync)

```
  CMT_LOG_LEVEL=p2p:none,pex:error namada node ledger run
```

可选项 (Optional)：如果您想要更多日志，可以运行：

```
NAMADA_LOG=info CMT_LOG_LEVEL=p2p:none,pex:error NAMADA_CMT_STDOUT=true namada node ledger run
```

如果您想将日志保存到文件，可以运行：

```
TIMESTAMP=$(date +%s)
NAMADA_LOG=info CMT_LOG_LEVEL=p2p:none,pex:error NAMADA_CMT_STDOUT=true namada node ledger run &> logs-${TIMESTAMP}.txt
tail -f -n 20 logs-${TIMESTAMP}.txt ## (in another shell)
```

### 以 systemd 服务方式运行 namada (Running namada as a systemd service)

{% hint style="info" %}
下面的脚本是由 Encipher88 社区贡献的，目前只能在 Ubuntu 机器上运行。对许多验证者来说，它非常有用。
{% endhint %}

下面假设您已经从源代码安装了 namada，并用 `make install` 安装。它至少假定相应的二进制文件位于 `/usr/local/bin/`。

```
which namada ## (should return /usr/local/bin/namada)
```

下面为 systemd 创建了一个服务文件，该服务文件将把 namada 作为服务运行。这对于在后台运行节点以及在节点崩溃时自动重启节点非常有用。

```
sudo tee /etc/systemd/system/namadad.service > /dev/null <<EOF
[Unit]
Description=namada
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.local/share/namada
Environment=CMT_LOG_LEVEL=p2p:none,pex:error
Environment=NAMADA_CMT_STDOUT=true
ExecStart=/usr/local/bin/namada node ledger run 
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
```

使用下面的命令启用服务：

```
sudo systemctl daemon-reload
sudo systemctl enable namadad
```

现在您可以通过 systemd 命令管理节点：

运行节点

```
sudo systemctl start namadad
```

停止节点

```
sudo systemctl stop namadad
```

重新启动节点

```
sudo systemctl restart namadad
```

显示节点日志

```
sudo journalctl -u namadad -f -o cat
```


---

# Agent Instructions: 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:

```
GET https://tantalum666.gitbook.io/namada-docs-chinese/yun-ying-zhi-nan-operators-guide/yun-xing-wan-zheng-jie-dian-runningafull-node/she-zhi-wan-zheng-jie-dian-setting-up-the-full-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
