码迷,mamicode.com
首页 > 数据库 > 详细

常用的Docker数据库镜像及处理命令

时间:2019-09-27 01:57:44      阅读:385      评论:0      收藏:0      [点我收藏+]

标签:int   etcd   maximum   dbn   imu   sqlstate   direct   etc   base   

常用的数据库镜像
docker pull wangpengcheng/oracle12c-enterprise:12.2.0.1-sys
docker pull mysql:5.7.26
docker pull store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
docker pull exoplatform/sqlserver
docker pull postgres
docker pull postgres:9.6.13
docker pull pivotaldata/greenplum-server-ubuntu-18 

常用的处理命令
mysql: 
    # 参考: https://hub.docker.com/_/mysql
    docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7.26 
    vim ~/.my.cnf
        [client]
        password=‘root‘
    docker cp .my.cnf 3d4e41ebaa1c:/root/.my.cnf    
    docker exec -it 3d4e41ebaa1c /bin/bash
    mysql -e "drop database if exists adpdb;create database adpdb default character set utf8mb4 collate utf8mb4_bin;"
    mysql -e "drop database if exists oss6 ;create database oss6  default character set utf8mb4 collate utf8mb4_bin;"
    mysqldump -uroot -p××× -hmysql.hepengju.com adpdb > adpdb_$(date +%Y%m%d).sql
    mysqldump -uroot -p××× -hmysql.hepengju.com oss6  > oss6_$(date +%Y%m%d).sql
    mysql adpdb < ~/adpdb_$(date +%Y%m%d).sql 
    mysql oss6 < ~/oss6_$(date +%Y%m%d).sql 

oracle:
    # 参考: https://hub.docker.com/r/bofm/oracle12c
    # 说明: 拉取的不是这个, 但这个里面有文档供参考
    docker run -d --shm-size 1GB --name oracle_database -p 1521:1521 wangpengcheng/oracle12c-enterprise:12.2.0.1-sys
    docker exec -it 111ca416ec33 /bin/bash
    source ~/.bashrc
    sqlplus / as sysdba
    alter user sys identified by sys;
    show con_name ; 
    show pdbs; 
    #alter pluggable database all open; 
    #alter pluggable database all save state;
    alter session set container=orclpdb1;

    drop user dhuser cascade;
    create user dhuser  identified by dhuser;
    grant connect, resource, create view to dhuser;
    grant dba to dhuser;
    grant all privileges to dhuser;
    alter user dhuser quota unlimited on users;
    alter user dhuser quota unlimited on dh_data;
    alter user dhuser quota unlimited on dh_index;
    alter user dhuser quota unlimited on dh_his;

    create or replace directory EXPDP_DIR as ‘/home/oracle/expdp_dir‘;
    create tablespace dh_data datafile ‘/u02/app/oracle/oradata/ORCLCDB/orclpdb1/dh_data.dbf‘ size 100M autoextend on next 10M maxsize 10240M;
    create tablespace dh_index datafile ‘/u02/app/oracle/oradata/ORCLCDB/orclpdb1/dh_index.dbf‘ size 100M autoextend on next 10M maxsize 10240M;
    create tablespace dh_his datafile ‘/u02/app/oracle/oradata/ORCLCDB/orclpdb1/dh_his.dbf‘ size 100M autoextend on next 10M maxsize 10240M;

    # expdp dhuser/Top#123@pdb2 schemas=dhuser directory=EXPDP_DIR dumpfile=dhuser_$(date +%Y%m%d).dmp
    # docker cp 0a45cc68d3af:/home/oracle/expdp_dir/dhuser_20190525.dmp ./
    docker cp dhuser_20190525.dmp 111ca416ec33:/home/oracle/expdp_dir/
    impdp dhuser/dhuser@orclpdb1 directory=EXPDP_DIR dumpfile=dhuser_20190525.dmp
    # "DHUSER"."ASSET_EXTERNAL_TABLE" value too large for column TRANSFER_ENCRYPTION (actual: 115, maximum: 100)
    # 修改列长度, 建立远程连接, 本地Truncate后再插入; 或者修改列长度, 本地Truncate后再重新导入(怎么改长度呢)
    impdp dhuser/dhuser@orclpdb1 directory=EXPDP_DIR dumpfile=dhuser_20190525.dmp tables=ASSET_EXTERNAL_TABLE

    # docker stop -t 120 oracle_database
    # docker start oracle_database

db2:
    # 参考: https://hub.docker.com/u/hepengju/content/sub-3a88b39c-ee6d-4acd-8b93-6aa163baeafc
    vim .env_list
        LICENSE=accept
        DB2INSTANCE=db2inst1
        DB2INST1_PASSWORD=db2inst1
        DBNAME=testdb
        BLU=false
        ENABLE_ORACLE_COMPATIBILITY=false
        UPDATEAVAIL=NO
        TO_CREATE_SAMPLEDB=false
        REPODB=false
        IS_OSXFS=false
        PERSISTENT_HOME=true
        HADR_ENABLED=false
        ETCD_ENDPOINT=
        ETCD_USERNAME=
        ETCD_PASSWORD=
    docker run -d --name db2server --restart=always --privileged=true -p 50000:50000 -p 55000:55000 --env-file .env_list store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
    docker logs -f db2server
    docker exec -it db2server /bin/bash
    db2 create db ftzmisdb using codeset utf-8 territory CN
    # db2 force application all
    # db2 backup database ftzmisdb
    CREATE REGULAR TABLESPACE "TS_FTZMIS_INDEX"
    CREATE REGULAR TABLESPACE "TS_FTZMIS_DATA"
    db2 restore db ftzmisdb  from ‘/database/config/db2inst1‘ on ‘/database/config/db2inst1‘ dbpath on ‘/home/db2inst1‘
    # 报错: SQL1139N  The total size of the table space is too big.  SQLSTATE=54047 解决不了
    docker stop -t 120 db2server
    docker start db2server

sqlserver:
    # 参考: https://hub.docker.com/r/exoplatform/sqlserver
    docker run -d --name sqlserver -e SA_PASSWORD=He736458 -e SQLSERVER_DATABASE=appdb -e SQLSERVER_USER=hepengju -e SQLSERVER_PASSWORD=He736458 -p 1433:1433 exoplatform/sqlserver
    docker logs -f sqlserver
    docker stop -t 120 sqlserver
    docker start sqlserver

postgres: 
    docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:9.6.13
    docker stop postgres
    docker start postgres
 
 

常用的Docker数据库镜像及处理命令

标签:int   etcd   maximum   dbn   imu   sqlstate   direct   etc   base   

原文地址:https://www.cnblogs.com/hepengju/p/11595188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!