├── .gitattributes ├── .gitignore ├── README.md ├── condor.sh ├── ftp.sh ├── install_xrender_all.sh ├── install_xrender_all_test.sh ├── msp.sh ├── mysql.sh ├── platform.sh ├── portal.sh ├── python.sh ├── rabbitmq.sh └── redis.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qct/docker-all-in-one-render-platform/61fd9f095e9aa42674ae9d8ce861c2017fce72e9/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### [Docker](https://www.docker.com/) all in one environment of render platform 2 | 3 | ## Introduction 4 | 首先介绍一下**分布式渲染** ,核心有一下几点: 5 | * 并行渲染,调度系统会分发job到每个可用的节点机,每个job就是一帧,同一个节点机同一时间只执行一个job。这里的可以不但指节点确实存在,还指他被加进了当前渲染所用的节点池。 6 | * 文件去重,上传过的文件不会被再次上传,当你提交一个任务,上传文件之前会进行去重处理,在服务器上已经存在的文件不会再次上传。 7 | * 自动回传&手动下载,渲染完毕之后会自动回传到本地(前提是你有我们的客户端^_^)或者也可以通过手动下载渲染结果。 8 | 9 | #### 这里有什么 10 | 这是一个基于分布式渲染生产环境的all-in-one环境,把所有的组件都做成了docker容器,使得部署变得非常容易,原来部署一套环境需要2个人工作几天才能调通,现在只需要一条命令就可以实现。 11 | #### 适用于谁 12 | * 适用于小型的渲染农场或者工作室,他们可以通过自己内部的机器搭建小型的云渲染环境。 13 | * 适用于喜欢折腾的Geek,当然,Geek什么都可以玩,包括这个。 14 | 15 | ## Environment 16 | * 一台配置比较高的机器,linux系统,最好是[CentOS 7](https://www.centos.org/download/),我们搭建生产环境用的是 10台左右的 物理机+虚拟机,所以机器配置最好比较高。 17 | * 一台一般的windows机器,系统我们生产用的是Windows 2012。别的版本其实我觉得都还OK。 18 | 19 | ## Pre-install 20 | 环境搭建之前,需要先下载我已经做好的docker image,这个比较大,一共有9个组件,压缩之后3.57G,我已经传到网盘上了。这里面都是docker save出来的image。 21 | 22 | 网盘链接: [http://pan.baidu.com/s/1ntF69M5](http://pan.baidu.com/s/1ntF69M5) 密码: q5nm 23 | 24 | ## Server Install 25 | 镜像下载完之后在linux机器上解压,里面也包括了这些shell,进入主目录执行执行下面命令,会把这9大组件通过docker方式都安装并启动容器。 26 | ```bash 27 | docker rm -f $(docker ps -a|awk '{print $1}'|grep -v 'CONTAINER') ; sh -x install_xrender_all.sh `pwd` 28 | ``` 29 | ## Render Node Install 30 | 未完待续。。。 31 | ## About 32 | 33 | 我们是2个人的团队,docker以及系统调试是我弄的,安装shell是 @oiovoyo 写的。 34 | -------------------------------------------------------------------------------- /condor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ip_from="10.22.200.18" 3 | ip_to=$1 4 | 5 | files=" 6 | /etc/condor_api.conf 7 | /var/www/htcondorAPI/configure.php 8 | /home/work/pyCreateThumbNail.py 9 | /home/work/pymaxCMDrender.py 10 | /home/work/maya/pymayaSceneParser.py 11 | /home/work/maya/pymayaCMDrender.py 12 | /home/work/pyTileAssembly.py 13 | /home/work/nuke/pyNukeThumbNail.py 14 | /home/work/pymayaCMDrender.py 15 | /home/work/convert/pyConvertStream.py 16 | /home/work/convert/pyGetMediaInfo.py 17 | /home/work/convert/pyJoinStream.py 18 | /home/work/pyPhotonTileAssembly.py 19 | /home/work/pymaxSceneParser.py 20 | /home/work/pymaxImgs2Mov.py 21 | /home/work/pymaxCMDrender_test.py 22 | " 23 | 24 | for file in $files ; do 25 | sed -i "s/$ip_from/$ip_to/g" $file 26 | sed -i "s/localhost/127.0.0.1/g" $file 27 | done 28 | service apache2 restart 29 | kill -9 $(pidof condor_api_daemon) 30 | /usr/sbin/condor_api_daemon -d 31 | find /etc/condor/ -type f -exec sed -i "s/$ip_from/$ip_to/g" {} \; 32 | service condor restart 33 | exit 0 34 | -------------------------------------------------------------------------------- /ftp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ip=$1 3 | file=/home/ftp1/scripts/condor_base.py 4 | 5 | docker_host_ip_old=10.22.200.18 6 | docker_host_ip_new=$ip 7 | sed_strings=" 8 | $docker_host_ip_old##${docker_host_ip_new} 9 | " 10 | 11 | for sed_item in $sed_strings ; do 12 | sed_from=`echo $sed_item | awk -F'##' '{print $1}'` 13 | sed_to=`echo $sed_item | awk -F'##' '{print $2}'` 14 | sed -i "s/$sed_from/$sed_to/g" $file 15 | done 16 | 17 | exit 0 -------------------------------------------------------------------------------- /install_xrender_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # xrender All-In-One Installer 3 | # Usage: sh install_xrender_all.sh base_dir 4 | #DEBUG='y' 5 | 6 | # if command failed then exit 7 | # set -e 8 | 9 | 10 | XRENDE_INSTALL_ROOT=${XRENDE_INSTALL_ROOT:-"/usr/local/XRENDE"} 11 | 12 | CENTOS6='CENTOS6' 13 | CENTOS7='CENTOS7' 14 | UBUNTU1404='UBUNTU14.04' 15 | SUPPORTED_OS="$CENTOS6, $CENTOS7, $UBUNTU1404" 16 | XRENDE_INSTALL_LOG='/tmp/XRENDE_installation.log' 17 | OS="" 18 | STEP="1" 19 | 20 | [ -f $XRENDE_INSTALL_LOG ] && /bin/rm -f $XRENDE_INSTALL_LOG 21 | INSTALLATION_FAILURE=/tmp/XRENDE_installation_failure_exit_code 22 | [ -f $INSTALLATION_FAILURE ] && /bin/rm -f $INSTALLATION_FAILURE 23 | 24 | BASE_DIR=`dirname $0` 25 | 26 | [ ! -d $BASE_DIR ] && ( echo $BASE_DIR not exsist ; exit) 27 | 28 | cd $BASE_DIR 29 | IP=$1 30 | DOCKER_DATA_BASE="/usr/local/xrender/data/" 31 | DOCKER_SH_BASE="/usr/local/xrender/sh/" 32 | 33 | # The params is failed reason 34 | fail(){ 35 | #tput cub 6 36 | #echo -e "$(tput setaf 1) FAIL\n$(tput sgr0)"|tee -a $XRENDE_INSTALL_LOG 37 | #echo -e "$(tput setaf 1) Reason: $*\n$(tput sgr0)"|tee -a $XRENDE_INSTALL_LOG 38 | echo "$* \n\nThe detailed installation log could be found in $XRENDE_INSTALL_LOG " | tee -a $INSTALLATION_FAILURE 39 | exit 1 40 | } 41 | 42 | 43 | LOG() 44 | { 45 | echo -e '\n' >> $XRENDE_INSTALL_LOG 46 | echo $1 >> $XRENDE_INSTALL_LOG 47 | } 48 | 49 | 50 | echo_title(){ 51 | echo -e "\n================">> $XRENDE_INSTALL_LOG 52 | echo ""|tee -a $XRENDE_INSTALL_LOG 53 | echo -n -e " ${STEP}. $*:\n" |tee -a $XRENDE_INSTALL_LOG 54 | STEP=`expr $STEP + 1` 55 | } 56 | 57 | echo_subtitle(){ 58 | echo -e "\n----------------" >> $XRENDE_INSTALL_LOG 59 | echo -n -e " $*:\n"|tee -a $XRENDE_INSTALL_LOG 60 | } 61 | 62 | 63 | #Do preinstallation checking for CentOS and Ubuntu 64 | check_system(){ 65 | echo_title "Check System" 66 | echo "" 67 | cat /etc/*-release |egrep -i -h "centos |Red Hat Enterprise" >>$XRENDE_INSTALL_LOG 2>&1 68 | if [ $? -eq 0 ]; then 69 | grep 'release 6' /etc/system-release >>$XRENDE_INSTALL_LOG 2>&1 70 | if [ $? -eq 0 ]; then 71 | OS=$CENTOS6 72 | else 73 | grep 'release 7' /etc/system-release >>$XRENDE_INSTALL_LOG 2>&1 74 | if [ $? -eq 0 ]; then 75 | OS=$CENTOS7 76 | rpm -q libvirt |grep 1.1.1-29 >/dev/null 2>&1 77 | if [ $? -eq 0 ]; then 78 | fail "Your OS is old CentOS7, as its libvirt is `rpm -q libvirt`. You need to use \`yum upgrade\` to upgrade your system to latest CentOS7." 79 | fi 80 | else 81 | fail "Host OS checking failure: your system is: `cat /etc/system-release`, we can only support $SUPPORTED_OS currently" 82 | fi 83 | fi 84 | which unzip >/dev/null 2>&1 85 | if [ $? -ne 0 ];then 86 | yum install -y unzip >>$XRENDE_INSTALL_LOG 2>&1 87 | fi 88 | else 89 | grep 'Ubuntu 14.04' /etc/issue >>$XRENDE_INSTALL_LOG 2>&1 90 | if [ $? -eq 0 ]; then 91 | OS=$UBUNTU1404 92 | else 93 | fail "Host OS checking failure: your system is: `cat /etc/issue`, we can only support $SUPPORTED_OS currently" 94 | fi 95 | which unzip >/dev/null 2>&1 96 | if [ $? -ne 0 ];then 97 | apt-get install unzip >>$XRENDE_INSTALL_LOG 2>&1 98 | fi 99 | fi 100 | 101 | LOG "Your system is: $OS" 102 | } 103 | 104 | install_package() 105 | { 106 | echo_subtitle "install_package $1" 107 | package=$1 108 | whereis $package > /dev/null 2>&1 109 | [ "$?" = "0" ] && ( LOG "package $package is installed";return ) 110 | if [ "$OS" = "$UBUNTU1404" ] ; then 111 | apt-get install -y $package 112 | else 113 | yum install -y $package 114 | fi 115 | } 116 | 117 | # install docker 118 | install_docker() 119 | { 120 | echo_title "install_docker $@" 121 | install_package docker 122 | service docker start 123 | } 124 | 125 | # data dir will be mounted to docker as application data 126 | install_data() 127 | { 128 | echo_title "install_data" 129 | data_path=$BASE_DIR/data.tgz 130 | [ ! -f $data_path ] && (fail "$data_path not exist") 131 | 132 | mkdir -p $DOCKER_DATA_BASE 133 | tar -xzvf $data_path -C $DOCKER_DATA_BASE > /dev/null 2>&1 134 | chmod -R 777 $DOCKER_DATA_BASE > /dev/null 2>&1 135 | } 136 | 137 | # sh dir will be mounted to docker and execute for change configure 138 | install_sh() 139 | { 140 | echo_title "install_sh" 141 | sh_path=$BASE_DIR/sh.tgz 142 | tar -czvf $sh_path *.sh *.sql > /dev/null 2>&1 143 | [ ! -f $sh_path ] && (fail "$sh_path not exist") 144 | 145 | mkdir -p $DOCKER_SH_BASE 146 | tar -xzvf $sh_path -C $DOCKER_SH_BASE > /dev/null 2>&1 147 | chmod -R 777 $DOCKER_SH_BASE > /dev/null 2>&1 148 | } 149 | 150 | 151 | 152 | # image path 153 | declare -A docker_image_path=() 154 | docker_image_path["portal"]=$BASE_DIR/portal.tar 155 | docker_image_path["rabbitmq"]=$BASE_DIR/rabbitmq.tar 156 | docker_image_path["condor"]=$BASE_DIR/condor.tar 157 | docker_image_path["platform"]=$BASE_DIR/test-platform.tar 158 | docker_image_path["msp"]=$BASE_DIR/test-msp.tar 159 | docker_image_path["python"]=$BASE_DIR/python.tar 160 | docker_image_path["redis"]=$BASE_DIR/redis.tar 161 | docker_image_path["ftp"]=$BASE_DIR/ftp.tar 162 | docker_image_path["mysql"]=$BASE_DIR/mysql.tar 163 | 164 | 165 | # tag 166 | declare -A docker_image_tag=() 167 | docker_image_tag["portal"]="registry.local:5000/xrender-ax-test/portal" 168 | docker_image_tag["rabbitmq"]="registry.local:5000/xrender-ax-test/rabbitmq" 169 | docker_image_tag["condor"]="registry.local:5000/xrender-ax-test/condor" 170 | docker_image_tag["platform"]="registry.local:5000/xrender-ax-test/test-platform" 171 | docker_image_tag["msp"]="registry.local:5000/xrender-ax-test/test-msp" 172 | docker_image_tag["python"]="registry.local:5000/xrender-ax-test/python" 173 | docker_image_tag["redis"]="registry.local:5000/xrender-ax-test/redis" 174 | docker_image_tag["ftp"]="registry.local:5000/xrender-ax-test/ftp" 175 | docker_image_tag["mysql"]="registry.local:5000/xrender-ax-test/mysql" 176 | 177 | # docker port to be used 178 | declare -A docker_image_port=() 179 | docker_image_port["portal"]="80" 180 | docker_image_port["rabbitmq"]="5672 15672" 181 | docker_image_port["condor"]="9618 8888" 182 | docker_image_port["platform"]="28080" 183 | docker_image_port["msp"]="38080" 184 | docker_image_port["python"]="5001" 185 | docker_image_port["redis"]="6379" 186 | docker_image_port["ftp"]="21 2002" 187 | docker_image_port["mysql"]="3306" 188 | 189 | # all docker image mount this dir for execute sh after docker image run 190 | DOCKER_SH_MOUNT=" -v $DOCKER_SH_BASE:$DOCKER_SH_BASE " 191 | 192 | # all docker run command 193 | declare -A docker_image_run_command=() 194 | docker_image_run_command["portal"]="docker run -itd --name xrender_nginx --net=host --privileged -v $DOCKER_DATA_BASE/portal:/root/nginx/portal $DOCKER_SH_MOUNT ${docker_image_tag[portal]}" 195 | docker_image_run_command["rabbitmq"]="docker run -d --name xrender_rabbitmq --net=host --privileged -e RABBITMQ_USERNAME=xrender -e RABBITMQ_PASSWORD=xrender $DOCKER_SH_MOUNT ${docker_image_tag[rabbitmq]}" 196 | docker_image_run_command["condor"]="docker run -itd --name xrender_condor --net=host --privileged $DOCKER_SH_MOUNT ${docker_image_tag[condor]}" 197 | docker_image_run_command["platform"]="docker run -itd --privileged --name xrender_platform --net=host $DOCKER_SH_MOUNT ${docker_image_tag[platform]}" 198 | docker_image_run_command["msp"]="docker run -itd --name xrender_msp --net=host --privileged $DOCKER_SH_MOUNT ${docker_image_tag[msp]}" 199 | docker_image_run_command["python"]="docker run -itd --net=host --privileged --name xrender_python -e LANG=C.UTF-8 $DOCKER_SH_MOUNT ${docker_image_tag[python]}" 200 | docker_image_run_command["redis"]="docker run --name xrender_redis -d --restart=always --net=host --privileged $DOCKER_SH_MOUNT ${docker_image_tag[redis]}" 201 | docker_image_run_command["ftp"]="docker run -itd --net=host --privileged --name xrender_ftp -v $DOCKER_DATA_BASE/ftp:/home/ftp1 $DOCKER_SH_MOUNT ${docker_image_tag[ftp]}" 202 | docker_image_run_command["mysql"]="docker run -itd --net=host --privileged --name xrender_mysql $DOCKER_SH_MOUNT ${docker_image_tag[mysql]}" 203 | 204 | 205 | check_port() 206 | { 207 | echo_subtitle "check_port $@" 208 | type=$1 209 | ports=${docker_image_port[$type]} 210 | sleep 10 211 | for port in $ports ; do 212 | result=`netstat -anp | grep ':'$port | awk '{if($6=="LISTEN") print $4}'` 213 | [ -z $result ] && (fail "can not find listen $port ") 214 | done 215 | return 0 216 | } 217 | 218 | 219 | docker_load_image() 220 | { 221 | echo_subtitle "docker_load_image $@" 222 | tag=$1 223 | image_path=${docker_image_path[$tag]} 224 | [ ! -f $image_path ] && (fail "$image_path not exist") 225 | image_tag=${docker_image_tag[$tag]} 226 | result=`docker images | grep "$image_tag" | awk '{print $1}'` 227 | [ ! -z "$result" ] && ( LOG "$tag image exist , do not load" ; return 0 ) 228 | docker load -i $image_path 229 | } 230 | 231 | docker_run_image() 232 | { 233 | echo_subtitle "docker_run_image $@" 234 | tag=$1 235 | run_command=${docker_image_run_command[$tag]} 236 | LOG $run_command 237 | $run_command 238 | } 239 | 240 | modify_docker() 241 | { 242 | sleep 10 243 | echo_subtitle "modify_docker $@" 244 | ip=$1 245 | type=$2 246 | id=$(docker ps -a |grep $type|awk '{print $1}'|head -n 1) 247 | [ -z $id ] && (fail "can not find $type running docker") 248 | docker exec -it $id bash $DOCKER_SH_BASE/$type.sh $ip 249 | } 250 | 251 | docker_load_run() 252 | { 253 | echo_title "docker_load_run $@" 254 | type="$1" 255 | docker_load_image $type 256 | docker_run_image $type 257 | } 258 | 259 | 260 | get_host_ip() 261 | { 262 | [ -n $IP ] && ( echo $IP ; exit ) 263 | eth=`route -n | awk '{if($1=="0.0.0.0" || $1=="default") print $8 }' | head -n 1` 264 | [ -z $eth ] && (fail "can not find default gatway") 265 | ip=`ifconfig $eth | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'` 266 | [ -z $ip ] && ip=`ifconfig $eth | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` 267 | [ -z $ip ] && (fail "can not find ip") 268 | echo $ip 269 | } 270 | 271 | 272 | install_common() 273 | { 274 | host_ip=`get_host_ip` 275 | docker_tag=$1 276 | docker_load_run $docker_tag 277 | [ "$?" != "0" ] && ( fail "docker_load_run $docker_tag failed" ) 278 | modify_docker $host_ip $docker_tag 279 | [ "$?" != "0" ] && ( fail "modify_docker $host_ip $docker_tag failed" ) 280 | check_port $docker_tag 281 | [ "$?" != "0" ] && ( fail "check_port $docker_tag failed" ) 282 | } 283 | 284 | usage() 285 | { 286 | if [ "$#" != "0" -a "$#" != "1" ] ; then 287 | echo "usage: $0 " 288 | echo " IP_ADDRESS is an option" 289 | exit 1 290 | fi 291 | } 292 | 293 | main() 294 | { 295 | usage $* 296 | # check linux releas type 297 | check_system 298 | 299 | # install latest docker 300 | install_docker 301 | 302 | # unzip data file 303 | install_data 304 | 305 | # unzip sh file 306 | install_sh 307 | 308 | # all docker types 309 | all_tag=" 310 | mysql 311 | redis 312 | ftp 313 | portal 314 | rabbitmq 315 | python 316 | condor 317 | platform 318 | msp 319 | " 320 | 321 | for tag in $all_tag ; do 322 | # install docker image & run docker image & modify all configures 323 | install_common $tag 324 | done 325 | } 326 | 327 | main 328 | -------------------------------------------------------------------------------- /install_xrender_all_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # xrender All-In-One Installer 3 | # Usage: sh install_xrender_all.sh base_dir 4 | #DEBUG='y' 5 | 6 | # if command failed then exit 7 | # set -e 8 | 9 | 10 | XRENDE_INSTALL_ROOT=${XRENDE_INSTALL_ROOT:-"/usr/local/XRENDE"} 11 | 12 | CENTOS6='CENTOS6' 13 | CENTOS7='CENTOS7' 14 | UBUNTU1404='UBUNTU14.04' 15 | SUPPORTED_OS="$CENTOS6, $CENTOS7, $UBUNTU1404" 16 | XRENDE_INSTALL_LOG='/tmp/XRENDE_installation.log' 17 | OS="" 18 | STEP="1" 19 | 20 | [ -f $XRENDE_INSTALL_LOG ] && /bin/rm -f $XRENDE_INSTALL_LOG 21 | INSTALLATION_FAILURE=/tmp/XRENDE_installation_failure_exit_code 22 | [ -f $INSTALLATION_FAILURE ] && /bin/rm -f $INSTALLATION_FAILURE 23 | 24 | BASE_DIR=$1 25 | 26 | [ ! -d $BASE_DIR ] && ( echo $BASE_DIR not exsist ; exit) 27 | 28 | DOCKER_DATA_BASE="/usr/local/xrender/data/" 29 | DOCKER_SH_BASE="/usr/local/xrender/sh/" 30 | 31 | # The params is failed reason 32 | fail(){ 33 | #tput cub 6 34 | #echo -e "$(tput setaf 1) FAIL\n$(tput sgr0)"|tee -a $XRENDE_INSTALL_LOG 35 | #echo -e "$(tput setaf 1) Reason: $*\n$(tput sgr0)"|tee -a $XRENDE_INSTALL_LOG 36 | echo "$* \n\nThe detailed installation log could be found in $XRENDE_INSTALL_LOG " | tee -a $INSTALLATION_FAILURE 37 | exit 1 38 | } 39 | 40 | 41 | LOG() 42 | { 43 | echo -e '\n' >> $XRENDE_INSTALL_LOG 44 | echo $1 >> $XRENDE_INSTALL_LOG 45 | } 46 | 47 | 48 | echo_title(){ 49 | echo -e "\n================">> $XRENDE_INSTALL_LOG 50 | echo ""|tee -a $XRENDE_INSTALL_LOG 51 | echo -n -e " ${STEP}. $*:\n" |tee -a $XRENDE_INSTALL_LOG 52 | STEP=`expr $STEP + 1` 53 | } 54 | 55 | echo_subtitle(){ 56 | echo -e "\n----------------" >> $XRENDE_INSTALL_LOG 57 | echo -n -e " $*:\n"|tee -a $XRENDE_INSTALL_LOG 58 | } 59 | 60 | 61 | #Do preinstallation checking for CentOS and Ubuntu 62 | check_system(){ 63 | echo_title "Check System" 64 | echo "" 65 | cat /etc/*-release |egrep -i -h "centos |Red Hat Enterprise" >>$XRENDE_INSTALL_LOG 2>&1 66 | if [ $? -eq 0 ]; then 67 | grep 'release 6' /etc/system-release >>$XRENDE_INSTALL_LOG 2>&1 68 | if [ $? -eq 0 ]; then 69 | OS=$CENTOS6 70 | else 71 | grep 'release 7' /etc/system-release >>$XRENDE_INSTALL_LOG 2>&1 72 | if [ $? -eq 0 ]; then 73 | OS=$CENTOS7 74 | rpm -q libvirt |grep 1.1.1-29 >/dev/null 2>&1 75 | if [ $? -eq 0 ]; then 76 | fail "Your OS is old CentOS7, as its libvirt is `rpm -q libvirt`. You need to use \`yum upgrade\` to upgrade your system to latest CentOS7." 77 | fi 78 | else 79 | fail "Host OS checking failure: your system is: `cat /etc/system-release`, we can only support $SUPPORTED_OS currently" 80 | fi 81 | fi 82 | which unzip >/dev/null 2>&1 83 | if [ $? -ne 0 ];then 84 | yum install -y unzip >>$XRENDE_INSTALL_LOG 2>&1 85 | fi 86 | else 87 | grep 'Ubuntu 14.04' /etc/issue >>$XRENDE_INSTALL_LOG 2>&1 88 | if [ $? -eq 0 ]; then 89 | OS=$UBUNTU1404 90 | else 91 | fail "Host OS checking failure: your system is: `cat /etc/issue`, we can only support $SUPPORTED_OS currently" 92 | fi 93 | which unzip >/dev/null 2>&1 94 | if [ $? -ne 0 ];then 95 | apt-get install unzip >>$XRENDE_INSTALL_LOG 2>&1 96 | fi 97 | fi 98 | 99 | LOG "Your system is: $OS" 100 | } 101 | 102 | install_package() 103 | { 104 | echo_subtitle "install_package $1" 105 | package=$1 106 | whereis $package > /dev/null 2>&1 107 | [ "$?" = "0" ] && ( LOG "package $package is installed";return ) 108 | if [ "$OS" = "$UBUNTU1404" ] ; then 109 | apt-get install -y $package 110 | else 111 | yum install -y $package 112 | fi 113 | } 114 | 115 | # install docker 116 | install_docker() 117 | { 118 | echo_title "install_docker $@" 119 | install_package docker 120 | service docker start 121 | } 122 | 123 | # data dir will be mounted to docker as application data 124 | install_data() 125 | { 126 | echo_title "install_data" 127 | data_path=$BASE_DIR/data.tgz 128 | [ ! -f $data_path ] && (fail "$data_path not exist") 129 | 130 | mkdir -p $DOCKER_DATA_BASE 131 | tar -xzvf $data_path -C $DOCKER_DATA_BASE > /dev/null 2>&1 132 | chmod -R 777 $DOCKER_DATA_BASE > /dev/null 2>&1 133 | } 134 | 135 | # sh dir will be mounted to docker and execute for change configure 136 | install_sh() 137 | { 138 | echo_title "install_sh" 139 | sh_path=$BASE_DIR/sh.tgz 140 | tar -czvf $sh_path *.sh *.sql > /dev/null 2>&1 141 | [ ! -f $sh_path ] && (fail "$sh_path not exist") 142 | 143 | mkdir -p $DOCKER_SH_BASE 144 | tar -xzvf $sh_path -C $DOCKER_SH_BASE > /dev/null 2>&1 145 | chmod -R 777 $DOCKER_SH_BASE 146 | } 147 | 148 | 149 | 150 | # image path 151 | declare -A docker_image_path=() 152 | docker_image_path["portal"]=$BASE_DIR/portal.tar 153 | docker_image_path["rabbitmq"]=$BASE_DIR/rabbitmq.tar 154 | docker_image_path["condor"]=$BASE_DIR/condor.tar 155 | docker_image_path["platform"]=$BASE_DIR/test-platform.tar 156 | docker_image_path["msp"]=$BASE_DIR/test-msp.tar 157 | docker_image_path["python"]=$BASE_DIR/python.tar 158 | docker_image_path["redis"]=$BASE_DIR/redis.tar 159 | docker_image_path["ftp"]=$BASE_DIR/ftp.tar 160 | docker_image_path["mysql"]=$BASE_DIR/mysql.tar 161 | 162 | 163 | # tag 164 | declare -A docker_image_tag=() 165 | docker_image_tag["portal"]="registry.local:5000/xrender-ax-test/portal" 166 | docker_image_tag["rabbitmq"]="registry.local:5000/xrender-ax-test/rabbitmq" 167 | docker_image_tag["condor"]="registry.local:5000/xrender-ax-test/condor" 168 | docker_image_tag["platform"]="registry.local:5000/xrender-ax-test/test-platform" 169 | docker_image_tag["msp"]="registry.local:5000/xrender-ax-test/test-msp" 170 | docker_image_tag["python"]="registry.local:5000/xrender-ax-test/python" 171 | docker_image_tag["redis"]="registry.local:5000/xrender-ax-test/redis" 172 | docker_image_tag["ftp"]="registry.local:5000/xrender-ax-test/ftp" 173 | docker_image_tag["mysql"]="registry.local:5000/xrender-ax-test/mysql" 174 | 175 | # docker port to be used 176 | declare -A docker_image_port=() 177 | docker_image_port["portal"]="80" 178 | docker_image_port["rabbitmq"]="5672 15672" 179 | docker_image_port["condor"]="9618 8888" 180 | docker_image_port["platform"]="28080" 181 | docker_image_port["msp"]="38080" 182 | docker_image_port["python"]="5001" 183 | docker_image_port["redis"]="6379" 184 | docker_image_port["ftp"]="21 2002" 185 | docker_image_port["mysql"]="3306" 186 | 187 | # all docker image mount this dir for execute sh after docker image run 188 | DOCKER_SH_MOUNT=" -v $DOCKER_SH_BASE:$DOCKER_SH_BASE " 189 | 190 | # all docker run command 191 | declare -A docker_image_run_command=() 192 | docker_image_run_command["portal"]="docker run -itd --privileged --name xrender_nginx --net=host -v $DOCKER_DATA_BASE/portal:/root/nginx/portal $DOCKER_SH_MOUNT ${docker_image_tag[portal]}" 193 | docker_image_run_command["rabbitmq"]="docker run -d --privileged --name xrender_rabbitmq --net=host -e RABBITMQ_USERNAME=xrender -e RABBITMQ_PASSWORD=xrender $DOCKER_SH_MOUNT ${docker_image_tag[rabbitmq]}" 194 | docker_image_run_command["condor"]="docker run -itd --privileged --name xrender_condor --net=host $DOCKER_SH_MOUNT ${docker_image_tag[condor]}" 195 | docker_image_run_command["platform"]="docker run -itd --privileged --name xrender_platform --net=host $DOCKER_SH_MOUNT ${docker_image_tag[platform]}" 196 | docker_image_run_command["msp"]="docker run -itd --privileged --name xrender_msp --net=host $DOCKER_SH_MOUNT ${docker_image_tag[platform]}" 197 | docker_image_run_command["python"]="docker run -itd --privileged --net=host --name xrender_python -e LANG=C.UTF-8 $DOCKER_SH_MOUNT ${docker_image_tag[python]}" 198 | docker_image_run_command["redis"]="docker run --name xrender_redis -d --restart=always --net=host $DOCKER_SH_MOUNT ${docker_image_tag[redis]}" 199 | docker_image_run_command["ftp"]="docker run -itd --privileged --net=host --name xrender_ftp -v $DOCKER_DATA_BASE/ftp:/home/ftp1 $DOCKER_SH_MOUNT ${docker_image_tag[ftp]}" 200 | docker_image_run_command["mysql"]="docker run -itd --privileged --net=host --name xrender_mysql $DOCKER_SH_MOUNT ${docker_image_tag[mysql]}" 201 | 202 | 203 | check_port() 204 | { 205 | echo_subtitle "check_port $@" 206 | type=$1 207 | ports=${docker_image_port[$type]} 208 | sleep 10 209 | for port in $ports ; do 210 | result=`netstat -anp | grep ':'$port | awk '{if($6=="LISTEN") print $4}'` 211 | [ -z $result ] && (fail "can not find listen $port ") 212 | done 213 | return 0 214 | } 215 | 216 | 217 | docker_load_image() 218 | { 219 | echo_subtitle "docker_load_image $@" 220 | tag=$1 221 | image_path=${docker_image_path[$tag]} 222 | [ ! -f $image_path ] && (fail "$image_path not exist") 223 | docker load -i $image_path 224 | } 225 | 226 | docker_run_image() 227 | { 228 | echo_subtitle "docker_run_image $@" 229 | tag=$1 230 | run_command=${docker_image_run_command[$tag]} 231 | LOG $run_command 232 | $run_command 233 | } 234 | 235 | modify_docker() 236 | { 237 | echo_subtitle "modify_docker $@" 238 | ip=$1 239 | type=$2 240 | id=$(docker ps -a |grep $type|awk '{print $1}'|head -n 1) 241 | [ -z $id ] && (fail "can not find $type running docker") 242 | docker exec -it $id bash $DOCKER_SH_BASE/$type.sh $ip 243 | } 244 | 245 | docker_load_run() 246 | { 247 | echo_title "docker_load_run $@" 248 | type="$1" 249 | docker_load_image $type 250 | docker_run_image $type 251 | } 252 | 253 | 254 | get_host_ip() 255 | { 256 | eth=`route -n | awk '{if($1=="0.0.0.0" || $1=="default") print $8 }' | head -n 1` 257 | [ -z $eth ] && (fail "can not find default gatway") 258 | ip=`ifconfig $eth | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'` 259 | [ -z $ip ] && ip=`ifconfig $eth | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` 260 | [ -z $ip ] && (fail "can not find ip") 261 | echo $ip 262 | } 263 | 264 | 265 | install_common() 266 | { 267 | host_ip=`get_host_ip` 268 | docker_tag=$1 269 | docker_load_run $docker_tag 270 | [ "$?" != "0" ] && ( fail "docker_load_run $docker_tag failed" ) 271 | modify_docker $host_ip $docker_tag 272 | [ "$?" != "0" ] && ( fail "modify_docker $host_ip $docker_tag failed" ) 273 | check_port $docker_tag 274 | [ "$?" != "0" ] && ( fail "check_port $docker_tag failed" ) 275 | } 276 | 277 | 278 | 279 | main() 280 | { 281 | # check linux releas type 282 | check_system 283 | 284 | # install latest docker 285 | install_docker 286 | 287 | # unzip data file 288 | install_data 289 | 290 | # unzip sh file 291 | install_sh 292 | 293 | # all docker types 294 | all_tag=" 295 | $1 296 | " 297 | 298 | for tag in $all_tag ; do 299 | # install docker image & run docker image & modify all configures 300 | install_common $tag 301 | done 302 | } 303 | if [ "$3" != "" ] ; then 304 | docker rm -f $(docker ps -a|awk '{print $1}') 305 | docker rmi -f $(docker images -q) 306 | fi 307 | main $2 308 | -------------------------------------------------------------------------------- /msp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ip=$1 3 | sed -i "s/10.22.200.18/$ip/g" /usr/local/apache-tomcat-6.0.44/webapps/msp-web/WEB-INF/classes/system.properties 4 | kill -9 $(pidof java) 5 | /usr/local/apache-tomcat-6.0.44/bin/startup.sh 6 | exit 0 7 | -------------------------------------------------------------------------------- /mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #!/bin/sh 3 | 4 | ip=$1 5 | file=/usr/local/xrender/sh/xrender_docker20151201.sql 6 | 7 | docker_host_ip_old=10.22.200.18 8 | docker_host_ip_new=$ip 9 | sed_strings=" 10 | $docker_host_ip_old##${docker_host_ip_new} 11 | " 12 | mysql -uroot -e"grant all on *.* to 'root'@'%' identified by 'xrender' with grant option; grant all on *.* to xrender@'%' identified by 'xrender';flush privileges;" 13 | for sed_item in $sed_strings ; do 14 | sed_from=`echo $sed_item | awk -F'##' '{print $1}'` 15 | sed_to=`echo $sed_item | awk -F'##' '{print $2}'` 16 | sed -i "s/$sed_from/$sed_to/g" $file 17 | done 18 | mysql -h$ip -uxrender -pxrender -e 'create database xrender' 19 | mysql -h$ip -uxrender -pxrender xrender < $file 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /platform.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 -------------------------------------------------------------------------------- /portal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "$1 server.xrender.local" >> /etc/hosts 3 | service nginx reload 4 | exit 0 5 | -------------------------------------------------------------------------------- /python.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 -------------------------------------------------------------------------------- /rabbitmq.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 -------------------------------------------------------------------------------- /redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 --------------------------------------------------------------------------------