아무거나

Docker 를 활용한 로컬 개발용 초 간단 Mysql, Oracle, Elastic Search, Kibana, Cerebro 세팅 본문

Infra/Docker

Docker 를 활용한 로컬 개발용 초 간단 Mysql, Oracle, Elastic Search, Kibana, Cerebro 세팅

전봉근 2022. 7. 29. 13:14
반응형

로컬세팅시 자주 사용하는 명령들을 귀찮아서 한 번에 저장하였다.

 

  • Docker 설치(CentOS8)
    • sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    • sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    • sudo yum install docker-ce
  • Elasticsearch + Kibana + Cerebro 설치 (Docker Compose 또는 Docker 중 선택)
    • Docker Compose
      [docker-compose.yml]
      version: '3.6'
      services:
        elasticsearch:
          image: 'docker.elastic.co/elasticsearch/elasticsearch:7.9.2'
          container_name: es01
          ports:
            - "9200:9200"
            - "9300:9300"
          environment:
            - node.name="es01"
            - cluster.name="es-docker-cluster"
            - bootstrap.memory_lock=true
            - discovery.type=single-node
            - "ES_JAVA_OPTS=-Xms4g -Xmx4g"
          ulimits:
            memlock:
              soft: -1
              hard: -1
          networks:
            - elastic
      
        kibana:
          image: 'docker.elastic.co/kibana/kibana:7.9.2'
          container_name: kibana
          ports:
            - "5601:5601"
          environment:
            - ELASTICSEARCH_HOSTS=["http://es01:9200"]
          depends_on:
            - elasticsearch
          networks:
            - elastic
      
        cerebro:
          image: 'lmenezes/cerebro'
          container_name: 'cerebro'
          ports:
            - "9000:9000"
          environment:
            - "CEREBRO_PORT=9000"
            - "ELASTICSEARCH_HOST=http://es01:9200"
          networks:
            - elastic
      
      volumes:
        data01:
          driver: local
        data02:
          driver: local
        data03:
          driver: local
      
      networks:
        elastic:
          driver: bridge    
      
    • Docker
      // Elasticsearch 설치
      $ docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name elasticsearch7 docker.elastic.co/elasticsearch/elasticsearch:7.1.1
      // Elasticsearch 설정 확인
      $ docker exec -i -t elasticsearch7 cat /usr/share/elasticsearch/config/elasticsearch.yml
      
      // Kibana 설치
      $ docker run -d --link elasticsearch7:elasticsearch -p 5601:5601 --name kibana7 docker.elastic.co/kibana/kibana:7.1.1
      // Kibana 설정 확인
      $ docker exec -i -t kibana7 cat /usr/share/kibana/config/kibana.yml
      
      // Cerebro 설치 (http://localhost:9000/ 접속 후 Elasticsearch 정보 입력)
      $ docker run -d -p 9000:9000 --link elasticsearch7:localhost --name cerebro -e "CEREBRO_PORT=9000" -e "ELASTICSEARCH_HOST=http://localhost:9200" lmenezes/cerebro
      
  • MySQL 설치
$ mkdir -p /home/bkjeon/docker/mysql/data
$ mkdir -p /home/bkjeon/docker/mysql/config

$ docker run -d -p 13306:3306 -e MYSQL_ROOT_PASSWORD=wjsqhdrms --name bkjeon-mysql -v /home/bkjeon/docker/mysql/data:/var/lib/mysql -v /home/bkjeon/docker/mysql/config:/etc/mysql/conf.d mysql:8.0.17 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower_case_table_names=1
$ docker exec -it bkjeon-mysql bash

$ mysql -u root -p
sql) CREATE DATABASE bkjeon
sql) CREATE USER 'bkjeon'@'%' IDENTIFIED BY 'wjsqhdrms';
sql) GRANT ALL PRIVILEGES ON *.* TO 'bkjeon'@'%';
sql) flush privileges;
sql) quit

 

  • Oracle 11g 설치
    • image 다운
      $ docker pull jaspeen/oracle-xe-11g
      
    • 컨테이너 생성
      $ docker run --name oracle11g -d -p 1521:1521 -p 8080:8080 jaspeen/oracle-xe-11g
      
    • sqlplus 를 사용하여 oracle 접속 (만약 ORA-01089: immediate shutdown in progress - no operations are permitted 오류가 발생하면 실행중이니깐 조금 기다렸다가 다시 시도해 보자)
      $ docker exec -it oracle11g sqlplus
      
      // system / oracle 로 접속
      SQL> 
      
    • 계정생성 (위의 sqlplus로도 되지만 안될경우 SQL Developer 툴로 사용)
      • SQL Developer 을 다운받고 실행하여 접속정보에 system / oracle 입력하여 접속한다. (호스트이름:localhost, 포트:1521, SID:xe)
      • 계정생성
        CREATE USER bkjeon IDENTIFIED BY wjsqhdrms;
        
      • 세션권한부여
        GRANT CREATE SESSION TO bkjeon;
        

에러

  • Couldn't connect to Docker daemon at http+docker://localhost - is it running?
    • docker.sock 권한이 없어서 표시되는 문제이다. 즉, 아래와 같이 명령을 입력하자.
    • sudo chown $USER /var/run/docker.sock
반응형
Comments