李明
|
注意
微服务部署
docker化
docker pull java:openjdk-8 docker images|grep jdk
docker run -it --entrypoint bash java:openjdk-8 java -version
开始dockerfile的开发
application.properties service.name=user-thrift-service service.port=7911 #数据源的配置 spring.datasource.url=jdbc:mysql://{mysql.address}:3306/db_userspring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.idig8</groupId> <artifactId>user-thrift-service</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.10.0</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>user-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.44</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <e x e cutions> <e x e cution> <goals> <goal>repackage</goal> </goals> </e x e cution> </e x e cutions> </plugin> </plugins> </build> </project>
FROM java:openjdk-8 MAINTAINER liming www.idig8.com COPY target/user-thrift-service-1.0-SNAPSHOT.jar /user-thrift-service.jar ENTRYPOINT ["java","-jar","/user-thrift-service.jar"]
docker build -t user-thrift-service:latest .
ifconfig
docker run -it user-thrift-service:latest --mysql.address=192.168.1.140
#!/usr/bin/env bash mvn package docker build -t user-thrift-service:latest .
docker pull python:3.6 docker images|grep python
FROM python:3.6 MAINTAINER liming www.idig8.com RUN pip install thrift ENV PYTHONPATH / COPY message /message ENTRYPOINT ["python","/message/message_service.py"]
docker build -t message-thrift-python-service:latest .
#!/usr/bin/env bash docker build -t message-thrift-python-service:latest .
docker run -it message-thrift-python-service:latest
application.properties server.name=user-edge-service server.port=8082 thrift.user.ip=user-thrift-service thrift.user.port=7911 thrift.message.ip=message-thrift-python-service thrift.message.port=9090#redis configspring.redis.host=${redis.address} spring.redis.port=6379 spring.redis.password=liming spring.redis.timeout=30000 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.idig8</groupId> <artifactId>user-edge-service</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.10.0</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>user-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>message-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <e x e cutions> <e x e cution> <goals> <goal>repackage</goal> </goals> </e x e cution> </e x e cutions> </plugin> </plugins> </build> </project>
FROM java:openjdk-8 MAINTAINER liming www.idig8.com COPY target/user-edge-service-1.0-SNAPSHOT.jar /user-edge-service.jar ENTRYPOINT ["java","-jar","/user-edge-service.jar"]
#!/usr/bin/env bash mvn package docker build -t user-edge-service:latest .
sh build.sh
docker run -it user-edge-service:latest --redis.address=192.168.1.140
application.properties #dubbo 配置 spring.dubbo.application.name=course-dubbo-service spring.dubbo.registry.address=zookeeper://${zookeeper.address}:2181spring.dubbo.protocol.name=dubbo spring.dubbo.protocol.port=20880 #spring.dubbo.protocol.host=127.0.0.1 spring.dubbo.scan=com.idig8.course #数据源的配置 spring.datasource.url=jdbc:mysql://${mysql.address}:3306/db_coursespring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver thrift.user.ip=user-thrift-service thrift.user.port=7911 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.idig8</groupId> <artifactId>course-dubbo-service</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>io.dubbo.springboot</groupId> <artifactId>spring-boot-starter-dubbo</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.10.0</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.44</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>course-dubbo-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>user-thrift-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>user-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <e x e cutions> <e x e cution> <goals> <goal>repackage</goal> </goals> </e x e cution> </e x e cutions> </plugin> </plugins> </build> </project>
FROM java:openjdk-8 MAINTAINER liming www.idig8.com COPY target/course-dubbo-service-1.0-SNAPSHOT.jar /course-dubbo-service.jar ENTRYPOINT ["java","-jar","/course-dubbo-service.jar"]
#!/usr/bin/env bash mvn package docker build -t course-dubbo-service:latest .sh build.sh
docker run -it course-dubbo-service:latest --redis.address=192.168.1.140 --zookeeper.address=192.168.1.140
docker run -it course-edge-service:latest --zookeeper.address=192.168.1.140 docker run -it gataway-zuul:latest PS:把所有单独的服务,做成了镜像,下次想个办法服务和镜像统一的运行起来。 |
2019-02-03 10:11:04