You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
#!/bin/bash
|
|
# 启动一个mysql 容器
|
|
CODE=$1 #容器编号
|
|
MYSQL_PATH=/data/mmogrun/mysql/${CODE}
|
|
|
|
if [ -d "${MYSQL_PATH}" ]; then
|
|
echo "文件夹存在.容器编号重复"
|
|
exit 1
|
|
fi
|
|
mkdir -p ${MYSQL_PATH}
|
|
cp -rf 3rd/mysql ${MYSQL_PATH}/3rd/mysql/
|
|
|
|
cp mcmd.sh ${MYSQL_PATH}
|
|
|
|
cd ${MYSQL_PATH}
|
|
|
|
# shellcheck disable=SC2006
|
|
NUM=`expr ${CODE} \* 10000`
|
|
PORT=`expr ${NUM} + 3306`
|
|
|
|
IMAGES_VERSION=mysql:8.0.23 #
|
|
# --network=mysqltest2 \
|
|
# --hostname=0dc907497e5e \
|
|
#docker run -m 4g -it -d --privileged=true --name mysql_${CODE} -p${PORT}:3306 ${IMAGES_VERSION} /bin/bash >mysql.pid
|
|
docker run --name mysql_${CODE} --env=MYSQL_ROOT_PASSWORD=root -p ${PORT}:3306 --expose=33060 --restart=no --runtime=runc --detach=true ${IMAGES_VERSION} mysqld >mysql.pid
|
|
cat mysql.pid
|
|
PID=$(cat mysql.pid)
|
|
docker cp 3rd ${PID}:/
|
|
docker exec -it ${PID} sh -c "cd /3rd/mysql/ && ./init.sh"
|
|
|
|
# shellcheck disable=SC1073
|
|
echo "created mysql maintainer '"${CODE}"' successfully"
|
|
|
|
echo "new Mysql Data Source Ip Info:"
|
|
docker inspect ${PID} |grep "172.17"
|