docker 安装
# 1、更新centos的yum
yum update -y
# 2、卸载旧版本(如果安装过旧版本的话)
yum remove docker docker-common docker-selinux docker-engine
# 3、安装docker软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
# 4、设置yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 5、查看docker版本
yum list docker-ce --showduplicates | sort -r
# 6、选择需要安装的版本
yum install -y docker-ce-17.12.0.ce
或者直接 yum -y install docker-ce
# 7、设置开机自启动、容器自启动、启动docker
# docker 自启动
systemctl enable docker
# 关闭 docker 自启动
systemctl disable docker.service
systemctl start docker
# 容器自启动
docker update --restart=always 容器ID
docker常用命令
# 查看完整Command
docker ps -a --no-trunc
# 进入容器
docker exec -it 容器ID /bin/bash
# 查看应用最近10秒日志
docker logs -f --since '10m' 容器名称
# 查看应用挂载目录
docker inspect container_id | grep Mounts -A 20
# 本地到docker
docker cp 本地路径 容器id或者容器名字:容器内路径
docker cp /home/acc0526.dmp oracle11g:/home/
# 服务器到本地
docker cp 容器id或者容器名字:容器内路径 本地路径
docker安装各种软件
安装nginx
# 查找镜像
docker search nginx
# 拉取镜像到本地
docker pull nginx
1、本地配置创建文件夹
mkdir -p /AFCAPP/docker/nginx/conf.d
mkdir -p /AFCAPP/docker/nginx/html
mkdir -p /AFCAPP/docker/nginx/logs
mkdir -p /AFCAPP/docker/nginx/conf/nginx.conf
2、拷贝文件到本地
docker cp nginx:/etc/nginx/nginx.conf /AFCAPP/docker/nginx/nginx.conf
docker cp nginx:/etc/nginx/conf.d /AFCAPP/docker/nginx/conf.d
docker cp nginx:/usr/share/nginx/html /AFCAPP/docker/nginx/html
3、创建docker容器并挂载目录
docker run -p 80:80 --name nginx-acc --restart=always \
-v /AFCAPP/docker/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /AFCAPP/docker/nginx/conf.d:/etc/nginx/conf.d \
-v /AFCAPP/docker/nginx/html:/usr/share/nginx/html \
-v /AFCAPP/docker/nginx/logs:/var/log/nginx \
-d nginx
安装Oracle11g
1、拉取镜像,启动容器
# 1、拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
# 2、创建并启动容器
docker run --name oracle_temp -p 1500:1521 --privileged=true -d registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
# 3 创建挂载目录
mkdir -p /home/oracle/data
docker cp oracle_temp:/home/oracle/app/oracle/oradata/ /home/oracle/data/
#修改挂载目录所属用户和用户组
chown -R 500:500 /home/oracle/data
# 删除临时容器
docker rm -f oracle_temp
# 创建正式容器
docker run -d --name oracle11g -p 1521:1521 --privileged=true -v /home/oracle/data/oradata:/home/oracle/app/oracle/oradata registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest
# 修改文件
docker exec -it oracle11g bash
rm -rf /home/oracle/app/oracle/flash_recovery_area/helowin/control02.ctl #删除oracle的机制文件
cp /home/oracle/app/oracle/oradata/helowin/control01.ctl /home/oracle/app/oracle/flash_recovery_area/helowin/control02.ctl #拷贝
exit;
docker restart oracle11g#重启
2、进入oracle容器,修改环境变量
source ~/.bash_profile
3、登录oracle 创建用户
sqlplus / as sysdba
# 修改system、sys密码
alter user system identified by system;
alter user sys identified by sys;
# 修改密码规则策略为密码永不过期
alter profile default limit password_life_time unlimited;
# 修改数据库最大连接数据
alter system set processes=1000 scope=spfile;
4、查看表空间、创建用户
# 查看数据库版本、表空间位置
select * from v$version;
select name from v$datafile;
# 创建表空间
CREATE TABLESPACE UDMTBS LOGGING
DATAFILE '/home/oracle/app/oracle/oradata/helowin/UDMTBS.dbf' SIZE 100M AUTOEXTEND ON
NEXT 50M MAXSIZE 10240M
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
# 建立用户
CREATE USER ACC PROFILE DEFAULT
IDENTIFIED BY ACC DEFAULT TABLESPACE ACC
ACCOUNT UNLOCK;
# 改变用户在表空间上的配额:
ALTER USER ACC quota UNLIMITED ON ACC;
# 建立授权
GRANT CONNECT TO ACC;
GRANT DBA TO ACC;
5、导入dmp数据库
su - oracle
imp ACC/ACC@192.168.1.227:1521/HELOWIN file=E:/BaiduNetdiskDownload/acc0712.dmp full=y buffer=3276800 ignore=y log=E:/imp.log
imp ACC/ACC@HELOWIN file=E:/BaiduNetdiskDownload/acc0712.dmp full=y buffer=3276800 ignore=y log=E:/imp.log
安装fastdfs
docker pull delron/fastdfs
docker run -dti --network=host --name tracker -v /home/fdfs/tracker:/var/fdfs -v /etc/localtime:/etc/localtime delron/fastdfs tracker
docker run -dti --network=host --name storage -e TRACKER_SERVER=192.168.1.205:22122 -v /home/fdfs/storage:/var/fdfs -v /etc/localtime:/etc/localtime delron/fastdfs storage
网友评论