Skip to content

Commit

Permalink
Merge pull request #73 from cloud-barista/feature/Add-demo-guide
Browse files Browse the repository at this point in the history
Docs: Demo-guide & Fix: NewLogger
  • Loading branch information
heedaeshin authored Oct 8, 2024
2 parents a1c08df + 2f2abdb commit 82f6454
Show file tree
Hide file tree
Showing 76 changed files with 353 additions and 152 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Data Manager 데이터 마이그레이션 기술의 검증을 위한 환경을
* [Data Manager 기능명세서](docs/Datamanager-Function-Specification.md)
* [Data Manager 사용가이드](docs/Datamanager-Usage-Guide.md)
* [Data Manager 도커가이드](docs/Datamanager-Docker-Guide.md)
* [Data Manager 데모가이드](docs/Datamanager-Demo-Guide.md)
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
init: true
# service app
mc-data-manger:
container_name: mc-data-manager
depends_on:
- init-chown-volumes
build:
Expand Down
240 changes: 240 additions & 0 deletions docs/Datamanager-Demo-Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
# Data Manager 사용 가이드

## 사전 준비 사항
### 스토리지/DB 관련 서비스 신청 및 권한 부여
* GCP, NCP같은 경우 서비스 이용 시 이용 신청을 해야한다.
* 로그인 후 사용할 서비스 페이지 접속 후 이용 신청을 하면 된다.
* 예시

**GCP**
<p align="center"><img src="../docs/image/pre-check/gcp_pre_auth.png" ></p>
**NCP**
<p align="center"><img src="../docs/image/pre-check/ncp_pre_auth.png" ></p>

* GCP와 NCP는 사전에 인증정보에 권한을 부여해야합니다.

사용하고자 하는 서비스계정에 Storage Admin 권한 추가
* GCP : https://cloud.google.com/storage../docs/access-control/iam-roles?hl=ko

서브 계정 사용 시 Object Storage 권한 추가
* NCP : https://guide.ncloud-docs.com../docs/storage-objectstorage-subaccount

