https://github.com/zq2599/blog_demos
内容:所有原创文章分类汇总及配套源码,涉及Java、Docker、Kubernetes、DevOPS等;
接下来开始体验吧;
systemctl stop firewalld && systemctl disable firewalld
yum install -y wget yum-utils device-mapper-persistent-data lvm2 \ && yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo \ && yum install -y docker-ce docker-ce-cli containerd.io \ && systemctl start docker
[root@centos7 ~]# docker version Client: Docker Engine - Community Version: 20.10.2 API version: 1.41 Go version: go1.13.15 Git commit: 2291f61 Built: Mon Dec 28 16:17:48 2020 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.2 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8891c58 Built: Mon Dec 28 16:16:13 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.3 GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b runc: Version: 1.0.0-rc92 GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff docker-init: Version: 0.19.0 GitCommit: de40ad0
mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://registry.docker-cn.com"] } EOF systemctl daemon-reload systemctl restart docker
环境准备完成,接下来安装KMS;
docker run -d \ --name kms \ --network host \ kurento/kurento-media-server:6.15
[root@centos7 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4265203b2baa kurento/kurento-media-server:6.15 "/entrypoint.sh" 3 minutes ago Up 3 minutes (healthy) kms
curl -i -N \ -H "Connection: Upgrade" \ -H "Upgrade: websocket" \ -H "Host: 127.0.0.1:8888" \ -H "Origin: 127.0.0.1" \ http://127.0.0.1:8888/kurento
HTTP/1.1 500 Internal Server Error Server: WebSocket++/0.7.0
mkdir -p /usr/lib/jvm tar -C /usr/lib/jvm/ -xzf jdk-8u191-linux-x64.tar.gz
echo 'export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_191' >> ~/.bashrc echo 'export JRE_HOME=${JAVA_HOME}/jre' >> ~/.bashrc echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >> ~/.bashrc echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> ~/.bashrc source ~/.bashrc
[root@centos7 ~]# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz tar -C /usr/local/ -xzf apache-maven-3.6.3-bin.tar.gz echo 'export MAVEN_HOME=/usr/local/apache-maven-3.6.3' >> ~/.bashrc echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> ~/.bashrc source ~/.bashrc
[root@centos7 ~]# mvn -version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /usr/local/apache-maven-3.6.3 Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk1.8.0_191/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-1160.11.1.el7.x86_64", arch: "amd64", family: "unix"
<mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
wget https://github.com/Kurento/kurento-tutorial-java/archive/6.15.0.tar.gz tar -xzf 6.15.0.tar.gz
[root@centos7 ~]# tree -L 1 kurento-tutorial-java-6.15.0/ kurento-tutorial-java-6.15.0/ ├── kurento-chroma ├── kurento-crowddetector ├── kurento-group-call ├── kurento-hello-world ├── kurento-hello-world-recording ├── kurento-hello-world-repository ├── kurento-magic-mirror ├── kurento-metadata-example ├── kurento-one2many-call ├── kurento-one2one-call ├── kurento-one2one-call-advanced ├── kurento-one2one-call-recording ├── kurento-platedetector ├── kurento-player ├── kurento-pointerdetector ├── kurento-rtp-receiver ├── kurento-send-data-channel ├── kurento-show-data-channel ├── LICENSE ├── NOTICE ├── pom.xml └── README.md 18 directories, 4 files
4. 上面就是一个最基本的demo所涉及的数据流向,当然了,每个demo都有其特殊性,例如直播的demo是多个浏览器连接到KMS,不过整体上与上面的流程图类似;
nohup mvn -U clean spring-boot:run \ -Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \ >> ~/kurento-hello-world.log \ 2>&1 &
... Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/jcraft/jsch.agentproxy.jsch/0.0.9/jsch.agentproxy.jsch-0.0.9.jar (0 B at 0 B/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar (0 B at 0 B/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/wagon/wagon-ssh-common/3.3.2/wagon-ssh-common-3.3.2.jar Progress (1): 1.9 kB ...
[INFO] --- spring-boot-maven-plugin:2.2.4.RELEASE:run (default-cli) @ kurento-hello-world --- [INFO] Attaching agents: [] .------------------------------------. | | | | |/ / _ _ _ ___ _ _| |_ ___ | | | ' < || | '_/ -_) ' \ _/ _ \ | | |_|\_\_,_|_| \___|_||_\__\___/ | | | '------------------------------------' Kurento Java Tutorial - Hello World Version 6.15.0 2021-01-09 15:56:15.348 WARN 35812 --- [ main] o.s.boot.StartupInfoLogger : InetAddress.getLocalHost().getHostName() took 10012 milliseconds to respond. Please verify your network configuration. 2021-01-09 15:56:25.366 INFO 35812 --- [ main] o.k.tutorial.helloworld.Application : Starting Application on centos7 with PID 35812 (/root/kurento-tutorial-java-6.15.0/kurento-hello-world/target/classes started by root in /root/kurento-tutorial-java-6.15.0/kurento-hello-world) 2021-01-09 15:56:25.367 INFO 35812 --- [ main] o.k.tutorial.helloworld.Application : No active profile set, falling back to default profiles: default 2021-01-09 15:56:25.984 INFO 35812 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket : [KurentoClient] Connecting native client 2021-01-09 15:56:25.985 INFO 35812 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket : [KurentoClient] Creating new NioEventLoopGroup 2021-01-09 15:56:41.079 INFO 35812 --- [ntLoopGroup-2-1] o.k.j.c.JsonRpcClientNettyWebSocket : [KurentoClient] Initiating new Netty channel. Will create new handler too! 2021-01-09 15:56:41.140 WARN 35812 --- [ main] org.kurento.client.KurentoClient : Connected to KMS in 15142 millis (> 5000 millis) 2021-01-09 15:56:41.704 INFO 35812 --- [ main] o.k.tutorial.helloworld.Application : Started Application in 51.601 seconds (JVM running for 51.817)
4. 执行以下命令即可启动demo应用,并且将控制台信息转存到~/kurento-magic-mirror.log:
nohup mvn -U clean spring-boot:run \ -Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \ >> ~/kurento-magic-mirror.log \ 2>&1 &
微信搜索「程序员欣宸」,我是欣宸,期待与您一同畅游Java世界...
https://github.com/zq2599/blog_demos