Selaa lähdekoodia

fix: 修复数据库异常问题

kindring 1 vuosi sitten
vanhempi
sitoutus
bb73996c41

+ 9 - 8
package/startDockerImage.sh

@@ -56,7 +56,7 @@ if [ "$enable_sql" == "1" ];then
     docker ps -a | grep hfysql
     if [ $? -eq 0 ]; then
         # 导出数据库
-        docker exec -it hfysql mysqldump -uroot -p"$sql_root_passwd" --all-databases > /data/sqlBack/hfysqlSave.sql
+        docker exec -it hfysql mysqldump -uroot -p"$sql_root_passwd" --all-databases > /data/mysql/hfysqlSave.sql
         # 停止容器
         docker stop hfysql
         # 删除容器
@@ -67,8 +67,10 @@ if [ "$enable_sql" == "1" ];then
     fi
     # 修改mysql配置文件
     sed -i \
-        -e "s/^port .*$/port=$sql_port/g" \
+        -e "s/^port=.*/port=$sql_port/g" \
         "$SCRIPT_DIR/mysqlConf/my.cnf";
+#       sed -i 's/^port=.* /port=1234/g' ./mysqlConf/my.cnf
+
     # 启动mysql容器,使用三目语句判断sql_enable_host为1时设置网络模式为host
     if [ "$sql_enable_host" == "1" ];then
       docker run -d --name hfysql \
@@ -76,8 +78,7 @@ if [ "$enable_sql" == "1" ];then
       -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"mysql -u root -p12345678
-       \
+      -e MYSQL_ROOT_PASSWORD="$sql_root_passwd"\
       hfysql:latest
     else
       docker run -d --name hfysql \
@@ -101,8 +102,8 @@ if [ "$enable_redis" == "1" ];then
     #
 #  修改配置redis配置文件
     sed -i \
-    -e "s/^port .*$/port $redis_port/g" \
-    -e "s/^requirepass .*$/requirepass $redis_passwd/g" \
+    -e "s/^port.*$/port $redis_port/g" \
+    -e "s/^requirepass.*$/requirepass $redis_passwd/g" \
     "$SCRIPT_DIR/redis/redis.conf";
     # 导入redis镜像
     docker load -i ./hfyredis.tar
@@ -116,6 +117,7 @@ if [ "$enable_redis" == "1" ];then
     fi
     # 启动redis容器 host 模式启动,端口映射到宿主机
     docker run -it -p "$redis_port":"$redis_port" \
+      --net=host \
      -v /data/redis:/data/redis \
      -v /data/redis/logs:/data/redis/logs \
      -v "$SCRIPT_DIR/redis/redis.conf":/etc/redis/redis.conf \
@@ -171,8 +173,7 @@ if [ "$enable_sql" == "1" ];then
     # 刷新权限
     docker exec -it hfysql mysql \
       -uroot -p"$sql_root_passwd" \
-      -e "
-      FLUSH PRIVILEGES;"
+      -e "FLUSH PRIVILEGES;"
     echo "等待sql重启,等待15秒"
     sleep 15
     reConnect=0

+ 3 - 3
src/main/java/com/genersoft/iot/vmp/storager/dao/AdminMapper.java

@@ -71,7 +71,7 @@ public interface AdminMapper {
 //    WHERE sip.adminId = 1 AND dev.id = 15;
 
     @Select("SELECT dev.*\n" +
-            "FROM sipConfig sip\n" +
+            "FROM sip_config sip\n" +
             "JOIN devices dev ON sip.sipDomain = dev.domain\n" +
             "JOIN adminSip a ON sip.id = a.sipId\n" +
             "WHERE a.adminId = ${adminId} AND dev.id = ${devId};\n")
@@ -83,7 +83,7 @@ public interface AdminMapper {
     Device getDeviceByAdminIdAndDevId(String adminId, String devId);
 
     @Select("SELECT dev.*\n" +
-            "FROM sipConfig sip\n" +
+            "FROM sip_config sip\n" +
             "JOIN devices dev ON sip.sipDomain = dev.domain\n" +
             "JOIN adminSip a ON sip.id = a.sipId\n" +
             "WHERE a.adminId = ${adminId} AND dev.deviceId = ${deviceSipId};\n")
@@ -96,7 +96,7 @@ public interface AdminMapper {
 
     @Select("SELECT d.*, sc.*\n" +
             "    FROM devices d\n" +
-            "    JOIN sipConfig sc ON d.domain = sc.sipDomain\n" +
+            "    JOIN sip_config sc ON d.domain = sc.sipDomain\n" +
             "    JOIN adminSip a ON sc.id = a.sipId\n" +
             "    WHERE a.adminId = ${adminId};")
     /**