# Install Gmet

본 문서에서는 메타디움 EN 노드의 설치를 위한 gmet 설정 및 빌드에 대해 설명합니다. 해당 설치과정은 github의 사전 빌드된 파일을 이용하는 경우에는 진행할 필요 없으며, 직접 소스코드를 사용하여 빌드하는 경우에만 해당합니다.

### Download Source Code

go-metadium 소스코드는 [메타디움 github](https://github.com/METADIUM/go-metadium)를 통해 모두에게 공개되어 있으므로 아래와 같이 다운로드를 받을 수 있습니다.

```
git clone https://github.com/METADIUM/go-metadium.git
```

### Build Gmet

메타디움의 gmet은 rocksdb와 leveldb를 지원하며 빌드 시 USE\_ROCKSDB 옵션을 통해 각 버전으로 선택하여 빌드가 가능합니다. 각 버전은 생성되는 체인데이터의 포맷이 다르며 서로 간 호환이 되지 않으므로 사용할 DB 버전을 꼭 확인하여 진행해야 합니다.

아래는 빌드를 진행하기 위한 커맨드이며 메타디움에서 권장하는 ubuntu 운영체제를 기준으로 작성되었습니다.

{% tabs %}
{% tab title="Ubuntu 22.04 LTS" %}

#### Dependency

```
sudo apt-get update
sudo apt-get install -y build-essential golang
```

#### Rocksdb only

```
sudo apt-get install -y libsnappy-dev libjemalloc-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -sf libjemalloc.so.2 libjemalloc.so.1xx
```

#### Download source code

```
git clone https://github.com/METADIUM/go-metadium.git
cd go-metadium
```

#### Make-build (in case of rocksdb)

```
make USE_ROCKSDB=YES 
```

#### Make-build (in case of leveldb)

```
make USE_ROCKSDB=NO
```

#### Copy and untar "build" to $GMET\_HOME

```
GMET_HOME='/opt/meta'
sudo mkdir -p $GMET_HOME 
sudo chown $USER:$USER $GMET_HOME
cp build/metadium.tar.gz $GMET_HOME/
cd $GMET_HOME 
tar xvzf metadium.tar.gz
```

#### Start gmet

```
$GMET_HOME/bin/gmet.sh start
```

#### Check log

```
tail -F $GMET_HOME/logs/log
```

{% endtab %}

{% tab title="Ubuntu 20.04 or 18.04 LTS" %}

#### Dependency

```
sudo apt-get update
sudo apt-get install -y build-essential 
```

#### Rocksdb only

```
sudo apt-get install -y libsnappy-dev libjemalloc-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -sf libjemalloc.so.2 libjemalloc.so.1xx
```

#### Install go version 1.18.4

```
wget https://go.dev/dl/go1.18.4.linux-amd64.tar.gz 
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.4.linux-amd64.tar.gz 
export PATH=$PATH:/usr/local/go/bin 
source $HOME/.profile 
```

#### Download source code

```
git clone https://github.com/METADIUM/go-metadium.git
cd go-metadium
```

#### In case of rocksdb

```
make
```

#### In case of leveldb

```
make USE_ROCKSDB=NO
```

#### Copy and untar "build" to $GMET\_HOME

```
GMET_HOME='/opt/meta'
sudo mkdir -p $GMET_HOME 
sudo chown $USER:$USER $GMET_HOME
cp build/metadium.tar.gz $GMET_HOME/
cd $GMET_HOME 
tar xvzf metadium.tar.gz
```

#### Start gmet

```
$GMET_HOME/bin/gmet.sh start
```

#### Check log

```
tail -F $GMET_HOME/logs/log
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
빌드 환경에 의한 라이브러리 의존성의 문제가 있는 경우에는 아래와 같이 Docker를 이용한 빌드 방식을 권장합니다.&#x20;

<pre><code><strong>make USE_ROCKSDB=YES gmet-linux
</strong></code></pre>

{% endhint %}

### Configuration

빌드가 완료되면 gmet.sh 스크립트를 이용하여 gmet 노드를 구동할 수 있습니다. gmet.sh 스크립트에서는 gmet 노드 구동 시 설정하는 파라미터를 .rc 설정 파일을 생성하여  간단하게 지정할 수 있습니다.

```
# vi $GMET_HOME/.rc 

PORT=8588 
DISCOVER=1        # 1 for enable discovery mode, 0 for disable discovery mode
TESTNET=1         # 1 for Testnet or remove this line for Mainnet
SYNC_MODE=full    # snap, full or archive 
GMET_OPTS="--maxpeers=100" # setup additional options
```


---

# 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://docs.metadium.com/ko/developer/install-node/end-node/install-gmet.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.
