1. -- 1. 先建立项目 pandorapandora-box
    2. -- 2. 在各自的项目项目添加 cluster template 作为模板
    3. -- 3. 拷贝 测试环境的 AppNamespace 有效数据
    4. -- select `Name`, `AppId`, `Format`, `IsPublic`, `Comment`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_CreatedTime`, `DataChange_LastModifiedBy`, `DataChange_LastTime` from AppNamespace where IsDeleted = 0 and `Name` != 'application';
    5. -- 4 拷贝 测试环境下的 Namespace 有效数据
    6. -- select `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_CreatedTime`, `DataChange_LastModifiedBy`, `DataChange_LastTime` from Namespace where IsDeleted = 0 and ClusterName = 'default' and NamespaceName != 'application';
    7. -- 4 复制远程端的 namespace 到当前测试库中
    8. -- 5 拷贝 测试环境下的 item 有效数据
    9. select Namespace2.id as `NamespaceId`, Item.`Key`, Item.`Value`, Item.`Comment`, Item.`LineNum`, Item.`IsDeleted`, Item.`DataChange_CreatedBy`, Item.`DataChange_CreatedTime`, Item.`DataChange_LastModifiedBy`, Item.`DataChange_LastTime` from Item,Namespace,Namespace2 where Item.IsDeleted = 0 and Item.NamespaceId = Namespace.id and Namespace.ClusterName = 'default' and Namespace2.NamespaceName = Namespace.NamespaceName and Namespace2.ClusterName = 'template' and Namespace2.AppId = Namespace.AppId;
    10. -- 6 将远端环境 config 库中的 AppNamespace 拷贝到 portal 数据库
    11. --7 发布,或者同步

    页面授权:
    image.png
    接下来修改角色

    1. -- ModifyNamespace+pandora+application
    2. -- ReleaseNamespace+pandora+application
    3. -- ModifyNamespace+pandora+application+DEV
    4. insert into Role (`RoleName`, `IsDeleted`) select b.RoleName,0 as `IsDeleted` from (
    5. SELECT
    6. CONCAT(a.type,AppNamespace.AppId,'+',AppNamespace.name, IFNULL(a.env,'')) as RoleName
    7. FROM
    8. AppNamespace
    9. LEFT JOIN ( SELECT 'ModifyNamespace+' AS type, NULL AS env UNION SELECT 'ReleaseNamespace+' AS type, NULL AS env UNION SELECT 'ModifyNamespace+' AS type, '+DEV' AS env ) a on 1=1
    10. ) b where b.RoleName not in (select Role.RoleName from Role)

    修改权限

    1. insert into Permission (PermissionType, TargetId)
    2. select * from (
    3. SELECT
    4. a.type,CONCAT(AppNamespace.AppId,'+',AppNamespace.name, IFNULL(a.env,'')) as RoleName
    5. FROM
    6. AppNamespace
    7. LEFT JOIN ( SELECT 'ModifyNamespace' AS type, NULL AS env UNION SELECT 'ReleaseNamespace' AS type, NULL AS env UNION SELECT 'ModifyNamespace' AS type, '+DEV' AS env ) a on 1=1
    8. ) b where (b.type,b.RoleName) not in (select Permission.PermissionType,Permission.TargetId from Permission)

    赋权给 apollo
    更新配置

    1. select * from Item, Namespace where Item.`Key` = 'eureka.client.serviceUrl.defaultZone' and Item.NamespaceId = Namespace.id and Namespace.AppId = 'pandora';
    2. -- eureka.client.serviceUrl.defaultZone = http://registrys-test-java:9095/eureka,http://registrys-test-java02:9095/eureka
    3. -- http://106.15.10.251:30089/
    4. update Item,Namespace set Item.`Value` = 'http://106.15.10.251:30089/eureka' where Item.`Key` = 'eureka.client.serviceUrl.defaultZone' and Item.NamespaceId = Namespace.id and Namespace.AppId = 'pandora';
    5. update Item set Item.`Value` = '192.168.0.200' where Item.`Key` = 'graylog.url' ;
    6. update Item set Item.`Value` = '12201' where Item.`Key` = 'graylog.port' ;
    7. update Item set Item.`Value` = 'root' where Item.`Key` = 'spring.datasource.druid.password' ;
    8. update Item set Item.`Value` = '30088' where Item.`Key` = 'spring.redis.port' ;
    9. update Item set Item.`Value` = '106.15.10.251' where Item.`Key` = 'spring.redis.host' ;
    10. update Item set Item.`Value` = '47.101.154.236:30098' where Item.`Key` = 'idgen.zkList' ;
    11. -- update Item set Item.`Value` = 'root' where Item.`Key` = 'spring.datasource.druid.password' ;
    12. select REPLACE(Item.`Value`,'192.168.0.211:30206','106.15.10.251:30082'), Item.* from Item where Item.`Key` = 'spring.datasource.druid.url';--spring.datasource.druid.url http://106.15.10.251/
    13. update Item set Item.`Value` = REPLACE(Item.`Value`,'192.168.0.211:30206','106.15.10.251:30082') where Item.`Key` = 'spring.datasource.druid.url';