Pārlūkot izejas kodu

修复打包脚本

kindring 2 gadi atpakaļ
vecāks
revīzija
9a5d657f68

+ 3 - 0
package/buildDockerImage.sh

@@ -51,11 +51,14 @@ docker save -o ./result/hfysql.tar hfysql:latest
 mkdir ./result/gbRunning
 mkdir ./result/redis
 mkdir ./result/mysql
+mkdir ./result/mysqlConf
+mkdir ./result/sqlback
 cp ./gbDocker/createConfig.sh ./result/gbRunning/createConfig.sh
 cp ./config.cfg ./result/config.cfg
 cp ./startDockerImage.sh ./result/startDockerImage.sh
 cp ./redisDocker/redis.conf ./result/redis/redis.conf
 cp ./updateSqlImage.sh ./result/updateSqlImage.sh
+cp ./my.cnf ./result/mysqlConf/my.cnf
 # 为result目录下的文件添加读写权限
 chmod -R 777 ./result
 

+ 2 - 0
package/config.cfg

@@ -2,6 +2,8 @@
 # mysql 基础配置
 # 是否启用mysql 镜像
 enable_sql=1
+# 是否docker容器是否启用host模式
+sql_enable_host=0
 sql_host="0.0.0.0"
 sql_port=6543
 sql_user="hfygb"

+ 37 - 0
package/my.cnf

@@ -0,0 +1,37 @@
+# For advice on how to change settings please see
+# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
+
+[mysqld]
+#
+# Remove leading # and set to the amount of RAM for the most important data
+# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
+# innodb_buffer_pool_size = 128M
+#
+# Remove leading # to turn on a very important data integrity option: logging
+# changes to the binary log between backups.
+# log_bin
+#
+# Remove leading # to set options mainly useful for reporting servers.
+# The server defaults are faster for transactions and fast SELECTs.
+# Adjust sizes as needed, experiment to find the optimal values.
+# join_buffer_size = 128M
+# sort_buffer_size = 2M
+# read_rnd_buffer_size = 2M
+bind-address=0.0.0.0
+port=3306
+# Remove leading # to revert to previous value for default_authentication_plugin,
+# this will increase compatibility with older clients. For background, see:
+# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
+# default-authentication-plugin=mysql_native_password
+skip-host-cache
+skip-name-resolve
+datadir=/var/lib/mysql
+socket=/var/run/mysqld/mysqld.sock
+secure-file-priv=/var/lib/mysql-files
+user=mysql
+
+pid-file=/var/run/mysqld/mysqld.pid
+[client]
+socket=/var/run/mysqld/mysqld.sock
+
+!includedir /etc/mysql/conf.d/

+ 22 - 8
package/startDockerImage.sh

@@ -65,14 +65,28 @@ if [ "$enable_sql" == "1" ];then
         echo "移除容器占用的mysql目录"
         rm -rf ./mysql/*
     fi
-    # 启动mysql容器
-    docker run -d --name hfysql \
-    -p "$sql_port":3306 \
-    -v "$SCRIPT_DIR/mysql":/var/lib/mysql \
-    -v "$SCRIPT_DIR/sqlBack":/data/sqlBack \
-    --mount type=bind,src="$SCRIPT_DIR/mysqlConf/my.cnf",dst=/etc/mysql/my.cnf \
-    -e MYSQL_ROOT_PASSWORD="$sql_root_passwd" \
-    hfysql:latest
+    # 修改mysql配置文件
+    sed -i \
+        -e "s/^port .*$/port=$sql_port/g" \
+        "$SCRIPT_DIR/mysqlConf/my.cnf";
+    # 启动mysql容器,使用三目语句判断sql_enable_host为1时设置网络模式为host
+    if [ "$sql_enable_host" == "1" ];then
+      docker run -d --name hfysql \
+      --net=host \
+      -v "$SCRIPT_DIR/mysql":/var/lib/mysql \
+      -v "$SCRIPT_DIR/sqlBack":/data/sqlBack \
+      --mount type=bind,src="$SCRIPT_DIR/mysqlConf/my.cnf",dst=/etc/mysql/my.cnf \
+      -e MYSQL_ROOT_PASSWORD="$sql_root_passwd" \
+      hfysql:latest
+    else
+      docker run -d --name hfysql \
+            -p "$sql_port":"$sql_port" \
+            -v "$SCRIPT_DIR/mysql":/var/lib/mysql \
+            -v "$SCRIPT_DIR/sqlBack":/data/sqlBack \
+            --mount type=bind,src="$SCRIPT_DIR/mysqlConf/my.cnf",dst=/etc/mysql/my.cnf \
+            -e MYSQL_ROOT_PASSWORD="$sql_root_passwd" \
+            hfysql:latest
+    fi
     if [ $? -ne 0 ]; then
       echo "run mysql docker failed";
     fi

+ 1 - 1
src/main/resources/application.yml

@@ -196,7 +196,7 @@ user-settings:
     interface-authentication: true
     # 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录
     interface-authentication-excludes:
-         /aiLib/aialarm
+         /aiLib/alarm
     # 推流直播是否录制
     record-push-live: false
     # 国标是否录制