---
# System prepended metadata

title: DY - 開站文件

---

# DY - 開站文件

## Leading Principles
概念是，會有一台跳板機，上面為了往後佈署、上版用。另外Postgresql專在另外一台實體機。
* Postgresql 環境都需要裝在Linux裡面(實體機Best)
* 跳板機的準備(未來的部屬機器)
* 有多個專案需要安裝(config_center, center_data, lottery_independent_v4)

### Postgresql Installation
#### 安裝Postgresql 12 、pgagent
```shell
sudo apt update && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list && sudo apt update && sudo apt -y install postgresql-12 && apt-get install pgagent -y
```

開database 並將使用者權限加入 (記得將role test123換成DB Team常用的super user)
```sql
create database lottery_independent_v4 with template=template0 encoding='UTF8'  lc_collate= 'en_US.UTF-8' lc_ctype= 'en_US.UTF-8';
create database config_center with template=template0 encoding='UTF8'  lc_collate= 'en_US.UTF-8' lc_ctype= 'en_US.UTF-8';
create role test123 superuser nocreatedb noinherit login password 'test123';
```

Postgresql效能調整設定檔(16Core 32G為例)
```shell
vim /etc/postgresql/12/main/postgresql.conf
```

```
max_connections = 9999
shared_buffers = 8GB
effective_cache_size = 24GB
maintenance_work_mem = 2GB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 209kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 16
max_parallel_workers_per_gather = 4
max_parallel_workers = 16
max_parallel_maintenance_workers = 4
idle_in_transaction_session_timeout = 60000

lc_messages = 'en_US.UTF-8'
lc_monetary = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
timezone = 'Asia/Taipei'
log_timezone = 'Asia/Taipei'

shared_preload_libraries = 'pg_stat_statements'

shared_preload_libraries = 'pg_stat_statements'

pg_stat_statements.max = 10000

pg_stat_statements.track = all

pg_stat_statements.save = on
```

不同地區的設定(依據專案不同設定)
```
log_timezone = 'America/Caracas'
timezone = 'America/Caracas'
```


```shell
service postgresql restart
```

#### pgagent + crontab 設定

### 跳板機
#### Installation Postgresql 12
```shell
sudo apt update && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list && sudo apt update && sudo apt -y install postgresql-12 && apt-get install pgagent -y
```
#### Node.js (After version 10)

curl 安裝 nvm

```
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
```

Nvm install node 版本 v12.13.0

```
nvm install v12.13.0
```

檢查 node 是否為指定版本

```
node -v
```

安裝 node_module

```
npm install
```
#### 專案放置
1. 在root底下開啟db資料夾，並把專案都放入db資料夾裡面
2. 在各專案的custom裡面建立設定檔


### Config Center (給java用的config專案)
### Center Data(Platform, phone_number_rule, bank, System_menus)
### lottery_independnet_v4