1.20. 규정 준수 데이터 복원
Grafana Datasource는 주로 history.local_compliance 라는 테이블에서 사용됩니다. 해당 레코드는 Nightly 00:00:00부터 시작하는 요약 루틴에 의해 생성됩니다. 일반적으로 요약 프로세스를 수동으로 실행할 필요가 없습니다. 경우에 따라 규정 준수 작업을 실행할 때 예기치 않은 오류가 발생할 수 있으므로 생성되지 않은 데이터를 복구하기 위해 전체 요약 프로세스를 실행하려면 데이터베이스에 수동으로 로그인해야 합니다. Running the summarization 프로세스를 수동으로 실행하여 데이터를 복구할 수 있습니다.
1.20.1. 선택 사항: 기존 테이블을 파티션 테이블로 수동으로 업그레이드 링크 복사링크가 클립보드에 복사되었습니다!
GA 전에 멀티 클러스터 글로벌 허브의 초기 버전을 설치한 경우 현재 다중 클러스터 글로벌 허브 Operator와 호환되도록 테이블을 업그레이드해야 합니다. 업그레이드의 주요 목적은 event.local_policies,event.local_root_policies, history.local_compliance 테이블을 분할된 테이블로 변환하는 것입니다.
다음 예제에서는 2023-08 에 대한 날짜가 설정된 event.local_policies 테이블의 변환을 보여줍니다. 다른 두 테이블의 업그레이드 단계는 비슷합니다.
대상이 분할되었는지 확인합니다.
SELECT relname, relkind FROM pg_class WHERE relname = 'local_policies';표 출력은 다음 예와 유사합니다.
Expand relname
relkind
local_policies
r
relkind가p이면 현재 테이블이 분할됩니다. 이 경우 나머지 단계를 건너뛰고 다른 테이블을 업그레이드할 수 있습니다.일반 테이블을 분할된 테이블로 변환합니다.
-- start a transaction BEGIN; -- Rename the legacy TABLE_NAME ALTER TABLE event.local_policies RENAME TO local_policies_old; -- Partition tables: https://github.com/stolostron/multicluster-global-hub/blob/main/operator/pkg/controllers/hubofhubs/database/2.tables.sql#L283-L318 CREATE TABLE IF NOT EXISTS event.local_policies ( event_name character varying(63) NOT NULL, policy_id uuid NOT NULL, cluster_id uuid NOT NULL, leaf_hub_name character varying(63) NOT NULL, message text, reason text, count integer NOT NULL DEFAULT 0, source jsonb, created_at timestamp without time zone DEFAULT now() NOT NULL, compliance local_status.compliance_type NOT NULL, -- Rename the constraint to avoid conflicts CONSTRAINT local_policies_unique_partition_constraint UNIQUE (event_name, count, created_at) ) PARTITION BY RANGE (created_at); -- Create partitions, load the old data to the previous partition table CREATE TABLE IF NOT EXISTS event.local_policies_2023_08 PARTITION OF event.local_policies FOR VALUES FROM ('2023-08-01') TO ('2023-09-01'); CREATE TABLE IF NOT EXISTS event.local_policies_2023_07 PARTITION OF event.local_policies FOR VALUES FROM ('2000-01-01') TO ('2023-08-01'); -- Move the records from regular table to partition table INSERT INTO event.local_policies SELECT * FROM event.local_polcies_old; DROP TABLE IF EXISTS event.local_policies_old; -- commit the transaction COMMIT;테이블 이름 및 현재 날짜에 따라 다음 값을 교체할 수 있습니다.
-
event.local_policies_2023_08은 8월 예를 사용하여 현재 달의 접미사가 있는 파티션 이름입니다. -
'2023-08-01'및'2023-09-01'은 현재 달 파티션의 최소 및 최대 경계입니다. -
event.local_policies_2023_07은 이전 월의 접미사가 있는 파티션 이름입니다(July) -
'2000-01-01'및'2023-08-01'은 이전 달 파티션의 최소 및 최대 경계입니다.
-