# Install Guide

### Build

WEMIX3.0은 이더리움을 기반으로 구현되어 빌드 방법은 `go-ethereum`과 동일하며 다만 `geth`가 `gwemix`로 변경되었습니다. BP의 설치방법은 EN의 설치와 동일하며 동일한 binary를 사용합니다. 따라서 동일한 절차로 build까지 진행됩니다. &#x20;

첫번째, 개발자는 리눅스 머신에서 아래의 명령어를 실행하여 [`go-wemix` ](https://github.com/wemixarchive/go-wemix)소스코드를 다운로드 받습니다.&#x20;

```
git clone https://github.com/wemixarchive/go-wemix.git
```

이후 해당 go-wemix 디렉토리로 이동하여 아래의 명령을 실행하면 `gwemix`의 빌드가 시작됩니다. USE\_ROCKSDB option에 따라 Rocksdb 혹은 Leveldb로 빌드됩니다. 두 데이터베이스는 호환성이 없으니 다른 머신에서 받아놓은 chaindata를 이용할 때는 db버전을 꼭 확인해야 합니다.

본 장은 Ubuntu환경을 기준으로 설명되어있습니다. Ubuntu환경에서 직접 소스코드로부터 gwemix를 빌드하기 위해서는 다음의 과정을 따라서 진행해야 합니다.

{% 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/wemixarchive/go-wemix.git 
cd go-wemix
```

#### In case of rocksdb

```
make
```

#### In case of leveldb

```
make USE_ROCKSDB=NO
```

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

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

#### Create .rc at $GWEMIX \_HOME with the following info

```
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
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

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

{% endtab %}

{% tab title="Ubuntu 20.04.4 or 18.04.6 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/wemixarchive/go-wemix.git 
cd go-wemix
```

#### In case of rocksdb

```
make
```

#### In case of leveldb

```
make USE_ROCKSDB=NO
```

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

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

#### Create .rc at $GWEMIX\_HOME with the following info

```
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
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

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

{% endtab %}
{% endtabs %}

위와 같이 `make`를 실행하는 경우, 설치 편의를 위해 `logrot`와 `gwemix.tar.gz`가 한번에 빌드되어 `build` 디렉터리에 압축파일로 저장됩니다. 생성된 `gwemix.tar.gz`에는 다음과 같은 파일들이 포함됩니다.&#x20;

```
bin/gwemix        ## gwemix binary
bin/gwemix.sh     ## gwemix control shell script
bin/logrot        ## log rotator
```

### Docker 이미지를 이용한 Build <a href="#build-with-docker-image" id="build-with-docker-image"></a>

WEMIX3.0은 라이브러리 의존성이 문제가 되는 경우를  해결하기 위하여 docker 이미지를 사용할 수 있습니다. Linux혹은 MacOS X에서 빌드하는 경우 다음 과정을 통하여 빌드할 수 있습니다.

{% hint style="info" %}
현재 Apple Chip MacOS환경과 Windows환경에서 docker build를 지원하지 않으며, 추후 지원을 제공할 예정입니다.&#x20;
{% endhint %}

{% tabs %}
{% tab title="Rocksdb" %}

```
make USE_ROCKSDB=YES gwemix-linux
```

{% endtab %}

{% tab title="Leveldb" %}

```
make USE_ROCKSDB=NO gwemix-linux
```

{% endtab %}
{% endtabs %}

Docker를 통해서 빌드된 `gwemix.tar.gz` 바이너리를 Ubuntu환경으로 복사하여 설치하려면 다음의 과정을 따라야 합니다.

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

#### 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.1
```

#### Copy and untar "build" to $GWEMIX\_HOME <a href="#copy-and-untar-build-to-optnxt-2" id="copy-and-untar-build-to-optnxt-2"></a>

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

#### Create .rc at $GWEMIX\_HOME <a href="#create-rc-at-optnxt-2" id="create-rc-at-optnxt-2"></a>

```
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 
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix <a href="#start-gwemix-2" id="start-gwemix-2"></a>

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log <a href="#check-log-2" id="check-log-2"></a>

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

{% endtab %}

{% tab title="Ubuntu 18.04.6 LTS" %}

#### Rocksdb only

```
sudo apt-get isntall libjemalloc1
```

#### Copy and untar "build" to $GWEMIX\_HOME <a href="#copy-and-untar-build-to-optnxt-2" id="copy-and-untar-build-to-optnxt-2"></a>

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

#### Create .rc at $GWEMIX\_HOME <a href="#create-rc-at-optnxt-2" id="create-rc-at-optnxt-2"></a>

```
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 
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix <a href="#start-gwemix-2" id="start-gwemix-2"></a>

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log <a href="#check-log-2" id="check-log-2"></a>

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

{% endtab %}
{% endtabs %}


---

# 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.wemix.com/ko/install-and-operation/block-producer-node/install-guide.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.
