CumulusClips是一个开源的视频分享(内容管理)平台,能够提供最佳的视频分享功能之一类似YouTube。 在CumulusClips的帮助下,您可以开始自己的视频分享网站或在您现有的网站上添加视频部分,用户可以注册,上传视频,评论视频,评价视频,嵌入视频等等。
一.部署环境
centos7系列系统,已部署docker容器,社区版部署参考官方文档或
https://www.jianshu.com/p/edccebf55184
二.下载相关的镜像images
这里使用的镜像为mysql5.7旧版稳定版本,链接容器命令如下
[root@cobbler ~]# docker run --name cumulusclips-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -e MYSQL_DATABASE=cumulusclipsdb \
> -e MYSQL_USER=cumulusclipsuser -e MYSQL_PASSWORD=cumulusclipsdbpasswd -d mysql:5.7
Unable to find image 'mysql:5.7' locally
5.7: Pulling from library/mysql
27833a3ba0a5: Pull complete
864c283b3c4b: Pull complete
cea281b2278b: Pull complete
8f856c14f5af: Pull complete
9c4f38c23b6f: Pull complete
1b810e1751b3: Pull complete
5479aaef3d30: Pull complete
1d924ec3d520: Pull complete
1ab7ae63ac60: Pull complete
08aa5f3680e9: Pull complete
a832d0a0972a: Pull complete
Digest: sha256:dba5fed182e64064b688ccd22b2f9cad4ee88608c82f8cff21e17bab8da72b81
Status: Downloaded newer image for mysql:5.7
7866342b58740e35d01ba6cb7de0cc2957075b498df5692da4ecb9b108163b7e
[root@cobbler ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 98455b9624a9 2 weeks ago 372MB
hello-world latest fce289e99eb9 3 months ago 1.84kB
[root@cobbler ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7866342b5874 mysql:5.7 "docker-entrypoint.s…" 25 seconds ago Up 23 seconds 3306/tcp, 33060/tcp cumulusclips-mysql
#这里会自动生成一个新的容器为防止和启动脚本冲突停止容器并删除
[root@cobbler ~]# docker stop 7866342b5874
7866342b5874
[root@cobbler ~]# docker rm 7866342b5874
7866342b5874
创建初始化启动脚本拉取最新镜像并进入初始化安装
[root@cobbler ~]# cd /
[root@cobbler /]# mkdir script
[root@cobbler /]# cd script/
[root@cobbler script]# vim cumulusclips_init.sh
docker run --name cumulusclips-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysecretpassword -e MYSQL_DATABASE=cumulusclipsdb \
-e MYSQL_USER=cumulusclipsuser -e MYSQL_PASSWORD=cumulusclipsdbpasswd -d mysql:5.7
docker run -d -p 80:80 --link cumulusclips-mysql:db quantumobject/docker-cumulusclips
[root@cobbler script]# chmod +x /script/cumulusclips_init.sh
[root@cobbler script]# ./cumulusclips_init.sh
0fa0bc4ad745d82b4d2da8f8f8924946e4bcca833d394fc804dd8c71ed4aa430
docker: Error response from daemon: driver failed programming external connectivity on endpoint cumulusclips-mysql (fb210d451788cb781968fd2a783771b3210ab49c9072b228afb14d8b82b13d69): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use.
Unable to find image 'quantumobject/docker-cumulusclips:latest' locally
latest: Pulling from quantumobject/docker-cumulusclips
84ed7d2f608f: Pull complete
be2bf1c4a48d: Pull complete
a5bdc6303093: Pull complete
e9055237d68d: Pull complete
8578d9691ed8: Pull complete
40776e828ac9: Pull complete
5d4b933b2986: Pull complete
a05d11aced8d: Pull complete
a97048fe5b53: Pull complete
9c6ace4bb9d1: Pull complete
d61d80359236: Pull complete
bc7c0dcd17ea: Pull complete
8733f35d998f: Pull complete
f2e28ef11aa2: Pull complete
8896dff6f9db: Pull complete
a40dcf5868ac: Pull complete
299ea5f91975: Pull complete
Digest: sha256:bc44239e15d12a314dd312d1a899621f82f3f1b7e7d77eed101a14674c2c4082
Status: Downloaded newer image for quantumobject/docker-cumulusclips:latest
3e39d36f54b4ec8e82166d3e896139450896649ab38aed063718d34900622a0b
docker: Error response from daemon: driver failed programming external connectivity on endpoint pensive_noether (567d87ece9d8662718519a28a3b00df316d395aa86053d27d07b5e596e56f064): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use.
正常会启动2个容器如下
[root@cobbler script]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3e39d36f54b4 quantumobject/docker-cumulusclips "/sbin/my_init" 18 seconds ago Created pensive_noether
0fa0bc4ad745 mysql:5.7 "docker-entrypoint.s…" 57 seconds ago Created cumulusclips-mysql
故障排除:根据提示这里容器都已经创建但是无法运行,手动启动容器报错如下
[root@cobbler script]# docker start 0fa0bc4ad745
Error response from daemon: driver failed programming external connectivity on endpoint cumulusclips-mysql (de4954d6c492bc8ea11313a64b1244fd09470bf17d3913df92670770a26717ab): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use
Error: failed to start containers: 0fa0bc4ad745
[root@cobbler script]# docker start 3e39d36f54b4
Error response from daemon: driver failed programming external connectivity on endpoint pensive_noether (b5c9eac41edeb75c6c7953a4f43a8685b7e73408bdd18bd0f2462726fbe8d74a): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
Error: failed to start containers: 3e39d36f54b4
结论:服务器上http的80端口以及mysql的3306端口都已经被占用因此无法运行
解决方案:删除容器并修改初始化脚本文件将端口顺延1位,81以及3307
新配置文件如下
[root@cobbler script]# vim cumulusclips_init.sh
docker run --name cumulusclips-mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=mysecretpassword -e MYSQL_DATABASE=cumulusclipsdb \
-e MYSQL_USER=cumulusclipsuser -e MYSQL_PASSWORD=cumulusclipsdbpasswd -d mysql:5.7
docker run -d -p 81:80 --link cumulusclips-mysql:db quantumobject/docker-cumulusclips
修改完成直接启动脚本
[root@cobbler script]# ./cumulusclips_init.sh
91a00a5a54baab44c20cfb8017d9e4b981ed26a05e496b0cd57682d9b4b30763
5da88e6aadcff4c52da5b06a895bca61346d8820ee9b00d05a470316bb224f25
[root@cobbler script]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5da88e6aadcf quantumobject/docker-cumulusclips "/sbin/my_init" 14 seconds ago Up 10 seconds 0.0.0.0:81->80/tcp epic_murdock
91a00a5a54ba mysql:5.7 "docker-entrypoint.s…" 15 seconds ago Up 13 seconds 33060/tcp, 0.0.0.0:3307->3306/tcp cumulusclips-mysql
附件docker脚本
version: '2'
volumes:
cumulusclips:
db:
services:
db:
image: mariadb
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_PASSWORD=cumulusclipsdbpasswd
- MYSQL_DATABASE=cumulusclipsdb
- MYSQL_USER=cumulusclipsuser
app:
image: quantumobject/docker-cumulusclips
links:
- db
ports:
- 80:80
volumes:
- cumulusclips:/var/www/html
restart: always
三.访问页面 http://192.168.28.150:81
进行初始化安装
点击继续配置相关数据库信息
相关信息如下
DataBase Host: db
DataBase Port: 3306
DataBase Name: cumulusclipsdb
DataBase User: cumulusclipsuser
DataBase Password: cumulusclipsdbpasswd
TablePrefix : tb_
配置平台管理员相关信息
至此视频分享平台搭建完成
备注:
1.上传视频后网站需要时间进行转码
2.如果关机或者服务停止情况下,重启两个容器即可,重启数据库容器
参考文章:
https://blog.csdn.net/Aria_Miazzy/article/details/85028663
服务器意外关机后重启容器
首先需要查看容器ID
[root@cobbler ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5da88e6aadcf quantumobject/docker-cumulusclips "/sbin/my_init" 4 weeks ago Exited (0) 14 seconds ago epic_murdock
91a00a5a54ba mysql:5.7 "docker-entrypoint.s…" 4 weeks ago Exited (0) 4 seconds ago cumulusclips-mysql
正常情况直接启动相应容器即可,但是因为意外关机造成iptales服务没有开机自启动,无法进行端口转发,报错信息如下
[root@cobbler ~]# docker start 91a00a5a54ba
Error response from daemon: driver failed programming external connectivity on endpoint cumulusclips-mysql (3c2c957defc1563a8768e897b53de468d754b62ad63a96e5184ceae395c9a023): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3307 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))
Error: failed to start containers: 91a00a5a54ba
手动启动iptables服务后启动容器仍然是同样的报错信息
光看这个报错: iptables: No chain/target/match by that name,就能够看出是跟iptables有关
原因猜测:如果再启动docker service的时候网关是关闭的,那么docker管理网络的时候就不会操作网管的配置(chain docker),然后网关重新启动了,导致docker network无法对新container进行网络配置,也就是没有网管的操作权限,做重启处理
解决办法:
先启动iptables服务组件
然后重启docker服务
最后启动容器成功
[root@cobbler ~]# systemctl start iptables
[root@cobbler ~]# systemctl restart docker
[root@cobbler ~]# docker start 91a00a5a54ba
91a00a5a54ba
备注:由于docker容器需要使用iptables服务进行端口转发,因此对于内网的文件服务器samba服务造成影响,因此需要开放服务对应的端口:137,138,139以及445
参考文章:https://www.cnblogs.com/kreo/p/4368811.html
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables
#安装iptables-services
yum install iptables-services
#查看iptables现有规则
iptables -L -n
#清空所有自定义规则
iptables -X
#清空所有默认规则
iptables -F
[root@cobbler ~]# iptables -X
[root@cobbler ~]# iptables -F
[root@cobbler ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#开放137,138,139以及445端口
[root@cobbler ~]# iptables -A INPUT -p tcp --dport 137 -j ACCEPT
[root@cobbler ~]# iptables -A INPUT -p tcp --dport 138 -j ACCEPT
[root@cobbler ~]# iptables -A INPUT -p tcp --dport 139 -j ACCEPT
[root@cobbler ~]# iptables -A INPUT -p tcp --dport 445 -j ACCEPT
#保存规则
[root@cobbler ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@cobbler ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:137
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:138
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:139
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:445
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#重启防火墙并加入开机自启动
[root@cobbler ~]# systemctl restart iptables
[root@cobbler ~]# systemctl enable iptables