Git Product home page Git Product logo

refarch-cloudnative-mysql's Introduction

refarch-cloudnative-mysql

This database will be managed by refarch-cloudnative-micro-inventory microservice.

Setup Inventory Database on Local MySQL Container

  1. Clone git repository. If you cloned the peer repositories ./clonePeers.sh, then you should not do a git clone

    # git clone https://github.com/ibm-cloud-architecture/refarch-cloudnative-mysql.git
    # cd refarch-cloudnative-mysql
    
  2. Create MySQL container with database inventorydb. This database can be connected at <docker-host-ipaddr/hostname>:3306 as dbuser using password.

    Linux/macOS:
    # docker run --name mysql -v $PWD/scripts:/home/scripts -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin123 -e MYSQL_USER=dbuser -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=inventorydb -w /home/scripts -d mysql:latest
    
    Windows:
    # docker run --name mysql -v %CD%\scripts:/home/scripts -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin123 -e MYSQL_USER=dbuser -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=inventorydb -w /home/scripts -d mysql:latest
    
  3. Create items table and load sample data.

    # docker exec -it mysql sh load-data.sh
    
  4. Verify, there should be 12 rows in the table.

    # docker exec -it mysql bash
    # mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE}
    mysql> select * from items;
    mysql> quit
    # exit
    

Inventory database is now setup in local container.

Setup Inventory Database in IBM Bluemix container

  1. Clone git repository. If you cloned the peer repositories ./clonePeers.sh, then you should not do a git clone

    # git clone https://github.com/ibm-cloud-architecture/refarch-cloudnative-mysql.git
    
  2. Change to the directory of the repository.

    # cd refarch-cloudnative-mysql
    
  3. Build docker image using the Dockerfile from repo.

    # docker build -t cloudnative/mysql .
    
  4. Log in to your Bluemix account.

    # cf login -a <bluemix-api-endpoint> -u <your-bluemix-user-id>
    
  5. Set target to use your Bluemix Org and Space.

    # cf target -o <your-bluemix-org> -s <your-bluemix-space>
    
  6. Log in to IBM Containers plugin.

    # cf ic login
    
  7. Check that your organization has set a namespace.

    # cf ic namespace get
    
  8. If there is no namespace set for your , then set a namespace.

    # cf ic namespace get
    
  9. Tag and push mysql database server image to your Bluemix private registry namespace.

    # docker tag cloudnative/mysql registry.ng.bluemix.net/$(cf ic namespace get)/mysql:cloudnative
    # docker push registry.ng.bluemix.net/$(cf ic namespace get)/mysql:cloudnative
    
  10. Create MySQL container with database inventorydb. This database can be connected at <docker-host-ipaddr/hostname>:3306 as dbuser using Pass4dbUs3R.

    It is recommended to change the default passwords used here.

    # cf ic run -m 512 --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Pass4Admin123 -e MYSQL_USER=dbuser -e MYSQL_PASSWORD=Pass4dbUs3R -e MYSQL_DATABASE=inventorydb registry.ng.bluemix.net/$(cf ic namespace get)/mysql:cloudnative
    
  11. Create items table and load sample data. You should see message Data loaded to inventorydb.items.

    # cf ic exec -it mysql sh load-data.sh
    
  12. Verify, there should be 12 rows in the table.

    # cf ic exec -it mysql bash
    # mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE}
    mysql> select * from items;
    mysql> quit
    # exit
    

Inventory database is now setup in IBM Bluemix Container.

refarch-cloudnative-mysql's People

Contributors

moberlin8 avatar ssibm avatar gangchen03 avatar jkwong888 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.