在master节点上编写/root/wordpress/docker-compose.yaml文件,具体要求如下:
(1)容器名称:wordpress;镜像:wordpress:latest;端口映射:82:80;
(2)容器名称:mysql;镜像:mysql:5.6;
(3)MySQLroot用户密码:123456;
(4)创建数据库wordpress。
完成后编排部署WordPress。
mkdir wordpress
cd wordpress
vi docker-compose.yaml
version: '3'
services:
mysql:
image: mysql:5.6
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: wordpress
wordpress:
depends_on:
- mysql
image: wordpress:latest
ports:
- 82:80
links:
- mysql:mysql
restart: always
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: 123456
WORDPRESS_DB_NAME: wordpress
docker-compose up -d
在master节点上停止并删除上述部署的wordpress容器。
docker-compose ps -a
docker-compose stop
docker-compose ps -a
docker-compose rm -f
docker-compose ps -a
# 总结就是
docker-compose ps -a
docker-compose down
docker-compose ps -a
在master节点上编写/root/owncloud/docker-compose.yaml文件,具体要求如下:
(1)容器名称:owncloud;镜像:owncloud:latest;端口映射:5678:80;
(2)容器名称:mysql;镜像:mysql:5.6;
(3)MySQLroot用户密码:123456;
(4)创建数据库owncloud。
完成后编排部署owncloud。
mkdir owncloud
cd owncloud/
vi docker-compose.yaml
version: '3'
services:
mysql:
image: mysql:5.6
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: ownclouds
owncloud:
depends_on:
- mysql
image: owncloud:latest
restart: always
links:
- mysql:mysql
ports:
- 5678:80
volumes:
- /data/db/owncloud:/var/www/html/data
docker-compose up -d
在master节点上编写/root/redis/Dockerfile文件,基于提供的软件包gpmall-single.tar构建chinaskill-redis:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)修改配置文件中的bind127.0.0.1为bind0.0.0.0;
(4)设置Redis免密,并关闭保护模式;
(5)开放端口:6379;
(6)设置服务开机自启。
完成后构建镜像。
可能需要解压.gz文件
gzip -d gpmall-single.tar.gz
暂时需要上传centos1804镜像并为其配置yum源
vi ftp.repo
[gpmall]
name=gpmall
baseurl=ftp://192.168.200.110/ChinaskillMall/gpmall-repo
enabled=1
gpgcheck=0
[centos]
name=centos
baseurl=ftp://192.168.200.110/centos
enabled=1
gpgcheck=0
[k8s]
name=k8s
baseurl=ftp://192.168.200.110/kubernetes-repo
enabled=1
gpgcheck=0
mkdir redis
cp ftp.repo redis/
cd redis/
vi Dockerfile
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -f /etc/yum.repos.d/*
ADD ftp.repo /etc/yum.repos.d/
RUN yum -y install redis
RUN sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/redis.conf
RUN sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis.conf
EXPOSE 6379
ENTRYPOINT ["/usr/bin/redis-server", "/etc/redis.conf"]
docker build -t chinaskill-redis:v1.1 .
在master节点上编写/root/mariadb/Dockerfile文件,基于提供的软件包gpmall-single.tar构建chinaskill-mariadb:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)设置数据库密码:123456;
(4)创建数据库gpmall并导入数据库文件gpmall.sql;
(5)设置字符编码:UTF-8;
(6)开放端口:3306;
(7)设置服务开机自启。
完成后构建镜像。
mkdir mariadb
cp ftp.repo /opt/ChinaskillMall/gpmall.sql mariadb/
cd mariadb/
vi Dockerfile
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -f /etc/yum.repos.d/*
ADD ftp.repo /etc/yum.repos.d/
ADD gpmall.sql /opt
ENV LC_ALL en_US.UTF-8
RUN yum -y install mariadb mariadb-server
RUN echo -e "[mysqld]\nport = 8066" >> /etc/my.cnf
RUN mysql_install_db --user=mysql && sleep 3 && (mysqld_safe &) && sleep 3 && mysqladmin -uroot password 123456 && mysql -uroot -p123456 -e "grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;create database gpmall;use gpmall;source /opt/gpmall.sql;flush privileges;"
EXPOSE 3306 8066
ENTRYPOINT ["mysqld_safe"]
docker build -t chinaskill-mariadb:v1.1 .
在master节点上编写/root/zookeeper/Dockerfile文件,基于提供的软件包gpmall-single.tar构建chinaskill-zookeeper:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)开放端口:2181;
(4)设置服务开机自启。
完成后构建镜像,使用构建的镜像运行容器myzookeeper。
mkdir zookeeper
cp ftp.repo /opt/ChinaskillMall/zookeeper-3.4.14.tar.gz zookeeper/
cd zookeeper/
vi Dockerfile
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -f /etc/yum.repos.d/*
ADD ftp.repo /etc/yum.repos.d/
ADD zookeeper-3.4.14.tar.gz /opt
RUN yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mv /opt/zookeeper-3.4.14/conf/zoo_sample.cfg /opt/zookeeper-3.4.14/conf/zoo.cfg
EXPOSE 2181
ENTRYPOINT ["/opt/zookeeper-3.4.14/bin/zkServer.sh", "start-foreground"]
docker build -t chinaskill-zookeeper:v1.1 .
在master节点上编写/root/kafka/Dockerfile文件,基于提供的软件包gpmall-single.tar构建chinaskill-kafka:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)开放端口:9092;
(4)设置服务开机自启。
完成后构建镜像。
mkdir kafka
cp ftp.repo /opt/ChinaskillMall/kafka_2.11-1.1.1.tgz kafka/
cd kafka/
vi Dockerfile
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -f /etc/yum.repos.d/*
ADD ftp.repo /etc/yum.repos.d/
ADD kafka_2.11-1.1.1.tgz /opt/kafka
RUN yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN sed -i 's/num.partitions.*$/num.partitions=3/g;s/zookeeper.connect=.*$/zookeeper.connect=zookeeper:2181/g' /opt/kafka/kafka_2.11-1.1.1/config/server.properties
EXPOSE 9092
ENTRYPOINT ["sh", "/opt/kafka/kafka_2.11-1.1.1/bin/kafka-server-start.sh config/server.properties"]
docker build -t chinaskill-kafka:v1.1 .
在master节点上编写/root/nginx/Dockerfile文件,基于提供的软件包gpmall-single.tar构建chinaskill-nginx:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)编写/etc/nginx/conf.d/default.conf文件,配置反向代理,将80端口请求转发到8081、8082和8083;
(4)将dist.tar解压并复制到/usr/share/nginx/html/目录下;
(5)开放端口:80、443、8081、8082、8083;
(6)设置服务开机自启。
mkdir nginx
cp ftp.repo dist.tar /opt/ChinaskillMall/*.jar nginx/
cd nginx/
cp /etc/nginx/conf.d/default.conf .
vi Dockerfile
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -f /etc/yum.repos.d/*
RUN rm -rf /etc/nginx/conf.d/default.conf /usr/share/nginx/html/*
ADD run.sh /root/
ADD ftp.repo /etc/yum.repos.d/
ADD dist.tar /usr/share/nginx/html/
ADD default.conf /etc/nginx/conf.d/default.conf
COPY *.jar /root/
RUN chmod 775 /root/run.sh /usr/share/nginx/html/*
RUN yum -y install nginx java-1.8.0-openjdk java-1.8.0-openjdk-devel
EXPOSE 80 443 8081 8082 8083
ENTRYPOINT ["nginx", "-g", "daemon off;"]
vi run.sh
#!/bin/bash
nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &
sleep 5
vi default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /shopping {
proxy_pass http://127.0.0.1:8081;
}
location /user {
proxy_pass http://127.0.0.1:8082;
}
location /cashier {
proxy_pass http://127.0.0.1:8083;
}
#error_page 404 /404.html;
}
docker build -t chinaskill-nginx:v1.1 .
在master节点上编写/root/chinaskillmall/docker-compose.yaml文件,具体要求如下:
(1)容器1名称:mysql;镜像:chinaskill-mariadb:v1.1;端口映射:3306:3306;
(2)容器2名称:redis;镜像:chinaskill-redis:v1.1;端口映射:6379:6379;
(3)容器3名称:kafka;镜像:chinaskill-kafka:v1.1;端口映射:9092:9092;
(4)容器4名称:zookeeper;镜像:chinaskill-zookeeper:v1.1;端口映射:2181:2181;
(5)容器5名称:nginx;镜像:chinaskill-nginx:v1.1;端口映射:80:80,443:443。
mkdir chinaskillmall
cd chinaskillmall/
vi docker-compose.yaml
version: "3"
services:
mysql.mall:
container_name: mysql
image: chinaskill-mariadb:v1.1
ports:
- "3306:3306"
restart: always
redis.mall:
depends_on:
- mysql.mall
container_name: redis1
image: chinaskill-redis:v1.1
ports:
- "6379:6379"
restart: always
zookeeper.mall:
depends_on:
- mysql.mall
- redis.mall
container_name: zookeeper
image: chinaskill-zookeeper:v1.1
ports:
- "2181:2181"
restart: always
kafka.mall:
links:
- zookeeper.mall
depends_on:
- mysql.mall
- redis.mall
- zookeeper.mall
container_name: kafka
image: chinaskill-kafka:v1.1
ports:
- "9092:9092"
restart: always
mall:
container_name: nginx1
image: chinaskill-nginx:v1.1
links:
- mysql.mall
- redis.mall
- zookeeper.mall
- kafka.mall
depends_on:
- mysql.mall
- redis.mall
- zookeeper.mall
- kafka.mall
ports:
- "88:80"
- "443:443"
privileged: true
command: /root/run.sh
在master节点上使用镜像jenkins/jenkins:2.262-centos部署Jenkins服务,具体要求如下:
(1)容器名称:jenkins;
(2)端口映射:8080:80;
(3)使用root身份生成容器;
(4)离线安装Jenkins插件;
(5)设置Jenkins用户:chinaskill;密码:000000;
(6)配置权限“任何用户可以做任何事(没有任何限制)”。
使用chinaskill用户登录Jenkins。
在master节点上使用镜像gitlab/gitlab-ce:12.9.2-ce.0部署Gitlab服务,具体要求如下:
(1)容器名称:mygitlab;
(2)端口映射:1022:22、81:80、443:443;
(3)重启策略:always;
(4)设置Gitlab用户:root;密码:00000000;
(5)新建项目:ChinaskillProject;
(6)将/opt/ChinaskillProject中的代码上传到ChinaskillProject项目中。
配置Jenkins连接Gitlab,具体要求如下:
(1)设置Outboundrequests;
(2)生成“AccessTokens”;
(3)设置Jenkins取消对'/project'end-point进行身份验证;
(4)测试Jenkins与Gitlab的连通性。
配置Jenkins连接maven,具体要求如下:
(1)采用dockerindocker的方式在Jenkins内安装maven;
(2)在Jenkins中配置maven信息。
配置CI/CD,具体要求如下:
(1)新建一个流水线任务ChinaskillProject;
(2)编写流水线脚本;
(3)配置Webhook;
(4)在Harbor中新建公开项目chinaskillproject。
将ChinaskillProject项目中的代码上传到Gitlab中触发构建。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)