### CSP 인증정보
1. AWS 인증정보
* [AWS S3, DynamoDB 인증정보](https:/../docs.aws.amazon.com/ko_kr/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey)
2. GCP 인증정보
* [GCP Cloud Storage, FirestoreDB 인증정보](https://developers.google.com/workspace/guides/create-credentials?hl=ko)
3. NCP 인증정보
* [NCP Object Storage 인증정보](https://medium.com/naver-cloud-platform/%EC%9D%B4%EB%A0%87%EA%B2%8C-%EC%82%AC%EC%9A%A9%ED%95%98%EC%84%B8%EC%9A%94-%EB%84%A4%EC%9D%B4%EB%B2%84-%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EC%9C%A0%EC%A0%80-api-%ED%99%9C%EC%9A%A9-%EB%B0%A9%EB%B2%95-1%ED%8E%B8-494f7d8dbcc3)

### AWS, GCP, NCP Cloud DB 설치 및 인증정보
* [DB 설치 및 인증정보](../docs/Cloud-DB-Installation-and-Authentication-Information.md)

### 프로필 설정 가이드
* 위의 생성된 인증정보를 프로젝트의 아래 경로에 저장해야합니다.
> data/var/run/profile/profile.json
```json

[
{
"profileName": "default",
"credentials": {
"aws": {
"accessKey": "",
"secretKey": ""
},
"ncp": {
"accessKey": "",
"secretKey": ""
},
"gcp": {
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "",
"token_uri": "",
"auth_provider_x509_cert_url": "",
"client_x509_cert_url": "",
"universe_domain": ""
}
}
},
{
"profileName": "admin",
"credentials": {
"aws": {
"accessKey": "",
"secretKey": ""
},
"ncp": {
"accessKey": "",
"secretKey": ""
},
"gcp": {
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "",
"token_uri": "",
"auth_provider_x509_cert_url": "",
"client_x509_cert_url": "",
"universe_domain": ""
}
}
}
]
```

## 설치 가이드
* [Data Manager 도커가이드](../docs/Datamanager-Docker-Guide.md)

## 1. 오브젝트 스토리지
### AWS S3 Generate
1. data-manager server 접속 후 좌측 메뉴에서 데이터 생성 -> Object Storage -> AWS S3 순으로 클릭
2. 사용자의 프로필과 리전 선택, 버킷 명을 입력한 다음 생성 할 데이터를 선택 및 용량 입력 후 생성 버튼 클릭

<p align="center"><img src="../docs/image/web/objectstorage/generate_s3.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/objectstorage/generate_s3_result.png" ></p>

### Migrate from AWS S3 to NCP ObjectStorage

1. data-manager server 접속 후 좌측 메뉴에서 Migration -> Object Storage -> AWS s3 to -> Naver Object Storage
2. 사용자의 AWS 접속정보와 버킷명, 사용자의 Naver 접속정보와 버킷명을 입력 후 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/objectstorage/migrate_obj_aws_ncp.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/objectstorage/migrate_obj_aws_ncp_result.png" ></p>

### Backup NCP ObjectStorage

1. data-manager server 접속 후 좌측 메뉴에서 Backup 클릭
2. Backup Service 항목에서 NCP, Objectstorage 선택
3. 사용자의 Naver 접속정보와 버킷명, 백업 경로 입력 후 백업 버튼 클릭

<p align="center"><img src="../docs/image/web/objectstorage/backup_obj_ncp.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/objectstorage/backup_obj_ncp_result.png" ></p>

### Restore GCP ObjectStorage

1. data-manager server 접속 후 좌측 메뉴에서 Restore 클릭
2. Restore Service 항목에서 GCP, Objectstorage 선택
3. 사용자의 GCP 접속정보와 버킷명, 복구 경로 입력 후 복구 버튼 클릭

<p align="center"><img src="../docs/image/web/objectstorage/restore_obj_gcp.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/objectstorage/restore_obj_gcp_result.png" ></p>

## 2. RDBMS
### GCP RDBMS Generate
1. data-manager server 접속 후 좌측 메뉴에서 데이터 생성 -> SQL Database -> MySQL
2. 사용자의 DB Connect Config를 입력하고 생성 버튼 클릭

<p align="center"><img src="../docs/image/web/RDBMS/generate_rdbms_gcp.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/RDBMS/generate_rdbms_gcp_result.png" ></p>


### Migrate from GCP to AWS
1. data-manager server 접속 후 좌측 메뉴에서 MIGRATION -> SQL Database -> MySQL
2. 사용자의 DB Connect Config를 입력하고 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/RDBMS/migrate_rdbms_gcp_aws.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/RDBMS/migrate_rdbms_gcp_aws_result.png" ></p>

### Back Up AWS RDBMS
1. data-manager server 접속 후 좌측 메뉴에서 Backup 클릭
2. Backup Service 항목에서 AWS, RDBMS 선택
3. 사용자의 DB Connect Config를 입력하고 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/RDBMS/backup_rdbms_aws.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/RDBMS/backup_rdbms_aws_result.png" ></p>


### Restore NCP RDBMS

1. data-manager server 접속 후 좌측 메뉴에서 Restore 클릭
2. Restore Service 항목에서 NCP, RDBMS 선택
3. 사용자의 DB Connect Config를 입력하고 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/RDBMS/restore_rdbms_ncp.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/RDBMS/restore_rdbms_ncp_result.png" ></p>

## 3. NRDBMS
### AWS NRDBMS Generate
1. data-manager server 접속 후 좌측 메뉴에서 데이터 생성 -> NO-SQL Database -> Google Firestore
2. 사용자의 AWS 접속정보를 입력하고 생성 버튼 클릭

<p align="center"><img src="../docs/image/web/NRDBMS/generate_nrdbms_aws.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/NRDBMS/generate_nrdbms_aws_result.png" ></p>

### Back Up AWS NRDBMS
1. data-manager server 접속 후 좌측 메뉴에서 Backup 클릭
2. Backup Service 항목에서 AWS, NRDBMS 선택
3. 사용자의 DB Connect Config를 입력하고 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/NRDBMS/backup_nrdbms_aws.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/NRDBMS/backup_nrdbms_aws_result.png" ></p>


### Restore GCP NRDBMS

1. data-manager server 접속 후 좌측 메뉴에서 Restore 클릭
2. Restore Service 항목에서 GCP, NRDBMS 선택
3. 사용자의 GCP 접속정보 입력 후 복구 버튼 클릭

<p align="center"><img src="../docs/image/web/NRDBMS/restore_nrdbms_gcp.png" ></p>

4. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/NRDBMS/restore_nrdbms_gcp_result.png" ></p>


### Migrate from GCP to AWS
1. data-manager server 접속 후 좌측 메뉴에서 MIGRATION -> SQL Database -> MySQL
2. 사용자의 DB Connect Config를 입력하고 실행 버튼 클릭

<p align="center"><img src="../docs/image/web/NRDBMS/migrate_nrdbms_gcp_aws.png" ></p>

3. 성공 및 실패는 아래 로그에서 확인이 가능합니다.

<p align="center"><img src="../docs/image/web/NRDBMS/migrate_nrdbms_gcp_aws_result.png" ></p>




16 changes: 13 additions & 3 deletions docs/Datamanager-Docker-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,31 @@

- Docker run
```shell
docker run -d -p 3300:3300 cloudbaristaorg/mc-data-manager
docker run -d \
-p 3300:3300 \
-v data:/app/data \
--name mc-data-manager \
cloudbaristaorg/mc-data-manager
```

- Docker compose
- docker-compose yaml 파일 생성
```yaml
services:
mc-data-manager:
container_name: mc-data-manager
image: cloudbaristaorg/mc-data-manager
ports:
- "3300:3300"
- "3300:3300"
volumes:
- ./data:/app/data/
```
- 실행
```shell
docker compose -f <filename>.yaml up -d
```

- 인증 프로필 카피
```shell
docker compose cp profile.json mc-data-manager:/app/data/var/run/profile/profile.json
```

51 changes: 0 additions & 51 deletions docs/Datamanager-task-Guide.md

This file was deleted.

Binary file added docs/image/web/NRDBMS/backup_nrdbms_aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/NRDBMS/generate_nrdbms_aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/NRDBMS/migrate_nrdbms_gcp_aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/NRDBMS/restore_nrdbms_gcp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/backup_rdbms_aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/backup_rdbms_aws_resutl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/generate_rdbms_gcp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/migrate_rdbms_gcp_aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/nrdbms_aws_generate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/restore_rdbms_ncp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/RDBMS/restore_rdbms_ncp_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/generate_s3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/generate_s3_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/objectstorage/backup_obj_ncp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/objectstorage/generate_s3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/web/objectstorage/restore_obj_gcp.png
2 changes: 1 addition & 1 deletion models/genDataParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type GenDataParams struct {

type GenFileParams struct {
Directory string `json:"Directory,omitempty" swaggerignore:"true"`
DummyPath string `json:"path,omitempty" swaggerignore:"true"`
DummyPath string `json:"dummyPath,omitempty" swaggerignore:"true"`
FileFormatParams
FileSizeParams
}
Expand Down
15 changes: 13 additions & 2 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"runtime"
"strconv"
"sync"
"time"

"github.com/cloud-barista/mc-data-manager/config"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -96,6 +97,16 @@ func NewLogger(config Config) *zerolog.Logger {
Compress: config.File.Compress,
}

// Ensure the log file directory exists before creating the log file
dir := filepath.Dir(config.File.Path)
if _, err := os.Stat(dir); os.IsNotExist(err) {
// Create the directory if it does not exist
err = os.MkdirAll(dir, 0755) // Set permissions as needed
if err != nil {
log.Fatal().Msgf("Failed to create log directory: %v", err)
}
}

// Ensure the log file exists before changing its permissions
if _, err := os.Stat(config.File.Path); os.IsNotExist(err) {
// Create the log file if it does not exist
Expand Down Expand Up @@ -152,15 +163,15 @@ func getLogLevel(logLevel string) zerolog.Level {
// configureWriter sets up the logger based on the writer type
func configureWriter(logWriter string, level zerolog.Level) *zerolog.Logger {
var logger zerolog.Logger
multi := zerolog.MultiLevelWriter(sharedLogFile, zerolog.ConsoleWriter{Out: os.Stdout})
multi := zerolog.MultiLevelWriter(sharedLogFile, zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})

switch logWriter {
case "both":
logger = zerolog.New(multi).Level(level).With().Timestamp().Caller().Logger()
case "file":
logger = zerolog.New(sharedLogFile).Level(level).With().Timestamp().Caller().Logger()
case "stdout":
logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout}).Level(level).With().Timestamp().Caller().Logger()
logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}).Level(level).With().Timestamp().Caller().Logger()
default:
log.Warn().Msgf("Invalid log writer: %s. Using default value: both", logWriter)
logger = zerolog.New(multi).Level(level).With().Timestamp().Caller().Logger()
Expand Down
Loading

0 comments on commit 82f6454

Please sign in to comment.