Docker로 Metabase 및 MySQL 환경 만들기
입문
주가 등 인터넷에서 얻은 데이터를 MySQL에 저장
나는 그것을 가시화하고 싶어서 Metabsae를 해 보았다.
환경을 만들 때 Docker가 사용됩니다.
환경
참고 자료
이번에 하고 싶은 구성.
 디렉토리 구성
.
├── Data
│   └── mysql_data
└── Docker
    └── docker-compose.yml
지구화를 위해 mysql_데이터에 MySQL 파일을 배치합니다.환경 만들기
이미지 없음 확인
$ docker-compose images
Container   Repository   Tag   Image Id   Size
----------------------------------------------
docker compose를 위한 파일 준비
docker-compose.yml에서 봤으면 하는 부분은 다음과 같습니다.
links에 mysql로 기재함으로써 Docker에서 mysql로 이름을 해석할 수 있습니다.volumes에 로컬 파일을 Docker 컨테이너에 로드하는 설정을 기록하여 MySQL의 데이터를 로컬에 저장합니다.그 결과는 데이터를 영구화할 수 있다는 것이다.version: "3"
services:
  metabase:
    container_name: metabase
    image: metabase/metabase
    ports:
      - "3000:3000"
    links:
      - mysql
  mysql:
    container_name: mysql
    image: mysql:5.7.22
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: stock
      MYSQL_USER: stock
      MYSQL_PASSWORD: stock
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ../Data/mysql_data/:/var/lib/mysql
이미지 가져오기
$ docker-compose create
WARNING: The create command is deprecated. Use the up command with the --no-start flag instead.
Pulling mysql (mysql:5.7.22)...
5.7.22: Pulling from library/mysql
be8881be8156: Pull complete
c3995dabd1d7: Pull complete
9931fdda3586: Pull complete
bb1b6b6eff6a: Pull complete
a65f125fa718: Pull complete
2d9f8dd09be2: Pull complete
37b912cb2afe: Pull complete
79592d21cb7f: Pull complete
00bfe968d82d: Pull complete
79cf546d4770: Pull complete
2b3c2e6bacee: Pull complete
Pulling metabase (metabase/metabase:)...
latest: Pulling from metabase/metabase
4fe2ade4980c: Already exists
6fc58a8d4ae4: Pull complete
819f4a45746c: Pull complete
cfead1870569: Pull complete
80eef12953dc: Pull complete
8ea161a68113: Pull complete
db7c1ab963fb: Pull complete
Creating mysql ... done
Creating metabase ... done
$ docker-compose images
Container      Repository        Tag       Image Id      Size
--------------------------------------------------------------
metabase    metabase/metabase   latest   0e41d8de8452   221 MB
mysql       mysql               5.7.22   6bb891430fb6   355 MB
부팅
$ docker-compose up -d
Starting mysql ... done
Starting metabase ... done
만약 -d를 열지 않고 분리 모드에 들어가면 터미널로 돌아갈 수 없습니다.동작 확인(MySQL)
$ mysql --host=127.0.0.1 --user=stock --password
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| stock              |
+--------------------+
2 rows in set (0.02 sec)
데이터 저장
Python으로 주가 정보를 취득하여 MySQL에 저장
에서 만든 Python 코드는 MySQL에 데이터를 저장합니다.
메타데이터 설정
초기 설정
http://localhost:3000/setup
방문
 
 
 docker-compose.yml
links에 기재된 mysql는 호스트 이름입니다.
 
 
 이번에는 미리 MySQL에 데이터 테이블을 만들었기 때문에 MySQL에 있는 테이블의 일람을 표시합니다.
 표의 이름을 누르면 마음대로 요약할 수 있다.
 물론 SQL에서 표의 데이터에 따라 다양한 도표(원도, 스트라이프, 선형도) 등을 만들 수 있다.
 경품
멈추다
$ docker-compose stop
Stopping metabase ... done
Stopping mysql    ... done
시작 (환경이 제거되지 않은 경우)
$ docker-compose start
Starting mysql    ... done
Starting metabase ... done
환경 삭제
컨테이너 중지 및 컨테이너 및 네트워크 삭제
$ docker-compose down
$ docker-compose down
Stopping metabase ... done
Stopping mysql    ... done
Removing metabase ... done
Removing mysql    ... done
Removing network docker_default
환경 삭제(이미지도 삭제)
이미지 삭제
$ docker-compose down --rmi all
Removing metabase ... done
Removing mysql    ... done
Removing network docker_default
Removing image mysql:5.7.22
Removing image metabase/metabase
                Reference
이 문제에 관하여(Docker로 Metabase 및 MySQL 환경 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ITNewcomer/items/73173f032af29175dacd텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)