<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: GBASE Database</title>
    <description>The latest articles on DEV Community by GBASE Database (@generaldata).</description>
    <link>https://dev.to/generaldata</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1624741%2Fe9c2d6b3-6b26-41c1-9ca8-644df3a1e4c4.png</url>
      <title>DEV Community: GBASE Database</title>
      <link>https://dev.to/generaldata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/generaldata"/>
    <language>en</language>
    <item>
      <title>GBase 8a Optimization Techniques for Precise Queries</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Thu, 12 Mar 2026 07:02:09 +0000</pubDate>
      <link>https://dev.to/generaldata/gbase-8a-optimization-techniques-for-precise-queries-39m</link>
      <guid>https://dev.to/generaldata/gbase-8a-optimization-techniques-for-precise-queries-39m</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“In database systems, the fastest query is not just about hardware power, but about how intelligently the data is located and returned.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This article summarizes several known optimization techniques for &lt;strong&gt;precise query scenarios in the GBase 8a MPP Cluster database&lt;/strong&gt;.&lt;br&gt;
The focus is on the simplest form of &lt;strong&gt;exact-match queries&lt;/strong&gt;, where the query condition is already known.&lt;/p&gt;

&lt;p&gt;The techniques discussed include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hash distribution&lt;/li&gt;
&lt;li&gt;Global hash index&lt;/li&gt;
&lt;li&gt;Row-storage columns&lt;/li&gt;
&lt;li&gt;Parallel materialization&lt;/li&gt;
&lt;li&gt;Pre-sorting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More optimization methods may be added in the future as additional practices are verified.&lt;/p&gt;


&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Performance improvement test of &lt;strong&gt;Global Hash Index&lt;/strong&gt; in GBase 8a&lt;/li&gt;
&lt;li&gt;Parallel materialization parameter &lt;code&gt;gbase_parallel_threshold&lt;/code&gt; in GBase 8a&lt;/li&gt;
&lt;li&gt;Performance improvement test of &lt;strong&gt;row-storage grouped columns&lt;/strong&gt; in GBase 8a&lt;/li&gt;
&lt;li&gt;Improving simple queries with &lt;code&gt;LIMIT&lt;/code&gt; using the &lt;code&gt;first_rows&lt;/code&gt; hint in GBase 8a&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  What Is a Precise Query?
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;precise query&lt;/strong&gt; refers to an &lt;strong&gt;equality-based query&lt;/strong&gt; where the exact value is specified.&lt;/p&gt;

&lt;p&gt;For example, retrieving the call records of a specific phone number on a specific date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;MyTable_20210808&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;calling_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13912345678&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Optimization Analysis
&lt;/h1&gt;

&lt;p&gt;From a database execution perspective, this type of query can be divided into &lt;strong&gt;two stages&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Location stage&lt;/strong&gt;&lt;br&gt;
Identify which rows match the query condition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Result retrieval stage&lt;/strong&gt;&lt;br&gt;
Read the full row data and return the result set.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;“Efficient queries are essentially a two-step dance: find the rows quickly, then assemble the results efficiently.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Location Stage
&lt;/h1&gt;

&lt;p&gt;This stage determines &lt;strong&gt;which rows satisfy the given condition&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Global Hash Index
&lt;/h2&gt;

&lt;p&gt;Indexes are the most common method for improving query performance.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;GBase 8a database&lt;/strong&gt;, this stage is optimized using a &lt;strong&gt;hash index&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This index works best for &lt;strong&gt;low-duplication columns&lt;/strong&gt;, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Phone numbers&lt;/li&gt;
&lt;li&gt;ID numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For columns with &lt;strong&gt;high duplication&lt;/strong&gt;, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ethnicity&lt;/li&gt;
&lt;li&gt;Region&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;performance may actually decrease.&lt;/p&gt;

&lt;p&gt;A practical rule of thumb:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If the duplication rate is &lt;strong&gt;below 0.1% (1‰)&lt;/strong&gt;, the column can generally be considered suitable for a hash index.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Actual performance should always be validated through testing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pre-Sorting
&lt;/h2&gt;

&lt;p&gt;Sorting data based on query columns can increase the hit rate of the &lt;strong&gt;intelligent indexing mechanism&lt;/strong&gt; used in the GBase database engine.&lt;/p&gt;




&lt;h1&gt;
  
  
  Result Retrieval Stage
&lt;/h1&gt;

&lt;p&gt;In a traditional &lt;strong&gt;row-based database&lt;/strong&gt;, once a row is located, retrieving the entire row is straightforward.&lt;/p&gt;

&lt;p&gt;However, in a &lt;strong&gt;columnar database&lt;/strong&gt;, the system must reconstruct a row by combining data from multiple columns.&lt;/p&gt;

&lt;p&gt;The more columns involved, the greater the cost of this reconstruction.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;GBase 8a&lt;/strong&gt;, this process is called &lt;strong&gt;Materialization&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Row-Storage Columns
&lt;/h2&gt;

&lt;p&gt;GBase allows certain columns to be stored using &lt;strong&gt;row-based storage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This approach trades &lt;strong&gt;storage space for faster query performance&lt;/strong&gt;, improving efficiency during result reconstruction.&lt;/p&gt;




&lt;h2&gt;
  
  
  Parallel Materialization
&lt;/h2&gt;

&lt;p&gt;In scenarios with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;small query volumes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;low concurrency&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;limited disk resource contention&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;parallel materialization can be considered.&lt;/p&gt;

&lt;p&gt;When the result set is small and system resources are not heavily contested, adjusting the parameter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gbase_parallel_threshold
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can enable &lt;strong&gt;parallel result materialization&lt;/strong&gt; and improve query performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pre-Sorting (Again)
&lt;/h2&gt;

&lt;p&gt;If data is stored &lt;strong&gt;sorted by the query column&lt;/strong&gt;, the matching rows are typically &lt;strong&gt;physically adjacent&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This dramatically reduces disk I/O and can significantly improve query performance.&lt;/p&gt;

&lt;p&gt;However, sorting has trade-offs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sorting large datasets takes time&lt;/li&gt;
&lt;li&gt;The larger the sorting range, the longer the sorting operation&lt;/li&gt;
&lt;li&gt;A table can have &lt;strong&gt;only one primary sorting column&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In many cases, this approach works well for &lt;strong&gt;historical data&lt;/strong&gt;, where data is written once but queried many times.&lt;/p&gt;




&lt;h1&gt;
  
  
  Choosing a Hash Distribution Column
&lt;/h1&gt;

&lt;p&gt;Whether a query column should be used for &lt;strong&gt;hash distribution&lt;/strong&gt; depends largely on &lt;strong&gt;query concurrency&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Hash distribution ensures that rows with the same key value are stored on the &lt;strong&gt;same node&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Low-Concurrency Scenarios
&lt;/h2&gt;

&lt;p&gt;If only a small number of queries are executed simultaneously:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hash distribution is &lt;strong&gt;not recommended&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Allowing more nodes to participate in the query computation can actually improve performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  High-Concurrency Scenarios
&lt;/h2&gt;

&lt;p&gt;A classic example comes from the &lt;strong&gt;telecommunications industry&lt;/strong&gt;, where customers frequently query &lt;strong&gt;call detail records (CDR)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Although each user may only have &lt;strong&gt;tens or hundreds of records per month&lt;/strong&gt;, there may be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hundreds&lt;/li&gt;
&lt;li&gt;or even thousands&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;of users querying simultaneously.&lt;/p&gt;

&lt;p&gt;At peak times, especially at the beginning of the month, the concurrency can increase even further.&lt;/p&gt;

&lt;p&gt;In such cases, &lt;strong&gt;hash distribution on the query column is recommended&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With hash distribution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;queries for the same condition can be completed on a single node&lt;/li&gt;
&lt;li&gt;different queries are likely distributed across different nodes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This reduces resource contention across the cluster and increases the overall number of parallel queries the database can support.&lt;/p&gt;

&lt;p&gt;It also makes &lt;strong&gt;capacity planning during cluster expansion&lt;/strong&gt; much easier.&lt;/p&gt;




&lt;h1&gt;
  
  
  Precise Queries with LIMIT
&lt;/h1&gt;

&lt;p&gt;For exact-match queries that include a &lt;code&gt;LIMIT&lt;/code&gt; clause, query performance can be further optimized using the &lt;strong&gt;&lt;code&gt;first_rows&lt;/code&gt; hint&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This technique allows the &lt;strong&gt;GBase database optimizer&lt;/strong&gt; to prioritize returning the first rows of the result set more quickly.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;“Database optimization is rarely about a single trick. It is usually a combination of distribution strategy, indexing design, and execution tuning working together.”&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>database</category>
      <category>gbase</category>
      <category>数据库</category>
    </item>
    <item>
      <title>GBase Cloud Data Warehouse (GCDW): Unlocking New Potential in Data Utilization</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Tue, 11 Mar 2025 08:01:25 +0000</pubDate>
      <link>https://dev.to/generaldata/gbase-cloud-data-warehouse-gcdw-unlocking-new-potential-in-data-utilization-195n</link>
      <guid>https://dev.to/generaldata/gbase-cloud-data-warehouse-gcdw-unlocking-new-potential-in-data-utilization-195n</guid>
      <description>&lt;p&gt;Built on the foundation of GBase 8a database, the cloud-native data warehouse GCDW effectively integrates multi-source data and provides a unified view and supports complex queries and analysis. It significantly enhances data utilization efficiency and decision support capabilities, injecting new momentum into industry innovation and development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s1rtgpvy914666xmcnc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s1rtgpvy914666xmcnc.jpeg" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Maximizing Data Value Across All Dimensions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Enhanced Resource Utilization Efficiency
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server Reuse and Cost Reduction:&lt;/strong&gt; By leveraging server reuse strategies, GCDW significantly improves hardware utilization efficiency, reducing procurement and maintenance costs while maximizing the value of existing resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Assurance for Concurrent Operations:&lt;/strong&gt; GCDW effectively alleviates resource constraints, enabling businesses to run multiple services in parallel with strong resource guarantees. This flexibility empowers enterprises to manage and allocate resources efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Enhanced Business Continuity Assurance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Disaster Recovery System:&lt;/strong&gt; GCDW builds a multi-center, multi-cluster PB-level disaster recovery system with robust backup, recovery, and active-active synchronization capabilities to ensure data integrity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stable Operations Guarantee:&lt;/strong&gt; Even in cases of unexpected failures or natural disasters, GCDW maintains continuous business operations, preventing economic losses and reputational damage, making it a key pillar of stable enterprise operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Efficient Data Management and Value Extraction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tool-Driven Process Optimization:&lt;/strong&gt; GCDW offers practical tools for data migration, backup management, and GVR synchronization, streamlining data migration and simplifying backup operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data-Driven Business Decisions:&lt;/strong&gt; GCDW achieves efficient and accurate data synchronization, improving data management efficiency and quality. This ensures precise data support for analytics and decision-making, driving business growth.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Enhanced Business Performance Optimization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Precise Application Matching:&lt;/strong&gt; GCDW optimizes resource allocation and scheduling strategies to meet performance requirements, especially for scenarios involving wide tables with large memory footprints and numerous nodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Customer Experience:&lt;/strong&gt; By accelerating data processing speeds and improving response times, GCDW enhances the overall user experience, helping enterprises excel in competitive markets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Intelligent Operations and Maintenance System
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensive Monitoring System:&lt;/strong&gt; GCDW builds a monitoring system that covers cluster-level to tenant-level metrics, offering real-time insights into system performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proactive Alerting and Issue Resolution:&lt;/strong&gt; GCDW quickly identifies potential performance bottlenecks and issues, providing early warnings and swift resolutions to maintain system stability and ensure smooth business operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Improved Resource Management Efficiency
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accurate Capacity Management:&lt;/strong&gt; Leveraging monitoring data at both the cluster and resource layers, GCDW enables precise capacity management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimized Resource Planning:&lt;/strong&gt; GCDW helps users gain insights into resource utilization patterns, ensuring accurate resource allocation to prevent waste or shortages, ultimately reducing operating costs and improving overall efficiency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Accelerated Cloud Transformation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility Analysis and Guidance:&lt;/strong&gt; GCDW conducts in-depth analysis of business requirements and cloud adaptability, providing clear direction for cloud migration and innovation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expanding Service Boundaries:&lt;/strong&gt; By leveraging cloud warehouse features, GCDW drives innovation, expands service boundaries, and supports personalized product development, addressing diverse customer needs and fueling business growth.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Driving Industry Development with Key Contributions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Leading Resource Efficiency Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Model Promotion:&lt;/strong&gt; GCDW showcases efficient resource utilization practices such as server reuse and refined resource allocation, setting a benchmark for industry peers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sustainable Development Support:&lt;/strong&gt; GCDW encourages resource conservation and improved utilization, contributing to sustainable growth within the industry.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setting a New Standard in Disaster Recovery Technology
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Advanced Disaster Recovery Capability:&lt;/strong&gt; GCDW's industry-leading PB-level disaster recovery capabilities provide a strong reference standard for disaster recovery system design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Risk Mitigation:&lt;/strong&gt; By strengthening data security and business continuity, GCDW helps other enterprises reduce systemic risks and maintain market stability.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Driving Data Management Innovation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Innovative Tools and Solutions:&lt;/strong&gt; GCDW offers advanced tools and methodologies for data migration, backup, and synchronization, providing fresh ideas and practical solutions for the industry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upgraded Data Management Techniques:&lt;/strong&gt; By enhancing data quality and management efficiency, GCDW lays a solid foundation for data-driven business innovation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advancing Performance Optimization Trends
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Technology Sharing and Best Practices:&lt;/strong&gt; GCDW's achievements in meeting complex application performance needs provide valuable insights for industry peers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Industry Competitiveness:&lt;/strong&gt; By helping businesses enhance system performance, improve service quality, and boost efficiency, GCDW supports overall industry growth and competitiveness.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Establishing a New Monitoring System Paradigm
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Optimization Experience Sharing:&lt;/strong&gt; GCDW's experience in refining monitoring systems from node-level to cluster-level and tenant-level serves as a valuable reference for enhancing monitoring frameworks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stable Technology System Assurance:&lt;/strong&gt; GCDW helps peers implement comprehensive monitoring for cloud-native architectures, ensuring stable technology system operations and fostering healthy industry growth.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Catalyzing Innovation in Technology Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Practical Case Studies:&lt;/strong&gt; GCDW's successful implementations in data sharing, active-active synchronization, and integrated data lake/warehouse scenarios provide practical references for new technology adoption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leading Industry Innovation:&lt;/strong&gt; By helping enterprises evaluate and apply new technologies, GCDW accelerates innovation adoption and drives the industry toward a new era of digital transformation.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>database</category>
      <category>cloudnative</category>
    </item>
    <item>
      <title>Exploring GBase 8s Window Functions: Unlocking Data Analysis Tools</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Mon, 10 Feb 2025 09:58:34 +0000</pubDate>
      <link>https://dev.to/generaldata/exploring-gbase-8s-window-functions-unlocking-data-analysis-tools-170h</link>
      <guid>https://dev.to/generaldata/exploring-gbase-8s-window-functions-unlocking-data-analysis-tools-170h</guid>
      <description>&lt;p&gt;Today, we will explore the &lt;strong&gt;Window Functions&lt;/strong&gt; in the GBase 8s database, focusing on the &lt;strong&gt;Window Frame&lt;/strong&gt; clause and how it helps us process and analyze data more efficiently.&lt;/p&gt;

&lt;p&gt;Window functions are a tool introduced in the SQL standard that allows us to perform calculations on a set of rows (called a window) in a query without losing row details, as traditional aggregate functions do. With window functions, we can perform complex calculations such as cumulative sums, moving averages, rankings, etc., while maintaining the integrity of the data rows. The &lt;strong&gt;Window Frame&lt;/strong&gt; clause is an essential part of window functions, defining the scope of the window, i.e., which rows will be included in the calculation. By flexibly defining the window scope, we can meet various complex data analysis requirements.&lt;/p&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Window Frame&lt;/strong&gt; clause returns a subset of rows within each window partition. The frame clause specifies how this subset is defined by a specific number of rows or a range of values. The frame is determined relative to the current row, allowing the frame to move within the partition based on the current row's position.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By defining a frame as all rows from the start of the partition to the current row, we can calculate the cumulative sum up to the current row.&lt;/li&gt;
&lt;li&gt;By defining a frame as extending N rows on either side of the current row, we can calculate a rolling average.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrg1yneq46bahp6cphu2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrg1yneq46bahp6cphu2.png" alt="Image description" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Terms in the Window Frame Clause
&lt;/h3&gt;

&lt;p&gt;The following keywords define the scope of the window:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Element&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;OFFSET&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;An unsigned integer representing the offset from the current row position. Cannot be negative. If zero, it specifies the current row.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RANGE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A value-based frame clause.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ROWS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A row-based frame clause.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UNBOUNDED&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All rows from the current row to the limit of the window partition.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UNBOUNDED PRECEDING&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The starting boundary is the first row in the partition.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UNBOUNDED FOLLOWING&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The ending boundary is the last row in the partition.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PRECEDING&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specifies a negative offset from the current row.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;FOLLOWING&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specifies a positive offset from the current row.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CURRENT ROW&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The current row.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Row-Based (ROWS) Window Frame
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;ROWS&lt;/strong&gt; keyword creates a row-based window frame. The frame is defined by the positions of the starting and ending rows, where the offset represents the number of rows to return.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1: Return the current row and the previous 6 rows.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;avg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="nb"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;day&lt;/span&gt; 
&lt;span class="k"&gt;ROWS&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="k"&gt;PRECEDING&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;CURRENT&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2: Requirement: Partition employees by department, sort by salary, and return the average salary of the current employee and the previous employee within each partition.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Create table&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;serial&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;emp_id&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="nb"&gt;decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Insert data&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;emp_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'carry'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'lili'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5500&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00B'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tom'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00B'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'amy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00B'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'chun'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00C'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'zouzou'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5200&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00D'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'candy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5800&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E00D'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'mumu'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Query: Partition by department, sort by salary, and calculate the average salary of the current and previous employee.&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; 
   &lt;span class="n"&gt;emp_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;emp_id&lt;/span&gt;
       &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;
       &lt;span class="k"&gt;ROWS&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;PRECEDING&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;CURRENT&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;
   &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Result&lt;/span&gt;
&lt;span class="n"&gt;EMP_ID&lt;/span&gt;   &lt;span class="n"&gt;NAME&lt;/span&gt;    &lt;span class="n"&gt;SALARY&lt;/span&gt;       &lt;span class="n"&gt;AVG_SALARY&lt;/span&gt;
&lt;span class="n"&gt;E00A&lt;/span&gt;     &lt;span class="n"&gt;carry&lt;/span&gt;   &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00A&lt;/span&gt;     &lt;span class="n"&gt;lili&lt;/span&gt;    &lt;span class="mi"&gt;5500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;5250&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;tom&lt;/span&gt;     &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;amy&lt;/span&gt;     &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;6250&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;chun&lt;/span&gt;    &lt;span class="mi"&gt;7000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;6750&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00C&lt;/span&gt;     &lt;span class="n"&gt;zouzou&lt;/span&gt;  &lt;span class="mi"&gt;5200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;5200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00D&lt;/span&gt;     &lt;span class="n"&gt;candy&lt;/span&gt;   &lt;span class="mi"&gt;5800&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;5800&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00D&lt;/span&gt;     &lt;span class="n"&gt;mumu&lt;/span&gt;    &lt;span class="mi"&gt;6200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;      &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="k"&gt;row&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;retrieved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Value-Based (RANGE) Window Frame
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;RANGE&lt;/strong&gt; keyword creates a value-based frame clause. The frame is defined by rows within a specific value range, where the offset is the difference between the row value and the current row value. The frame consists of the current row and rows that meet the criteria set by the sorting key in the &lt;strong&gt;ORDER BY&lt;/strong&gt; clause and the specified offset. The offset represents the number of units of the sorting key's data type. The sorting key must be numeric, DATE, or DATETIME. For example, if the sorting key is of DATE type, the offset represents a specific number of days.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1: Return rows with dates within 2 days before or after the current row.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;ship_date&lt;/span&gt;
&lt;span class="k"&gt;RANGE&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;PRECEDING&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;FOLLOWING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2: Requirement: Partition employees by department, sort by age, and return the average salary of employees whose age differs by no more than 5 years.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
   &lt;span class="n"&gt;emp_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;emp_id&lt;/span&gt;
       &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;
       &lt;span class="k"&gt;RANGE&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;PRECEDING&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;FOLLOWING&lt;/span&gt;
   &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Result&lt;/span&gt;
&lt;span class="n"&gt;emp_id&lt;/span&gt;   &lt;span class="n"&gt;NAME&lt;/span&gt;    &lt;span class="n"&gt;age&lt;/span&gt;   &lt;span class="n"&gt;salary&lt;/span&gt;    &lt;span class="n"&gt;avg_salary&lt;/span&gt;
&lt;span class="n"&gt;E00A&lt;/span&gt;     &lt;span class="n"&gt;carry&lt;/span&gt;   &lt;span class="mi"&gt;18&lt;/span&gt;    &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00A&lt;/span&gt;     &lt;span class="n"&gt;lili&lt;/span&gt;    &lt;span class="mi"&gt;28&lt;/span&gt;    &lt;span class="mi"&gt;5500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;5500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;tom&lt;/span&gt;     &lt;span class="mi"&gt;22&lt;/span&gt;    &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;amy&lt;/span&gt;     &lt;span class="mi"&gt;25&lt;/span&gt;    &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00B&lt;/span&gt;     &lt;span class="n"&gt;chun&lt;/span&gt;    &lt;span class="mi"&gt;26&lt;/span&gt;    &lt;span class="mi"&gt;7000&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;6500&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00C&lt;/span&gt;     &lt;span class="n"&gt;zouzou&lt;/span&gt;  &lt;span class="mi"&gt;25&lt;/span&gt;    &lt;span class="mi"&gt;5200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;5200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00D&lt;/span&gt;     &lt;span class="n"&gt;candy&lt;/span&gt;   &lt;span class="mi"&gt;23&lt;/span&gt;    &lt;span class="mi"&gt;5800&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;5800&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;span class="n"&gt;E00D&lt;/span&gt;     &lt;span class="n"&gt;mumu&lt;/span&gt;    &lt;span class="mi"&gt;29&lt;/span&gt;    &lt;span class="mi"&gt;6200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;   &lt;span class="mi"&gt;6200&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;000000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;In the E00A partition, the age difference between the two employees is greater than 5 years, so the average salary is their own salary. In the E00B partition, the age difference is within 5 years, so the average salary includes the other employee's salary.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Through the above introduction, we can see that the &lt;strong&gt;Window Functions&lt;/strong&gt; and &lt;strong&gt;Window Frame&lt;/strong&gt; clause in &lt;strong&gt;GBase 8s&lt;/strong&gt; provide powerful data analysis capabilities. Whether it's precise row-based control or flexible value-based processing, window functions help us quickly achieve complex calculation requirements. In practical applications, we can choose the appropriate window type and scope based on specific needs to process and analyze data more efficiently.&lt;/p&gt;

&lt;p&gt;We hope this article helps you better understand and apply window functions, unlocking new perspectives in data analysis. If you have any questions or suggestions about window functions or GBase 8s, feel free to leave a comment. Let's learn and grow together!&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>Summary of Common Issues with GBase 8c Primary-Standby Cluster</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Mon, 10 Feb 2025 07:24:00 +0000</pubDate>
      <link>https://dev.to/generaldata/summary-of-common-issues-with-gbase-8c-primary-standby-cluster-4c18</link>
      <guid>https://dev.to/generaldata/summary-of-common-issues-with-gbase-8c-primary-standby-cluster-4c18</guid>
      <description>&lt;p&gt;GBase 8c is a multi-model database representing the third generation of intelligent distributed database products from GBASE. It supports various storage modes and deployment forms, offering high performance, high availability, high intelligence, high security, and strong compatibility. This article primarily describes failure cases caused by operating system versions, environmental issues, etc., that lead to installation failures. It aims to help users quickly locate problems, analyze causes, and provide solutions or ideas to proficiently use the GBase 8c database.&lt;/p&gt;

&lt;h2&gt;
  
  
  0. Fault Classification
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic environment not ready&lt;/li&gt;
&lt;li&gt;System version/environment issues&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Basic Environment Not Ready
&lt;/h2&gt;

&lt;p&gt;Preparation before installation mainly involves checking operating system information, whether dependency packages are installed, whether the hostname is effective, whether the firewall is closed, whether the root user passwords are consistent across multiple machines, whether the time is synchronized, etc. Specific steps can be referred to as follows:&lt;/p&gt;

&lt;h3&gt;
  
  
  1.1 Check Operating System Information
&lt;/h3&gt;

&lt;p&gt;1) Whether the ID information is in the json file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# cat /etc/os-release                      # General command for Linux operating systems&lt;/span&gt;
&lt;span class="nv"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Kylin Linux Advanced Server"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"V10 (Tercel)"&lt;/span&gt;
&lt;span class="nv"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"kylin"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"V10"&lt;/span&gt;
&lt;span class="nv"&gt;PRETTY_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Kylin Linux Advanced Server V10 (Tercel)"&lt;/span&gt;
&lt;span class="nv"&gt;ANSI_COLOR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"0;31"&lt;/span&gt;

&lt;span class="c"&gt;# cat support_system_info.json&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
 &lt;span class="s2"&gt;"SUSE"&lt;/span&gt;: &lt;span class="s2"&gt;"suse"&lt;/span&gt;,
 &lt;span class="s2"&gt;"REDHAT"&lt;/span&gt;: &lt;span class="s2"&gt;"redhat"&lt;/span&gt;,
 &lt;span class="s2"&gt;"CENTOS"&lt;/span&gt;: &lt;span class="s2"&gt;"centos"&lt;/span&gt;,
 &lt;span class="s2"&gt;"EULEROS"&lt;/span&gt;: &lt;span class="s2"&gt;"euleros"&lt;/span&gt;,
 &lt;span class="s2"&gt;"KYLIN"&lt;/span&gt;: &lt;span class="s2"&gt;"kylin"&lt;/span&gt;,
 &lt;span class="s2"&gt;"KYLINSEC"&lt;/span&gt;: &lt;span class="s2"&gt;"kylinsecos"&lt;/span&gt;,
 &lt;span class="s2"&gt;"OPENEULER"&lt;/span&gt;: &lt;span class="s2"&gt;"openeuler"&lt;/span&gt;,
 &lt;span class="s2"&gt;"FUSIONOS"&lt;/span&gt;: &lt;span class="s2"&gt;"fusionos"&lt;/span&gt;,
 &lt;span class="s2"&gt;"ASIANUX"&lt;/span&gt;: &lt;span class="s2"&gt;"asianux"&lt;/span&gt;,
 &lt;span class="s2"&gt;"DEBIAN"&lt;/span&gt;: &lt;span class="s2"&gt;"debian"&lt;/span&gt;,
 &lt;span class="s2"&gt;"UBUNTU"&lt;/span&gt;: &lt;span class="s2"&gt;"ubuntu"&lt;/span&gt;,
 &lt;span class="s2"&gt;"NFS"&lt;/span&gt;: &lt;span class="s2"&gt;"nfs"&lt;/span&gt;,
 &lt;span class="s2"&gt;"UOS"&lt;/span&gt;: &lt;span class="s2"&gt;"uos"&lt;/span&gt;,
 &lt;span class="s2"&gt;"BCLINUX"&lt;/span&gt;: &lt;span class="s2"&gt;"bclinux"&lt;/span&gt;,
 &lt;span class="s2"&gt;"NEOKYLIN"&lt;/span&gt;: &lt;span class="s2"&gt;"neokylin"&lt;/span&gt;,
 &lt;span class="s2"&gt;"OPENKYLIN"&lt;/span&gt;: &lt;span class="s2"&gt;"openkylin"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) If it is a Kylin operating system, you also need to check whether the current version is based on Ubuntu, using the following command (either one will do):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# cat /etc/.kyinfo &lt;/span&gt;
&lt;span class="c"&gt;# cat /etc/os-release &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the returned version information, if the dist_id parameter value starts with "Kylin-Desktop", it is an Ubuntu-based operating system.&lt;/p&gt;

&lt;p&gt;You need to replace bash. Use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# sudo dpkg-reconfigure dash &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the process, select No and press Enter. After exiting, it will automatically switch to bash.&lt;/p&gt;

&lt;p&gt;3) For Kylin operating systems, you need to disable security authorization authentication&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# setstatus softmode -p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) CentOS/RHEL 7.2+ environment&lt;/p&gt;

&lt;p&gt;The systemd-logind service introduces a new feature—RemoveIPC, which manifests as: files created after a user logs in will be automatically deleted after logout. In the default case (i.e., RemoveIPC=yes), when a user logs out, the operating system will crash applications that use Shared Memory Segment (SHM) or Semaphores (SEM), causing the GBase database process to be interrupted. To avoid such problems, follow these steps:&lt;/p&gt;

&lt;p&gt;(1) Check if the RemoveIPC parameter value is yes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# loginctl show-session | grep RemoveIPC&lt;/span&gt;
&lt;span class="c"&gt;# systemctl show systemd-logind | grep RemoveIPC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it is yes, it needs to be modified; if it is no, there is no need to continue with the following steps.&lt;/p&gt;

&lt;p&gt;(2) Modify the /etc/systemd/logind.conf configuration file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# vim /etc/systemd/logind.conf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the RemoveIPC parameter value to no, type ":wq" to save and exit.&lt;/p&gt;

&lt;p&gt;Modify the /usr/lib/systemd/system/systemd-logind.service configuration file, set the RemoveIPC parameter value to no.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# vim /usr/lib/systemd/system/systemd-logind.service&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the RemoveIPC parameter value to no, type ":wq" to save and exit.&lt;/p&gt;

&lt;p&gt;(3) Reload the configuration file, execute the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# systemctl daemon-reload&lt;/span&gt;
&lt;span class="c"&gt;# systemctl restart systemd-logind&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(4) Check again to see if it takes effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# loginctl show-session | grep RemoveIPC&lt;/span&gt;
&lt;span class="c"&gt;# systemctl show systemd-logind | grep RemoveIPC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.2 Check CPU Architecture
&lt;/h3&gt;

&lt;p&gt;Confirm whether it is x86 or aarch64&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# lscpu |grep 'Architecture'&lt;/span&gt;
  Architecture:                    x86_64 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It needs to be consistent with the information in the downloaded package name, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;GBase8cV6_SXXXXX_centos7.8_x86_64.tar.gz                                                              &lt;span class="c"&gt;# x86 package&lt;/span&gt;
GBase8cV6_SXXXXX_centos7.8_aarch64.tar.gz                                                             &lt;span class="c"&gt;# aarch64 package&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.3 Pre-installation Dependency Check
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# rpm -qa|egrep "libaio-devel|flex|bison|ncurses-devel|glibc-devel|patch|redhat-lsb-core|readline-devel|libnsl|expect|patchelf|bzip2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installation command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel libnsl expect patchelf  bzip2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.4 Confirm Hostname Consistency
&lt;/h3&gt;

&lt;p&gt;Modify the hostname. Even for single-machine deployment, it is not recommended to use the default localhost.&lt;/p&gt;

&lt;p&gt;Execute the command to view the hostname:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# cat /etc/hostname&lt;/span&gt;
&lt;span class="c"&gt;# hostname&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modification method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# hostnamectl set-hostname  gbasedb01&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.5 Create Database OS Management User
&lt;/h3&gt;

&lt;p&gt;Take gbase as an example, it is not recommended to use the graphical interface to create&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# groupadd gbase&lt;/span&gt;
&lt;span class="c"&gt;# useradd -m -d /home/gbase gbase -g gbase&lt;/span&gt;
&lt;span class="c"&gt;# passwd gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.6 Close the Firewall
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# systemctl stop firewalld.service&lt;/span&gt;
&lt;span class="c"&gt;# systemctl disable firewalld.service&lt;/span&gt;
&lt;span class="c"&gt;# sed -i.bak '/^SELINUX=/s#SELINUX=.*#SELINUX=disabled#' /etc/selinux/config&lt;/span&gt;
&lt;span class="c"&gt;# setenforce  0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the environment requires it to be open, you can refer to the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# systemctl start firewalld&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15400/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15300/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15301/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15302/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15405/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=15401/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=5000/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=5001/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --add-port=5002/tcp --permanent&lt;/span&gt;
&lt;span class="c"&gt;# firewall-cmd --zone=public --query-port=15400/tcp&lt;/span&gt;
systemctl restart firewalld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.7 Multi-node Environment Installation Requires Checking Time Consistency
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# date&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modification method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# hwclock --show&lt;/span&gt;
&lt;span class="c"&gt;# hwclock --systohc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: During the database startup process, time inconsistency will cause the startup to hang. When manually modifying the time, you need to modify the current time to a future time.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.8 Check Maximum Open Files
&lt;/h3&gt;

&lt;p&gt;The requirement is not less than 640000&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ulimit -n&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modification method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# echo 'ulimit -n 1000000' &amp;gt;&amp;gt; ~/.bashrc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. System Version/Environment Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 Multi-node Installation, Root Password Inconsistency
&lt;/h3&gt;

&lt;p&gt;Solution:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Temporarily adjust to be consistent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If it cannot be changed, follow the steps below to install&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;① Execute gs_preinstall under root on each machine, place the installation package and xml file in the same directory, and add the -L command to gs_preinstall to only perform local installation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./gs_preinstall &lt;span class="nt"&gt;-U&lt;/span&gt; gbase  &lt;span class="nt"&gt;-G&lt;/span&gt; gbase  &lt;span class="nt"&gt;-X&lt;/span&gt; /opt/cluster.xml &lt;span class="nt"&gt;-L&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;② Switch to the gbase user, establish mutual trust for the gbase user, after establishment, execute "ssh hostname", "ssh ip" to log in to the local machine and other machines, refresh the cache information (refer to the ssh-free configuration issue for details)&lt;/p&gt;

&lt;p&gt;③ Execute the installation on any server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gs_install &lt;span class="nt"&gt;-X&lt;/span&gt; /opt/cluster.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 SSH-free Configuration Issue
&lt;/h3&gt;

&lt;p&gt;Complete password-free configuration reference is as follows (can avoid ssh permission issues)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# su - gbase&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; /home/gbase/.ssh
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/.ssh
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;700 ~/.ssh
&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-copy-id gbase@172.16.xx.xxx
&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-copy-id gbase@172.16.xx.xxx

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'StrictHostKeyChecking no'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.ssh/config
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'UserKnownHostsFile ~/.ssh/known_hosts'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.ssh/config
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;644 ~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verification test (both IP and hostname need to be tested)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ssh 172.16.xx.xxx  &lt;span class="nb"&gt;date&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;ssh 172.16.xx.xxx  &lt;span class="nb"&gt;date&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;ssh gbasedb01  &lt;span class="nb"&gt;date&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;ssh gbasedb01  &lt;span class="nb"&gt;date&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If during verification, it is found that ssh ip works but ssh hostname does not, ping the hostname to confirm if it is ipv6. If it is ipv6, perform the following operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'precedence ::ffff:0:0/96 100'&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/gai.conf 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.3 Environment Issues
&lt;/h3&gt;

&lt;p&gt;(1) Error xxxx list index out of range during installation&lt;/p&gt;

&lt;p&gt;Check the xml file during installation, focusing on whether the hostname and IP address are configured correctly.&lt;/p&gt;

&lt;p&gt;(2) Error "importerror:libffi.so.6:cannot open shared object file: no such file or directory" during installation.&lt;/p&gt;

&lt;p&gt;This may be due to the server's CPU architecture being ARM version, and the residual files from previously installed X86 version packages. In this case, according to the error message, delete all corresponding residues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ll /lib64/libffi.so.6&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="nb"&gt;sudo rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; /lib64/libffi.so.6&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(3) Error "cannot execute binary file" during installation.&lt;/p&gt;

&lt;p&gt;This is due to the GBase 8c installation package not matching the CPU architecture. According to the deployment environment, replace the corresponding version of the installation package. For details, see 1.2 Check CPU Architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.4 VIP Configuration Issue After Installation
&lt;/h3&gt;

&lt;p&gt;1) VIP address does not float&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Check if sudo permissions are configured on all machines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;su - gbase
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Check if VIP is configured on the standby machine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;find /&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'cm_resource.json'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) The entire cluster is unavailable when the primary node is down&lt;/p&gt;

&lt;p&gt;Check if the VIP information is saved in the cm_server configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cm_ctl  list &lt;span class="nt"&gt;--param&lt;/span&gt; &lt;span class="nt"&gt;--server&lt;/span&gt;| &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"third_party_gateway_ip"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the above query result is empty, configure as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cm_ctl &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--param&lt;/span&gt; &lt;span class="nt"&gt;--server&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="s2"&gt;"third_party_gateway_ip= gateway address"&lt;/span&gt;
cm_ctl &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--param&lt;/span&gt; &lt;span class="nt"&gt;--server&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="s2"&gt;"cms_enable_db_crash_recovery=1"&lt;/span&gt;
cm_ctl &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--param&lt;/span&gt; &lt;span class="nt"&gt;--server&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="s2"&gt;"cms_network_isolation_timeout=10"&lt;/span&gt;
cm_ctl &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--param&lt;/span&gt; &lt;span class="nt"&gt;--server&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="s2"&gt;"cms_enable_failover_on2nodes=1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;This article aims to provide a comprehensive guide to troubleshooting common issues encountered during the installation and configuration of GBase 8c primary-standby clusters. By following the detailed steps and solutions provided, users can ensure a smooth and successful deployment of the GBase 8c database. For further assistance, refer to the official documentation or reach out to the support team.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>Using GBase 8a Kafka Consumer for Data Synchronization</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Mon, 10 Feb 2025 07:01:28 +0000</pubDate>
      <link>https://dev.to/generaldata/using-gbase-8a-kafka-consumer-for-data-synchronization-1k6k</link>
      <guid>https://dev.to/generaldata/using-gbase-8a-kafka-consumer-for-data-synchronization-1k6k</guid>
      <description>&lt;h2&gt;
  
  
  Configuration of Data Synchronization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Parameter Configuration
&lt;/h3&gt;

&lt;p&gt;To use the Kafka consumer, configure the parameters as follows. Refer to the supplementary notes for details on adjustable parameters.&lt;/p&gt;

&lt;h4&gt;
  
  
  GCluster Configuration
&lt;/h4&gt;

&lt;p&gt;Edit the file: &lt;code&gt;/opt/gcluster/config/gbase_8a_gcluster.cnf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;_gbase_transaction_disable&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1 (Ensure this is not set to 0)&lt;/span&gt;
&lt;span class="py"&gt;gcluster_lock_level&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;10 (Not recommended to use 2)&lt;/span&gt;
&lt;span class="py"&gt;_gcluster_insert_cache_buffer_flag&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;span class="py"&gt;gcluster_assign_kafka_topic_period&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;20&lt;/span&gt;
&lt;span class="py"&gt;gcluster_kafka_max_message_size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1000000&lt;/span&gt;
&lt;span class="py"&gt;gcluster_kafka_batch_commit_dml_count&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;100000&lt;/span&gt;
&lt;span class="py"&gt;gcluster_kafka_local_queue_size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;210000&lt;/span&gt;
&lt;span class="py"&gt;gcluster_kafka_consume_batch&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;100&lt;/span&gt;
&lt;span class="py"&gt;gcluster_kafka_user_allowed_max_latency&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Adjustable Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_assign_kafka_topic_period&lt;/strong&gt;: Time period in seconds for automatic consumer takeover. Min: 20s, Max: 120s.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_kafka_max_message_size&lt;/strong&gt;: Maximum message size in bytes from Kafka topic. Must be &amp;gt;= Kafka server's &lt;code&gt;message.max.bytes&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_kafka_batch_commit_dml_count&lt;/strong&gt;: Number of DML operations per commit. Adjust based on table count and performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_kafka_user_allowed_max_latency&lt;/strong&gt;: Maximum latency in milliseconds for message caching in the 8a cluster layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_kafka_local_queue_size&lt;/strong&gt;: Length of the DML operation queue. Recommended to be more than double &lt;code&gt;gcluster_kafka_batch_commit_dml_count&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gcluster_kafka_consume_batch&lt;/strong&gt;: Number of Kafka messages consumed at once. Recommended range: 10-1000.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  GNode Configuration
&lt;/h4&gt;

&lt;p&gt;Edit the file: &lt;code&gt;/opt/gnode/config/gbase_8a_gbase.cnf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;_gbase_transaction_disable&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1 (Ensure this is not set to 0)&lt;/span&gt;
&lt;span class="py"&gt;gbase_tx_log_mode&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;ONLY_SPECIFY_USE (Do not use USE,STANDARD_TRANS)&lt;/span&gt;
&lt;span class="py"&gt;gbase_buffer_insert&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1024M&lt;/span&gt;
&lt;span class="py"&gt;gbase_tx_log_flush_time&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Adjustable Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;gbase_buffer_insert&lt;/strong&gt;: Size of the insert buffer. Adjust based on data volume and consumer tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gbase_tx_log_flush_time&lt;/strong&gt;: Frequency in seconds for flushing in-memory data. Recommended: 5 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Ensure all nodes have consistent configurations to avoid unknown errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commands for Starting and Stopping
&lt;/h2&gt;

&lt;p&gt;Execute the following commands on any Coordinator node using &lt;code&gt;gccli&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Consumer Task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;consumer_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;TRANSACTION&lt;/span&gt; &lt;span class="n"&gt;TOPIC&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;kafka_topic_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BROKERS&lt;/span&gt; &lt;span class="s1"&gt;'ip:port, ip:port,…'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;consumer_name&lt;/strong&gt;: Unique name for the consumer task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;kafka_topic_name&lt;/strong&gt;: Name of the Kafka topic to consume.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ip:port&lt;/strong&gt;: Kafka broker's IP and port.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="n"&gt;test1&lt;/span&gt; &lt;span class="n"&gt;TRANSACTION&lt;/span&gt; &lt;span class="n"&gt;TOPIC&lt;/span&gt; &lt;span class="n"&gt;topic_1&lt;/span&gt; &lt;span class="n"&gt;BROKERS&lt;/span&gt; &lt;span class="s1"&gt;'10.10.10.10:9092,10.10.10.11:9092'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deleting a Consumer Task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;consumer_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure the consumer task is stopped before deletion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewing Consumer Task Properties
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SHOW&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;consumer_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SHOW&lt;/span&gt; &lt;span class="n"&gt;TRANSACTION&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Starting a Consumer Task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;START&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;consumer_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stopping a Consumer Task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;STOP&lt;/span&gt; &lt;span class="n"&gt;KAFKA&lt;/span&gt; &lt;span class="n"&gt;CONSUMER&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;consumer_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Status Query
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kafka_consumer_status&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fields:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consumer&lt;/strong&gt;: Name of the consumer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IP&lt;/strong&gt;: Node IP where the consumer task is running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Topic&lt;/strong&gt;: Kafka topic name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Status&lt;/strong&gt;: Start or stop state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Min_offset&lt;/strong&gt;: Minimum offset in the Kafka queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Max_offset&lt;/strong&gt;: Maximum offset in the Kafka queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cur_offset&lt;/strong&gt;: Current offset being processed by 8a.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process_offset&lt;/strong&gt;: Offset of the message currently being synchronized.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commit_offset&lt;/strong&gt;: Offset of the last committed message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exception&lt;/strong&gt;: Description of the last error encountered.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Handling Exceptions in Consumer Tasks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JSON Parsing Errors
&lt;/h3&gt;

&lt;p&gt;If a JSON message parsing error occurs, the consumer task will enter a sleep state. Check the &lt;code&gt;exception&lt;/code&gt; field for details. Use Kafka's consumer tool to inspect the problematic message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kafka_home&lt;/span&gt;/bin/kafka-simple-consumer-shell.sh &lt;span class="nt"&gt;--broker-list&lt;/span&gt; 192.168.103.74:9092 &lt;span class="nt"&gt;--topic&lt;/span&gt; test3 &lt;span class="nt"&gt;--offset&lt;/span&gt; 797 &lt;span class="nt"&gt;--max-messages&lt;/span&gt; 1 &lt;span class="nt"&gt;--partition&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cluster Lock Failure or Node Offline
&lt;/h3&gt;

&lt;p&gt;If cluster lock failure or node offline occurs, the consumer task will exit and wait for task scheduler reassignment. Check the status for &lt;code&gt;status=waiting start, IP=unknown&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  GBase Single Node Execution Error
&lt;/h3&gt;

&lt;p&gt;If an error occurs during single node execution, the consumer task will enter a sleep state. Address the issue and restart the consumer task.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Exception Descriptions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JSON Parsing Issues&lt;/strong&gt;: Indicates a malformed JSON message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing Primary Key&lt;/strong&gt;: Indicates a missing primary key in the JSON message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invalid Primary Key&lt;/strong&gt;: Indicates an invalid primary key in the JSON message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target Table Does Not Exist&lt;/strong&gt;: Indicates the target table is missing in GBase 8a.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Table Definition Mismatch&lt;/strong&gt;: Indicates a mismatch in table definitions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Primary Key Changed&lt;/strong&gt;: Indicates a change in the primary key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Insertion Error&lt;/strong&gt;: Indicates an error during data insertion, such as data truncation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Always ensure the JSON messages and table definitions are correct to avoid synchronization issues.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE 数据库 | Physical and Logical Logs in GBase 8s Database</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Sat, 08 Feb 2025 08:24:39 +0000</pubDate>
      <link>https://dev.to/generaldata/gbase-shu-ju-ku-physical-and-logical-logs-in-gbase-8s-database-3fm4</link>
      <guid>https://dev.to/generaldata/gbase-shu-ju-ku-physical-and-logical-logs-in-gbase-8s-database-3fm4</guid>
      <description>&lt;p&gt;In database management, the logging system is a critical component for ensuring data integrity and system recovery. In GBase 8s, both physical and logical logs play vital roles in system recovery and data management. This article explores the structure, functionality, and importance of these logs in database management.&lt;/p&gt;

&lt;h2&gt;
  
  
  Physical Logs: The Foundation of Fast Recovery
&lt;/h2&gt;

&lt;p&gt;Physical logs record all physical operations in the database, such as modifications, insertions, and deletions of data pages. These records are essential for restoring the database to its state before a system failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Facts About Physical Logs:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used during fast recovery.&lt;/li&gt;
&lt;li&gt;Often set too small in most customer systems, leading to frequent checkpoints.&lt;/li&gt;
&lt;li&gt;Can be moved outside the root dbspace, which is generally recommended.&lt;/li&gt;
&lt;li&gt;Crucial for GBase 8s's fast recovery mechanism and its archiving algorithm, especially in environments prone to power failures and disk crashes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Common Pitfalls:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The initial size of the physical log is often too small, causing frequent checkpoints. This is a common mistake made by novice administrators.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Physical Log Page Structure:
&lt;/h3&gt;

&lt;p&gt;The page structure of the physical log is similar to that of regular data pages but with key differences. Physical log pages contain the address of the original page location rather than the physical location in the log. This allows for accurate data restoration during recovery.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhht5cphr8gettkegr7oa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhht5cphr8gettkegr7oa.png" alt="Physical Log Page Structure" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows the structure of a physical log page. The page in the physical log is identical to its original page. The only way to determine that a page is from the physical log is by examining the page address (offset and block). The page contains the address of the original page location, not its physical location in the log.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logical Logs: Ensuring Data Consistency
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fseyjxmio24ai1rch4nyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fseyjxmio24ai1rch4nyo.png" alt="Image description" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Logical logs can be thought of as a sequence of log pages, each with a page offset equivalent to a logical page number.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Characteristics:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each logical log is a continuous sequence of log pages, numbered starting from 0.&lt;/li&gt;
&lt;li&gt;Log files are segments within a block and are continuously overwritten. They serve as temporary hosts for logical logs.&lt;/li&gt;
&lt;li&gt;Logical logs can contain any number of pages, from 1 to the total available in the log file.&lt;/li&gt;
&lt;li&gt;Logical log pages are generated one after another in the logical log buffer and written out sequentially each time the buffer is flushed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Logical Log Page Structure:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3d4hknxaw38mrdirbz9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3d4hknxaw38mrdirbz9p.png" alt="Logical Log Page Structure" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown in the image above, the structure of a logical log page suggests a sequential method of accessing log records. For example, note that the page does not have a slot table (the length of each record is stored within the record itself). Also, logical log data flows smoothly from one page to the next without interruption (though records must be entirely contained within the log file). Even the page header has some unique attributes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unique Attributes of the Page Header:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;pg_nslots&lt;/strong&gt;: Unused, as there is no real concept of slots on log pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pg_frcnt&lt;/strong&gt;: Always zero, even for partially filled pages (note that pg_frptr is accurate). This is more coincidental than by design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pg_next&lt;/strong&gt;: Contains the unique ID of the logical log.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pg_prev&lt;/strong&gt;: Contains the page offset (similar to a logical page number) of the log page. Note that this is the offset within the log, starting from 0.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Logical Log Position:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwnin1s322ja1swqzudhx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwnin1s322ja1swqzudhx.png" alt="Image description" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Log records are uniquely addressed within a specific logical log. The address used is called the logical log position, or logpos. It is a 4-byte integer code that describes the location of the log record based on the page offset and byte offset. The page offset is relative to the start of the log, indexed from 0. The byte offset is relative to the start of the page, also indexed from 0, but should not be less than 0x018 due to the space occupied by the page header.&lt;/p&gt;

&lt;p&gt;For example, if you are told that a logical log record is located in logical log 234 with a logpos of 0x12018, you would:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the newer of the two checkpoint/logical log retention pages in the root chunk to find the physical address of log number 234.&lt;/li&gt;
&lt;li&gt;Once at that page, you would offset 0x12 pages within the log to find the correct log page.&lt;/li&gt;
&lt;li&gt;Then, offset 0x018 bytes within that page to find the log record.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Displaying Logical Logs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Displaying All Logical Log Files:
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;onstat -l&lt;/code&gt; command to display all logical log files. Logical log files have two numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Number (number)&lt;/strong&gt;: This number remains constant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unique ID (uniqid)&lt;/strong&gt;: Since logical log files are reused cyclically, a unique ID is needed to distinguish them.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@node2 ids]# onstat &lt;span class="nt"&gt;-l&lt;/span&gt;
On-Line &lt;span class="nt"&gt;--&lt;/span&gt; Up 16 days 03:16:37 &lt;span class="nt"&gt;--&lt;/span&gt; 19345028 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages    numwrits   pages/io
 P-2   98       256      13934      66          211.12
     phybegin         physize    phypos      phyused    %used
     2:53             32715      25656      4971       15.19

Logical Logging
Buffer bufused  bufsize  numrecs     numpages   numwrits   recs/pages pages/io
 L-3   0        128      1408526     154832     116507     9.1        1.3
       Subsystem    numrecs     Log Space used
       OLDRSAM      1408450    141317188
       HA           6          264
       DDL          70         24360

address          number   flags     uniqid   begin                size     used     %used
45b79a60         14       U-B----  121       3:29483              3270     3270    100.00
45b79ac8         13       U-B---L  122       3:26213              3270     3270    100.00
45b79b30         12       U-B----  123       3:22943              3270     3270    100.00
45b79b98         11       U-B----  124       3:19673              3270     3270    100.00
45b79c00         10       U-B----  125       3:16403              3270     3270    100.00
45b79c68         9        U-B----  126       3:13133              3270     3270    100.00
45b79cd0         8        U-B----  127       3:9863               3270     3270    100.00
45b79d38         7        U-B----  128       3:6593               3270     3270    100.00
45b79da0         6        U-B----  129       3:3323               3270     3270    100.00
45b79e08         5        U-B----  130       3:53                 3270     3270    100.00
45b79e70         1        U-B----  131       3:32753              3270     3270    100.00
45b79ed8         2         U-B----  132      3:36023              3270     3270    100.00
45b79f40         3        U-B----  133       3:39293              3270     3270    100.00
45b79fa8         4        U-B----  134       3:42563              3270     3270    100.00
4538df30         15       U-B----  135       3:45833              3270     3270    100.00
4538df98         16       U-B----  136       3:49103              3270     3270    100.00
4545ce28         17       U---C--  137       3:52373              3270     2411     73.73
485196a0         18       U-B----  120       3:55643              3270     3270    100.00
48acbed8         19       A------  0         3:58913              3270        0      0.00
19 active, 19 total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Displaying Logical Log Content:
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;onlog&lt;/code&gt; command to display the content of logical logs. Specific usage details are not covered here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By exploring the physical and logical logs in GBase 8s, we gain a deeper understanding of their structure, functionality, and importance in database management and recovery. This article aims to provide valuable insights and inspiration, helping you better manage and maintain your GBase database systems.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE 数据库 | Distributed Memory Monitoring in GBase 8c Database: A Practical Guide</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Sat, 08 Feb 2025 07:52:59 +0000</pubDate>
      <link>https://dev.to/generaldata/distributed-memory-monitoring-in-gbase-8c-database-a-practical-guide-2f58</link>
      <guid>https://dev.to/generaldata/distributed-memory-monitoring-in-gbase-8c-database-a-practical-guide-2f58</guid>
      <description>&lt;p&gt;The smooth operation of a database management system heavily relies on the server's hardware environment, including hard drives and memory. GBase 8c, a distributed database known for its high performance and availability, requires effective memory monitoring to maintain optimal performance. This article delves into the practices of monitoring memory in a distributed environment, specifically within GBase 8c.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ensuring Server Memory Health
&lt;/h2&gt;

&lt;p&gt;To ensure that server memory is functioning correctly, it's essential to monitor several key aspects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Memory Usage Monitoring&lt;/strong&gt;: Utilize database-provided monitoring tools or operating system-level tools like &lt;code&gt;top&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; to observe the physical memory usage across nodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache Hit Rate Check&lt;/strong&gt;: Monitor the cache hit rate during the operation of the GBase 8c database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Testing&lt;/strong&gt;: Conduct simulated performance tests to evaluate memory performance under concurrent access and large data processing scenarios.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article focuses on memory monitoring in distributed scenarios, providing a brief guide on how to perform these operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring Memory Usage
&lt;/h2&gt;

&lt;p&gt;Memory usage can be monitored using tools provided by the database itself or the operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Querying Memory Usage via SQL Commands
&lt;/h3&gt;

&lt;p&gt;You can retrieve memory usage information by executing specific SQL commands within the GBase 8c database. This involves querying system tables or views to gather data on memory usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_totale_memory_detail&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Using Operating System Commands
&lt;/h3&gt;

&lt;p&gt;On Linux systems, several commands are commonly used to monitor system memory usage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;free -m&lt;/code&gt;&lt;/strong&gt;: Displays a summary of memory usage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;vmstat&lt;/code&gt;&lt;/strong&gt;: Reports virtual memory statistics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;top&lt;/code&gt;&lt;/strong&gt;: Provides a dynamic view of processes, including memory usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Key Metrics to Monitor
&lt;/h3&gt;

&lt;p&gt;When monitoring memory usage, pay attention to the following key metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Memory Utilization&lt;/strong&gt;: Track the total memory used and the available memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache Usage&lt;/strong&gt;: Monitor the usage of different types of caches, such as shared cache and buffer cache.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Allocation&lt;/strong&gt;: Ensure that the memory allocated by the database does not exceed predefined thresholds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Leaks&lt;/strong&gt;: Regularly check for any signs of memory leaks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Monitoring memory usage is an ongoing process that requires regular checks and adjustments based on the monitoring results. This ensures the performance and stability of the database, particularly in a distributed environment like GBase 8c. By following the practices outlined above, database administrators can maintain a healthy memory environment, contributing to the overall efficiency and reliability of the database system.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE 数据库 | GBase 8a Database GDOM Deployment Guide</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Fri, 07 Feb 2025 08:38:14 +0000</pubDate>
      <link>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-database-gdom-deployment-guide-1a1m</link>
      <guid>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-database-gdom-deployment-guide-1a1m</guid>
      <description>&lt;p&gt;The GBase 8a MPP Database Operation Management System (GDOM) is a B/S architecture tool designed to provide full lifecycle operation and maintenance (O&amp;amp;M) support for the GBase 8a MPP database. It offers a range of functionalities including cluster management, host management, health checks, and alerts, all aimed at reducing customer O&amp;amp;M costs, improving efficiency, and ensuring 24/7 operation of the cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  GDOM Environment Setup Checklist
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Server&lt;/th&gt;
&lt;th&gt;Installed Components&lt;/th&gt;
&lt;th&gt;Node Type&lt;/th&gt;
&lt;th&gt;Remarks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10.0.0.211&lt;/td&gt;
&lt;td&gt;nginx, gdom-service&lt;/td&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.0.0.212&lt;/td&gt;
&lt;td&gt;haproxy&lt;/td&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.0.0.213&lt;/td&gt;
&lt;td&gt;mysql&lt;/td&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.0.0.214&lt;/td&gt;
&lt;td&gt;mysql&lt;/td&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.0.0.215&lt;/td&gt;
&lt;td&gt;Redis, RocketMQ&lt;/td&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note: Node Types&lt;/strong&gt;  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deployment Node: This is where the GDOM installation package is deployed. GDOM installation, service start/stop, uninstallation, and status queries are all managed from this node. It is the special installation node for managing GDOM services.
&lt;/li&gt;
&lt;li&gt;Installation Node: This is the server for installing GDOM components.
&lt;em&gt;For high availability configuration, if deploying with a single node, ignore the optional nodes.&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. Unpacking the Installation Package
&lt;/h3&gt;

&lt;p&gt;1.1. On the 10.0.0.211 machine, use the root user to unpack the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@nginx_gdom-service /opt]# &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xf&lt;/span&gt; GDOM-v3.0.0-build1.2.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Set Up User Trust
&lt;/h3&gt;

&lt;p&gt;2.1. Prerequisite: Configure &lt;code&gt;demo.options&lt;/code&gt; to specify the servers requiring mutual trust.&lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;demo.options&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vim /opt/GDOM-v3.0.0-build1.2/demo.options
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;gdomRoot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/gdom
&lt;span class="nv"&gt;gdomService&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.211
&lt;span class="nv"&gt;gdomServicePort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8080
&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gdom
&lt;span class="nv"&gt;gdomDb&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.213,10.0.0.214
&lt;span class="nv"&gt;gdomDbPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3306
&lt;span class="nv"&gt;gdomDbUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbUser&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;root
&lt;span class="nv"&gt;gdomDbPwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="nv"&gt;gdomDbHa&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.212
&lt;span class="nv"&gt;gdomDbHaPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3307
&lt;span class="nv"&gt;gdomDbHaMonitorPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8811
&lt;span class="nv"&gt;gdomDbHaMonitorAdmin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin
&lt;span class="nv"&gt;gdomDbHaMonitorPwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin
&lt;span class="nv"&gt;gdomNginx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.211
&lt;span class="nv"&gt;gdomNginxPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8810
&lt;span class="nv"&gt;gdomNginxUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;gdomRedis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.215
&lt;span class="nv"&gt;gdomRedisPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;7481
&lt;span class="nv"&gt;gdomRedisDb&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="nv"&gt;gdomRedisUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;gdomMq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.0.0.215
&lt;span class="nv"&gt;gdomMqPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9876
&lt;span class="nv"&gt;gdomDashBoardPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9898
&lt;span class="nv"&gt;gdomMqUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.2. Execute on all machines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;useradd gdom
passwd gdom
su - gdom
ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-P&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
ssh-copy-id &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Set Up Auto Start (Optional)
&lt;/h3&gt;

&lt;p&gt;3.1. On the deployment machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@nginx_gdom-service ~]# vim /etc/rc.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh -e&lt;/span&gt;
/opt/GDOM-v3.0.0-build1.2/gdomStart.sh &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/opt&lt;/code&gt;: The parent directory where the GDOM installation package is unpacked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GDOM-v3.0.0-build1.2&lt;/code&gt;: The directory where the GDOM installation package is unpacked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gdomStart.sh -a&lt;/code&gt;: The one-click start script for GDOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. GDOM Deployment
&lt;/h3&gt;

&lt;p&gt;4.1. &lt;strong&gt;Note&lt;/strong&gt;: Ensure that the user has permission to operate on the GDOM root directory on all nodes.&lt;br&gt;&lt;br&gt;
On all machines, execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; /opt/gdom  
&lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; gdom.gdom /opt/gdom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.2. On the deployment machine, run the installation script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@nginx_gdom-service /opt/GDOM-v3.0.0-build1.2]# su - gdom
&lt;span class="o"&gt;[&lt;/span&gt;gdom@nginx_gdom-service /opt/GDOM-v3.0.0-build1.2]# sh gdomInstall.sh &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Start GDOM Service
&lt;/h3&gt;

&lt;p&gt;5.1. On the deployment machine, start the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gdom@nginx_gdom-service /opt/GDOM-v3.0.0-build1.2]&lt;span class="nv"&gt;$ &lt;/span&gt;sh gdomStart.sh &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.2. After starting the service, access the browser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL: &lt;code&gt;http://10.0.0.211:8810&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Default Username: &lt;code&gt;admin&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Default Password: &lt;code&gt;admin123&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To stop the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh gdomStop.sh &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check the service status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh gdomStatus.sh &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Explanation of &lt;code&gt;demo.options&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# GDOM installation root directory&lt;/span&gt;
&lt;span class="nv"&gt;gdomRoot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/pjx
&lt;span class="c"&gt;# Backend service installation node (comma-separated)&lt;/span&gt;
&lt;span class="nv"&gt;gdomService&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.2
&lt;span class="c"&gt;# Backend service port (affects frontend requests to gdom-service)&lt;/span&gt;
&lt;span class="nv"&gt;gdomServicePort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8080
&lt;span class="c"&gt;# GDOM user&lt;/span&gt;
&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gdom
&lt;span class="c"&gt;# Repository installation nodes (for high availability configuration, comma-separated)&lt;/span&gt;
&lt;span class="nv"&gt;gdomDb&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.4,192.168.1.5
&lt;span class="c"&gt;# Repository access port (affects backend requests to MySQL)&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3306
&lt;span class="c"&gt;# Existing repository IP address&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.3.87
&lt;span class="c"&gt;# Repository connection user&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbUser&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;root
&lt;span class="c"&gt;# Repository connection password&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbPwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;111111
&lt;span class="c"&gt;# High availability proxy node for repository (recommended to deploy separately)&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbHa&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.3
&lt;span class="c"&gt;# Repository high availability access port&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbHaPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3307
&lt;span class="c"&gt;# Repository high availability proxy monitor access port&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbHaMonitorPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8811
&lt;span class="c"&gt;# Repository high availability proxy monitor login user&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbHaMonitorAdmin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin
&lt;span class="c"&gt;# Repository high availability proxy monitor login password&lt;/span&gt;
&lt;span class="nv"&gt;gdomDbHaMonitorPwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin
&lt;span class="c"&gt;# Nginx installation node&lt;/span&gt;
&lt;span class="nv"&gt;gdomNginx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.2
&lt;span class="c"&gt;# Nginx access port (affects browser access)&lt;/span&gt;
&lt;span class="nv"&gt;gdomNginxPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8810
&lt;span class="c"&gt;# Existing Nginx IP address [If this is set, gdomNginx is invalid]&lt;/span&gt;
&lt;span class="nv"&gt;gdomNginxUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="c"&gt;# Redis installation node&lt;/span&gt;
&lt;span class="nv"&gt;gdomRedis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.6
&lt;span class="c"&gt;# Redis access port (affects backend requests to Redis)&lt;/span&gt;
&lt;span class="nv"&gt;gdomRedisPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;7481
&lt;span class="c"&gt;# Redis DB to use&lt;/span&gt;
&lt;span class="nv"&gt;gdomRedisDb&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="c"&gt;# Existing Redis IP address [If this is set, gdomRedis is invalid]&lt;/span&gt;
&lt;span class="nv"&gt;gdomRedisUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="c"&gt;# RocketMQ installation node&lt;/span&gt;
&lt;span class="nv"&gt;gdomMq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.1.6
&lt;span class="c"&gt;# RocketMQ access port (affects backend requests to RocketMQ)&lt;/span&gt;
&lt;span class="nv"&gt;gdomMqPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9876
&lt;span class="c"&gt;# RocketMQ monitoring platform access port (optional)&lt;/span&gt;
&lt;span class="nv"&gt;gdomDashBoardPort&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9898
&lt;span class="c"&gt;# Existing RocketMQ IP address [If this is set, gdomMq is invalid]&lt;/span&gt;
&lt;span class="nv"&gt;gdomMqUrl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: MySQL, Redis, RocketMQ, and Nginx are optional components.&lt;br&gt;&lt;br&gt;
If the user’s environment already has these components, configure their URL properties in &lt;code&gt;demo.options&lt;/code&gt;. Regardless of whether they are newly installed or already present, the ports need to be configured.&lt;br&gt;&lt;br&gt;
For the best results, it is recommended to do a fresh installation to avoid conflicts with existing middleware.&lt;/p&gt;




&lt;p&gt;With GDOM, you can ensure efficient O&amp;amp;M operations, simplified management, and seamless service monitoring for your GBase 8a deployment. Happy managing!&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE数据库 | Understanding Partition Pages in GBase 8s Database</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Fri, 07 Feb 2025 07:43:55 +0000</pubDate>
      <link>https://dev.to/generaldata/gbaseshu-ju-ku-understanding-partition-pages-in-gbase8s-database-50cm</link>
      <guid>https://dev.to/generaldata/gbaseshu-ju-ku-understanding-partition-pages-in-gbase8s-database-50cm</guid>
      <description>&lt;p&gt;In this article, we will explore a crucial data storage structure in the GBase 8s database—&lt;strong&gt;Partition Page&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;In the first chunk of each dbspace, the pages following the chunk free list mark the beginning of the &lt;strong&gt;tblspace tblspace&lt;/strong&gt; (partition table).&lt;/p&gt;

&lt;p&gt;Tables (or indexes) can be either &lt;strong&gt;non-fragmented&lt;/strong&gt; or &lt;strong&gt;fragmented&lt;/strong&gt;. For non-fragmented tables, there is only one partition. For fragmented tables, there are multiple partitions.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;partition&lt;/strong&gt; (also referred to as a "fragment") is essentially a &lt;strong&gt;tblspace&lt;/strong&gt;. The metadata for this tblspace is stored in the &lt;strong&gt;tblspace tblspace&lt;/strong&gt; page. The tblspace tblspace manages the metadata for all partitions, similar to how a table manages multiple rows of data. Hence, it is called &lt;strong&gt;tblspace tblspace&lt;/strong&gt;, or the table space that manages table spaces.&lt;/p&gt;

&lt;p&gt;The layout of the tblspace tblspace is as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqzn0vn8dcfqwl4e4ofe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqzn0vn8dcfqwl4e4ofe.png" alt="Tblspace Tblspace Layout" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By configuring the &lt;code&gt;TBLTBLFIRST&lt;/code&gt; and &lt;code&gt;TBLTBLNEXT&lt;/code&gt; parameters in the &lt;code&gt;onconfig&lt;/code&gt; file, you can set the size of the first and subsequent extents for the tblspace tblspace. A default value of &lt;code&gt;0&lt;/code&gt; indicates that the database server will determine the appropriate extent size based on the initial dbspace chunk size.&lt;/p&gt;

&lt;p&gt;Each tblspace in the system has a &lt;strong&gt;tblspace tblspace page&lt;/strong&gt; that describes it. For simplicity, we often refer to this special page type as a &lt;strong&gt;partition page&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Partition Number (Partnum)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6mqo1ql3801rwrnm7bh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6mqo1ql3801rwrnm7bh6.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First 12 bits&lt;/strong&gt;: dbspace number&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Last 20 bits&lt;/strong&gt;: Logical page number within the tblspace tblspace&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of the &lt;strong&gt;Partnum&lt;/strong&gt; (a 4-byte hexadecimal code) is to guide GBase8s to the partition page of the table within the tblspace-tblspace. The high 12 bits of the partnum indicate which dbspace contains the table. GBase8s uses these 12 bits to locate the tblspace-tblspace of the target dbspace. A page within the tblspace tblspace describes the target table. GBase8s uses the low 20 bits of the partnum to locate the correct partition page, which contains a logical page number—essentially, the page number within the tblspace tblspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Partition Page Layout
&lt;/h2&gt;

&lt;h3&gt;
  
  
  General Overview
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza43vmgvp9yl650n55oq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza43vmgvp9yl650n55oq.png" alt="Image description" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each partition page uses the following &lt;strong&gt;5 slots&lt;/strong&gt; to describe the structure, location, and content of a table within the dbspace:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Slot 1&lt;/strong&gt;: Contains 92 bytes of general table information, including the partition number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slot 2&lt;/strong&gt;: Contains information identifying the partition by database name, table owner, table name, and NLS collation sequence (if applicable).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slot 3&lt;/strong&gt;: Contains descriptive entries for each special column in the table, representing Blob and VARCHAR types.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slot 4&lt;/strong&gt;: Contains key descriptor entries for each index key present in the table. Errors like "Illegal key descriptor: too many parts or too long" refer to issues in Slot 4 of the partition page, not the index itself. Deleting an index requires its key descriptor, so a faulty key descriptor may sometimes require intervention from GBase 8s technical support to fix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slot 5&lt;/strong&gt;: Contains extent information. Each 8-byte entry in this slot includes:

&lt;ul&gt;
&lt;li&gt;The logical page number of the first page of the extent in the tblspace (4 bytes)&lt;/li&gt;
&lt;li&gt;The page offset of the extent within the dbspace (4 bytes)&lt;/li&gt;
&lt;li&gt;This slot also includes an entry for the logical page number of the next allocated extent.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Tables can also have a &lt;strong&gt;sixth slot&lt;/strong&gt;, but it does not appear on the primary partition page of the table. The sixth slot is used to describe different versions of extents due to in-place table alterations. This slot appears on a separate page within the tblspace tblspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing Data and Metadata
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;hyqdb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;hyqdb&lt;/span&gt; &lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;LOG&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c1&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c2&lt;/span&gt; &lt;span class="nb"&gt;CHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;c3&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;i1_t1&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'001'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'v001'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'002'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'v002'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Finding the Partition Page
&lt;/h2&gt;

&lt;p&gt;You can use the &lt;code&gt;oncheck -pt database_name:table_name&lt;/code&gt; command to find all partitions related to a table. Each partition has its own information.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;t1&lt;/code&gt;, which is a non-partitioned table with a primary key index and another index, there are &lt;strong&gt;3 partitions&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The partition where the data resides.&lt;/li&gt;
&lt;li&gt;The partition where the primary key index resides.&lt;/li&gt;
&lt;li&gt;The partition where the other index resides.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@node2 ids]# oncheck &lt;span class="nt"&gt;-pt&lt;/span&gt; hyqdb:t1

TBLspace Report &lt;span class="k"&gt;for &lt;/span&gt;hyqdb:root.t1

    Physical Address               1:11862   // This address will be used later
    Creation &lt;span class="nb"&gt;date                   &lt;/span&gt;09/13/2024 11:14:56
    TBLspace Flags                  902        Row Locking
                                             TBLspace contains VARCHARS
                                              TBLspace use 4 bit bit-maps
    Maximum row size                26
    Number of special columns      1
    Number of keys                 0
    Number of extents              1
   Current serial value            1
    Current SERIAL8 value          1
    Current BIGSERIAL value        1
    Current REFID value            1
    Pagesize &lt;span class="o"&gt;(&lt;/span&gt;k&lt;span class="o"&gt;)&lt;/span&gt;                   2
    First extent size              8
    Next extent size               8
    Number of pages allocated      8
    Number of pages used           2
    Number of data pages           1
    Number of rows                 2
    Partition partnum              1049253  // This value will be used later
    Partition lockid                1049253

    Extents
         Logical Page     Physical Page        Size Physical Pages
                   0           1:13496           8          8

                 Index  100_1 fragment partition rootdbs &lt;span class="k"&gt;in &lt;/span&gt;DBspace rootdbs

    Physical Address               1:11863   // Used when displaying the primary key index
    Creation &lt;span class="nb"&gt;date                   &lt;/span&gt;09/13/2024 11:14:56
    TBLspace Flags                  802        Row Locking
                                              TBLspace use 4 bit bit-maps
    Maximum row size                26
    Number of special columns      0
    Number of keys                 1
    Number of extents              1
    Current serial value           1
    Current SERIAL8 value          1
    Current BIGSERIAL value        1
    Current REFID value            1
    Pagesize &lt;span class="o"&gt;(&lt;/span&gt;k&lt;span class="o"&gt;)&lt;/span&gt;                   2
    First extent size              4
    Next extent size               4
    Number of pages allocated      4
    Number of pages used           2
    Number of data pages           0
    Number of rows                 0
    Partition partnum               1049254
    Partition lockid                1049253

    Extents
         Logical Page     Physical Page        Size Physical Pages
                   0            1:6421           4          4

                 Index i1_t1 fragment partition rootdbs &lt;span class="k"&gt;in &lt;/span&gt;DBspace rootdbs

    Physical Address                1:11864  // Used when displaying index i1_t1
    Creation &lt;span class="nb"&gt;date                   &lt;/span&gt;09/13/2024 11:14:56
    TBLspace Flags                  802        Row Locking
                                             TBLspace use 4 bit bit-maps
    Maximum row size                26
    Number of special columns      0
    Number of keys                 1
    Number of extents              1
    Current serial value           1
    Current SERIAL8 value          1
    Current BIGSERIAL value        1
    Current REFID value            1
    Pagesize &lt;span class="o"&gt;(&lt;/span&gt;k&lt;span class="o"&gt;)&lt;/span&gt;                   2
    First extent size              7
    Next extent size               7
    Number of pages allocated      7
    Number of pages used           2
    Number of data pages           0
    Number of rows                 0
    Partition partnum               1049255
    Partition lockid                1049253

    Extents
         Logical Page     Physical Page        Size Physical Pages
                   0           1:13489           7          7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the partition number of the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;oncheck –pt 1049253
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be identical to the previous one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slot 1: The Partition Structure
&lt;/h2&gt;

&lt;p&gt;The output from the previous section consists of the partition structure (Slot 1) and the extent structure (Slot 5) of the partition page. This section describes the contents of the partition structure (in Slot 1).&lt;/p&gt;

&lt;p&gt;The partition structure is stored in the first slot of each partition page and holds general information about the corresponding table. You can view the partition structure of any table by running the following command:&lt;/p&gt;

&lt;p&gt;You might recognize some of the general tblspace information stored in the partition structure as table statistics, which are also stored in the system catalog for the optimizer to use. In fact, during some &lt;code&gt;UPDATE STATISTICS&lt;/code&gt; operations, some information from the table's partition page is copied to the system catalog, while other information must be collected by reading the tblspace pages themselves. Although the system catalog information may become outdated as the table grows and changes, the information on the partition page should always be accurate. However, the optimizer code is designed to be portable across GBase8s servers, so it does not know how to access partition pages. As far as the optimizer is concerned, the only available table statistics are those stored in the system catalog.&lt;/p&gt;

&lt;p&gt;We will now describe the contents of the partition structure in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Physical Address (decimal:decimal)
&lt;/h3&gt;

&lt;p&gt;This is the physical location of the partition page.&lt;/p&gt;

&lt;p&gt;You can display the contents of this page using &lt;code&gt;oncheck –pP&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table Data:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@node2 ids]# oncheck &lt;span class="nt"&gt;-pP&lt;/span&gt; 1 11862
addr             stamp    chksum nslots flag &lt;span class="nb"&gt;type         &lt;/span&gt;frptr frcnt next     prev
1:11862          5942545  831c    5      2    PARTN        216    1808  0        0
        slot ptr   len   flag
        1    24    136    0
        2    160   24     0
        3    184   12     0
        4    196   0      0
        5    196   20     0
slot    1:
    0: a5  2 10  0   2  9  0  0 1a  0   0  0  1  0  0   0   %...............
   16:  1  0   0  8 30 ae e3 66  1   0  0  0   8  0  0   0   ....0.cf........
   32:  8  0   0  0  8   0  0  0   1  0  0   0  0  0   0  0   ................
   48: ff ff ff ff a5  2 10  0   1  0  0   0  0  0   0  0   ....%...........
   64:  0  0   0  0  0   0  0  0  0  0   0  0  0  0   0  0   ................
   80:  0  0   0  0  0   0  0  0   0  0  0   0  1  0   0  0   ................
   96:  0  0   0  0  1   0  0  0   1  0  0   0  0  0   0  0   ................
  112:  1  0   0  0 89  0   0  0 80 d0 77  0   0  0  0   0   .........Pw.....
  128:  0  0   0  0  0   0  0  0                           ................
slot    2:
    0: 68 79 71 64 62  0 72 6f 6f 74  0 74 31  0 65 6e    hyqdb.root.t1.en
   16: 5f 55 53 2e 38 31 39  0                           _US.819.........
slot    3:
    0:  e  0   0  0  0   0  a  0   0  0  0   5               ................
slot   4:
slot   5:
   0:   0  0  0   0  0  1   0  0 34 b8  0   0  0  8   0  0   ........48......
  16:   0  0  0   0                                        ................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Primary Key Index
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@node2 ids]# oncheck &lt;span class="nt"&gt;-pP&lt;/span&gt; 1 11863
addr             stamp    chksum nslots flag &lt;span class="nb"&gt;type         &lt;/span&gt;frptr frcnt next     prev
1:11863          5942445  82a1    5      2    PARTN        244    1780  0        0
        slot ptr   len   flag
        1    24    136    0
        2    160   28     0
        3    188   0      0
        4    208   36     0
        5    188   20     0
slot    1:
    0: a6  2 10  0   2  8  0  0 1a  0   0  0  0  0  1   0   &amp;amp;...............
   16:  1  0   0  8 30 ae e3 66  1   0  0  0   4  0  0   0   ....0.cf........
   32:  4  0   0  0  4   0  0  0   2  0  0   0  0  0   0  0   ................
   48: ff ff ff ff a5  2 10  0   1  0  0   0  0  0   0  0   ....%...........
   64:  0  0   0  0  0   0  0  0   0  0  0   0  0  0   0  0   ................
   80:  0  0   0  0  0   0  0  0  0  0   0  0  1   0  0  0    ................
   96:  0  0   0  0  1   0  0  0   1  0  0   0  0  0   0  0   ................
  112:  1  0   0  0 89  0   0  0 74 d2 77  0   0  0  0   0   ........tRw.....
  128:  0  0   0  0  0   0  0  0                           ................
slot    2:
    0: 68 79 71 64 62  0 72 6f 6f 74  0 20 31 30 30 5f   hyqdb.root. 100_
   16: 31  0 65 6e 5f 55 53 2e 38 31 39  0               1.en_US.819.....
slot    3:
slot   4:
   0: 98   2  4  1   1  0  4   0  0  0   0  0 a5  2 10   0   ............%...
  16:   1  0  0   0  0  0   0  0  4   0  2  0   0  0  0   0   ................
  32:   0  0  0   0                                        ................
slot   5:
   0:   0  0  0   0  0  1   0  0 19 15  0   0  0  4   0  0   ................
  16:   0  0  0   0                                        ................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Index i1_t1
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@node2 ids]# oncheck &lt;span class="nt"&gt;-pP&lt;/span&gt; 1 11864
addr             stamp    chksum nslots flag &lt;span class="nb"&gt;type         &lt;/span&gt;frptr frcnt next     prev
1:11864          5942518  82f5    5      2    PARTN        260    1764  0        0
        slot ptr   len   flag
        1    24    136    0
        2    160   28     0
        3    188   0      0
        4    208   52     0
        5    188   20     0
slot    1:
    0: a7  2 10  0   2  8  0  0 1a  0   0  0  0  0  1   0   &lt;span class="s1"&gt;'...............
   16:  1  0   0  8 30 ae e3 66  1   0  0  0   7  0  0   0   ....0.cf........
   32:  7  0   0  0  7   0  0  0   2  0  0   0  0  0   0  0   ................
   48: ff ff ff ff a5  2 10  0   1  0  0   0  0  0   0  0   ....%...........
   64:  0  0   0  0  0   0  0  0   0  0  0   0  0  0   0  0   ................
   80:  0  0   0  0  0   0  0  0   0  0  0   0  1  0   0  0   ................
   96:  0  0   0  0  1   0  0  0   1  0  0   0  0  0   0  0   ................
  112:  1  0   0  0 89  0   0  0 50  0 78   0  0  0   0  0   ........P.x.....
  128:  0  0   0  0  0   0  0  0                           ................
slot    2:
    0: 68 79 71 64 62  0 72 6f 6f 74  0 69 31 5f 74 31   hyqdb.root.i1_t1
   16:  0 65 6e 5f 55 53 2e 38 31 39  0 49               .en_US.819.I....
slot    3:
slot    4:
    0:  1  2   0  1  2  0 16  0   0  0  0  0 a5  2 10  0    ............%...
   16:  1  0   0  0  4   0  0  0   a  0  0   0  0  0   0  0   ................
   32:  0  0   0  0  e   0  0  0   c  0  5   0  0  0   0  0   ................
   48:  0  0   0  0                                        ................
slot    5:
    0:  0   0  0  0   0  1  0  0 34 b1  0  0   0  7  0   0   ........41......
  16:   0  0  0   0                                        ................
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creation date
&lt;/h3&gt;

&lt;p&gt;This is the date and time when the table was created.&lt;/p&gt;

&lt;h3&gt;
  
  
  TBLSpace Flags (decimal)
&lt;/h3&gt;

&lt;p&gt;These flags are operated similarly to page flags, dbspace flags, and block flags, and are combined into an integer through logical OR. Each tblspace flag has the following values and meanings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0x0001: Page-level locking&lt;/li&gt;
&lt;li&gt;0x0002: Row-level locking&lt;/li&gt;
&lt;li&gt;0x0004: Tblspace is Bundlespace (online security)&lt;/li&gt;
&lt;li&gt;0x0008: Marked as DDR replicated partition&lt;/li&gt;
&lt;li&gt;0x0010: Partition is deleted (shared memory only)&lt;/li&gt;
&lt;li&gt;0x0020: System-defined temporary table&lt;/li&gt;
&lt;li&gt;0x0040: User-defined temporary table&lt;/li&gt;
&lt;li&gt;0x0080: Tblspace used for sorting&lt;/li&gt;
&lt;li&gt;0x0100: Contains VARCHAR columns&lt;/li&gt;
&lt;li&gt;0x0200: Contains BLOB space BLOB columns&lt;/li&gt;
&lt;li&gt;0x0400: Contains BLOB columns resident in the partition&lt;/li&gt;
&lt;li&gt;0x0800: Requires 4-bit bitmap&lt;/li&gt;
&lt;li&gt;0x1000: Contains optical BLOB columns&lt;/li&gt;
&lt;li&gt;0x2000: Partition required for system operation - do not delete&lt;/li&gt;
&lt;li&gt;0x4000: Temporary table used for special functions - do not update&lt;/li&gt;
&lt;li&gt;0x8000: Partition is being appended to&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Maximum row size (decimal)
&lt;/h3&gt;

&lt;p&gt;For tables with fixed row lengths, this value is simply the row size in bytes. The concept of maximum row size is only required when a tblspace contains VARCHAR columns. Remember that VARCHAR columns define minimum and maximum sizes in characters, which correspond to bytes. The maximum size of a VARCHAR column, plus the 2-byte overhead (for storing the actual size of the VARCHAR data), and the sizes of other columns in the schema, form the maximum row size.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of special columns (decimal)
&lt;/h3&gt;

&lt;p&gt;BLOB and VARCHAR columns are considered special and are exclusive column types in GBase 8s.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of keys (decimal)
&lt;/h3&gt;

&lt;p&gt;The total number of indexes defined for the table. Composite indexes can consist of several columns but are still counted as a single index key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of extents (decimal)
&lt;/h3&gt;

&lt;p&gt;The number of individual data blocks allocated to the table. The number of extents tends to remain low due to GBase 8s admin extensions and good tblspace management. As the number of data blocks in tblspace increases, not only does data become unpredictably dispersed (causing performance issues with sequential reads), but extension slots on the partition page also increase. Data block slots can only contain so many entries before space runs out. Since other slots on partition pages (like slot 4) can also grow dynamically, the exact maximum number of tblspace extension data blocks cannot be predicted with precision. Verified evidence suggests that the maximum number of extents on a 2K page is about 190.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current serial value (decimal)
&lt;/h3&gt;

&lt;p&gt;Tblspace can only contain one serial-type column. If it exists, this is the next value used for insertions. If there is no serial column in the table, this value remains 1.&lt;/p&gt;

&lt;p&gt;Serial-related types include: serial, serial8, bigserial.&lt;/p&gt;

&lt;h3&gt;
  
  
  First extent size (decimal)
&lt;/h3&gt;

&lt;p&gt;This is the configured EXTENT SIZE, measured in pages of GBase 8s. The unit here may be confusing because the EXTENT SIZE can be specified in kilobytes through SQL.&lt;/p&gt;

&lt;p&gt;The default EXTENT SIZE is 8 pages, independent of page size. The minimum extent size is 4 pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next extent size (decimal)
&lt;/h3&gt;

&lt;p&gt;This is the configured NEXT SIZE, also measured in pages of GBase 8s. Note that at the SQL level, NEXT SIZE is specified in kilobytes, so the value here is initially half or a quarter of the number specified in the SQL NEXT SIZE clause.&lt;/p&gt;

&lt;p&gt;Since data block sizes double, the next data block size may increase over time. Unless the table is intentionally changed, the size will never decrease. The default value for the next data block size is 8 pages. The minimum extent size is 4 pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of pages allocated (decimal)
&lt;/h3&gt;

&lt;p&gt;This is the total number of pages contained within the extended data blocks allocated to the tblspace, regardless of usage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of pages used (decimal)
&lt;/h3&gt;

&lt;p&gt;This is the total number of pages that have been used within the tblspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of data pages (decimal)
&lt;/h3&gt;

&lt;p&gt;This is the number of data pages currently in use in the tblspace. When all rows are removed from a data page, it will be released to be reused within the tblspace, and the partition structure's data page count will decrease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of rows (decimal)
&lt;/h3&gt;

&lt;p&gt;This indicates the number of rows in the tblspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Partition partnum (decimal)
&lt;/h3&gt;

&lt;p&gt;This indicates the partition number of the tblspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Partition lockid
&lt;/h3&gt;

&lt;p&gt;In the past, when you locked a table, you were actually locking a partition number. This worked as long as there was a one-to-one correspondence between database tables and partition numbers. However, partitioned tables allow many partitions to be associated with a single database table. GBase 8s uses this lockid value to represent all table fragments, rather than associating each partition number with a single table lock.&lt;/p&gt;

&lt;h3&gt;
  
  
  Slot 2: partition name
&lt;/h3&gt;

&lt;p&gt;In slot 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0: 68 79 71 64 62 0 72 6f 6f 74 0 74 31 0 65 6e hyqdb.root.t1.en
16: 5f 55 53 2e 38 31 39 0 _US.819.........
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PT_NAME in slot 2 is divided by &lt;code&gt;'\0'&lt;/code&gt; into four pieces of information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dbsname&lt;/li&gt;
&lt;li&gt;owner&lt;/li&gt;
&lt;li&gt;tabname&lt;/li&gt;
&lt;li&gt;nlscollname&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Slot 3: column descriptors
&lt;/h3&gt;

&lt;p&gt;In slot 3:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0: e 0 0 0 e 0 a 0 0 0 0 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The details for each byte are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;e 0 0 0&lt;/code&gt;: &lt;code&gt;e&lt;/code&gt; in hexadecimal (14) represents the offset of this column within the row.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a 0&lt;/code&gt;: This indicates that the maximum length of the VARCHAR field is 10 bytes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;0 0&lt;/code&gt;: This indicates the minimum length of the VARCHAR field is 0 bytes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;5&lt;/code&gt;: The base data type (5 represents VARCHAR).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Slot 4: key descriptors
&lt;/h3&gt;

&lt;p&gt;For the primary key corresponding to the partition partition page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    0: 98   2  4  1   1  0  4   0  0  0   0  0 a5  2 10   0   ............%...
   16:   1  0  0   0  0  0   0  0  4   0  2  0   0  0  0   0   ................
   32:   0  0  0   0                                        ................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the &lt;code&gt;i1_t1&lt;/code&gt; partition partition page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    0:   1  2  0   1  2  0 16   0  0  0   0  0 a5  2 10   0   ............%...
   16:   1  0  0   0  4  0   0  0  a   0  0  0   0  0  0   0   ................
   32:   0  0  0   0  e  0   0  0  c   0  5  0   0  0  0   0   ................
   48:   0  0  0   0                                       ................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Slot 5: The Extent Slot
&lt;/h3&gt;

&lt;p&gt;Using &lt;code&gt;oncheck -pt hyqdb:t1&lt;/code&gt;, the content displayed for each partition's final section represents extent-related information. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Extents
  Logical Page     Physical Page        Size Physical Pages
  0               1:13496             8           8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This represents the physical starting position of the data and the number of pages.&lt;/p&gt;

&lt;p&gt;According physical address displayed data part (Note: need to jump the bitmap page, so use 1 13497)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@node2 ids]# oncheck -pP 1 13497
addr             stamp    chksum nslots flag type         frptr frcnt next     prev
1:13497          5942555  99f9    2      1    DATA         64     1972  0        0
       slot ptr   len    flag
       1     24    20    0
       2     44    20    0
slot   1:
   0:   0  0  0  1 30 30 31 20 20 20 20 20 20 20  0  4    ....001       ..
  16: 76 30 30 31                                       v001............
slot   2:
   0:   0  0  0  2 30 30 32 20 20 20 20 20 20 20  0  4    ....002       ..
  16: 76 30 30 32                                        v002............
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Slot 6: Page Versioning (In-Place-Alter Required)
&lt;/h3&gt;

&lt;p&gt;When performing an In-Place-Alter, this slot tracks which version of metadata the data is based on.&lt;/p&gt;

&lt;p&gt;"In-Place-Alter" means modifying the table without immediately updating the data. Data is updated when it changes in the future. During this process, the data will have different metadata versions, and this slot records that version.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Through the analysis of Partition Pages in GBase 8s (GBase数据库), we have not only understood the definition, role, structure, and composition of partition pages, but also mastered their creation, management, and practical applications. Partition pages, as a key data storage structure in GBase 8s, play an important role in improving database storage efficiency, optimizing query performance, and simplifying data maintenance. In the future of database technology development, the application and optimization of partition pages will remain a key research focus. We hope this article provides valuable reference and inspiration to database professionals and enthusiasts, and together, we can explore the infinite possibilities of database technology.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE数据库 | GBase 8c Remote Backup and Restore Practice</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Fri, 07 Feb 2025 05:46:25 +0000</pubDate>
      <link>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8c-remote-backup-and-restore-practice-5f1j</link>
      <guid>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8c-remote-backup-and-restore-practice-5f1j</guid>
      <description>&lt;p&gt;GBase 8c database (GBase数据库) allows users to perform full and incremental backups and restores of clusters via a backup server. It also provides the built-in &lt;code&gt;gs_probackup&lt;/code&gt; tool for remote backup and restore operations, supporting flexible backup strategies such as incremental backups, scheduled backups, and remote backups and restores.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;gs_probackup&lt;/code&gt; tool is used to manage backup and recovery for GBase 8c databases. With this tool, regular backups can be scheduled to ensure that data is recoverable in case of network or machine failures. In addition to backing up the data in the database, it can also back up external directories, such as script files, configuration files, log files, and dumps. This article primarily focuses on configuring a remote backup strategy for GBase 8c databases using the &lt;code&gt;gs_probackup&lt;/code&gt; tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  0. Environment Setup
&lt;/h2&gt;

&lt;p&gt;In this example, based on &lt;code&gt;gs_probackup&lt;/code&gt;, the GBase 8c database cluster is backed up to a standby server and restored to a specified directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environment Information:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database server IP: &lt;code&gt;172.16.71.58&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Backup server IP: &lt;code&gt;172.16.200.108&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Backup Deployment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;(1) Configure Passwordless SSH Login for the &lt;code&gt;gbase&lt;/code&gt; System User Between the Database and Backup Servers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the database server &lt;code&gt;172.16.71.58&lt;/code&gt;, log in and configure passwordless login:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-copy-id &lt;span class="nt"&gt;-i&lt;/span&gt; gbase@172.16.200.108
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;On the backup server &lt;code&gt;172.16.200.108&lt;/code&gt;, log in and configure passwordless login:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@ZSC-GB8C-NODE1 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-copy-id &lt;span class="nt"&gt;-i&lt;/span&gt; gbase@172.16.71.58
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(2) Modify Database Parameters and Configure Archive Log Directory&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the database server &lt;code&gt;172.16.71.58&lt;/code&gt;, modify the parameters:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_guc reload &lt;span class="nt"&gt;-N&lt;/span&gt; all &lt;span class="nt"&gt;-I&lt;/span&gt; all &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"archive_mode=on"&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_guc reload &lt;span class="nt"&gt;-N&lt;/span&gt; all &lt;span class="nt"&gt;-I&lt;/span&gt; all &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"archive_timeout=1800"&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_guc reload &lt;span class="nt"&gt;-N&lt;/span&gt; all &lt;span class="nt"&gt;-I&lt;/span&gt; all &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"archive_command = 'scp %p gbase@172.16.200.108:/data/mpp/backup/zhck/archive_dir/%f'"&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_guc reload &lt;span class="nt"&gt;-N&lt;/span&gt; all &lt;span class="nt"&gt;-I&lt;/span&gt; all &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"enable_cbm_tracking=on"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;archive_mode&lt;/code&gt;: Determines whether archiving is enabled.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Possible values: &lt;code&gt;on&lt;/code&gt; (enable), &lt;code&gt;off&lt;/code&gt; (disable)&lt;/li&gt;
&lt;li&gt;Default: &lt;code&gt;off&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;archive_timeout&lt;/code&gt;: Defines the archive timeout period.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Range: Integer (0–1073741823) in seconds. &lt;code&gt;0&lt;/code&gt; disables this feature.&lt;/li&gt;
&lt;li&gt;Default: &lt;code&gt;0&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;archive_command&lt;/code&gt;: Defines the archive WAL log command. It is recommended to use an absolute path.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default: &lt;code&gt;disabled&lt;/code&gt; (feature disabled)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;enable_cbm_tracking&lt;/code&gt;: This parameter must be enabled for incremental backups. Disabling it can cause backup failure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Possible values: &lt;code&gt;on&lt;/code&gt; (enable tracking), &lt;code&gt;off&lt;/code&gt; (disable tracking)&lt;/li&gt;
&lt;li&gt;Default: &lt;code&gt;off&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;(3) Enable Remote Database Access on the Backup Server&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the database server &lt;code&gt;172.16.71.58&lt;/code&gt;, enable remote access for the backup server:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_guc reload &lt;span class="nt"&gt;-N&lt;/span&gt; all &lt;span class="nt"&gt;-I&lt;/span&gt; all &lt;span class="nt"&gt;-h&lt;/span&gt; &lt;span class="s2"&gt;"host replication all 172.16.200.108/32 md5"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(4) Create and Grant Backup User Permissions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the backup server &lt;code&gt;172.16.200.108&lt;/code&gt;, test the database login and create a backup user:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 ~]&lt;span class="nv"&gt;$ &lt;/span&gt;gsql &lt;span class="nt"&gt;-d&lt;/span&gt; postgres &lt;span class="nt"&gt;-h&lt;/span&gt; 172.16.71.58
  &lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# create user dba with password 'gbase,123' sysadmin;&lt;/span&gt;
  &lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# grant all privileges to dba;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(5) Create Archive Directory on the Backup Server&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the backup server &lt;code&gt;172.16.200.108&lt;/code&gt;, create the backup archive directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /data/mpp/backup/zhck/iicp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(6) Initialize Backup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Switch to the &lt;code&gt;gbase&lt;/code&gt; user and initialize the backup directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup init &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add a backup instance and generate the &lt;code&gt;pg_probackup.conf&lt;/code&gt; configuration file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup add-instance &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;-D&lt;/span&gt; /home/gbase/data/dn1 &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--remote-host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;172.16.71.58 &lt;span class="nt"&gt;--remote-user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Set retention policy for backups (e.g., 30 days):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup set-config &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--retention-redundancy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30 &lt;span class="nt"&gt;--retention-window&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(7) Full Backup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform a full backup:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup backup &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;-b&lt;/span&gt; FULL &lt;span class="nt"&gt;-h&lt;/span&gt; 172.16.71.58 &lt;span class="nt"&gt;-p&lt;/span&gt; 15432 &lt;span class="nt"&gt;-U&lt;/span&gt; gbase &lt;span class="nt"&gt;-W&lt;/span&gt; &lt;span class="s1"&gt;'gbase,123'&lt;/span&gt; &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--delete-expired&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; postgres &lt;span class="nt"&gt;--remote-host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;172.16.71.58 &lt;span class="nt"&gt;--remote-user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(8) Incremental Backup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform an incremental backup:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck
  &lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup backup &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;-b&lt;/span&gt; PTRACK &lt;span class="nt"&gt;-h&lt;/span&gt; 172.16.71.58 &lt;span class="nt"&gt;-p&lt;/span&gt; 15432 &lt;span class="nt"&gt;-U&lt;/span&gt; gbase &lt;span class="nt"&gt;-W&lt;/span&gt; &lt;span class="s1"&gt;'gbase,123'&lt;/span&gt; &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--delete-expired&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; postgres &lt;span class="nt"&gt;--remote-host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;172.16.71.58 &lt;span class="nt"&gt;--remote-user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Data Recovery in GBase 8c Database
&lt;/h2&gt;

&lt;p&gt;In this example, we recover data to a separate directory on the current host. In a production environment, if the cluster experiences incorrect operations or data corruption due to other factors, it is not recommended to perform the recovery directly on the original cluster. This could potentially cause secondary damage to the database. It is advised to restore data to another node, verify the data, and then import the data back into the production cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Full Recovery
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;(1) View the Backup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup show &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View the backup as shown in the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnki9i95pq5crfzaiw672.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnki9i95pq5crfzaiw672.png" alt="Image description" width="800" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(2) Create a Recovery Directory on the Database Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is recommended to restore the backup to a different server, such as a pre-release or near-production environment.&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt; and create a recovery directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;mkdir&lt;/span&gt; /data/mpp/backup/zhck/restore_test &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(3) Restore to a Full Backup at &lt;code&gt;2024-12-04 19:04:47&lt;/code&gt; on Database Server &lt;code&gt;172.16.71.58&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup restore &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;-D&lt;/span&gt; /data/mpp/backup/zhck/restore_test &lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;SNYUPG &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--remote-host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;172.16.71.58 &lt;span class="nt"&gt;--remote-user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following information will be returned:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzgytkrxr19ue9laxu4v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzgytkrxr19ue9laxu4v.png" alt="Image description" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(4) Change the Database Port to Avoid Conflicts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck/restore_test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the port in the configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 restore_test]&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;postgresql.conf
...
port &lt;span class="o"&gt;=&lt;/span&gt; 15432
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(5) Start the Database&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 restore_test]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_ctl start &lt;span class="nt"&gt;-D&lt;/span&gt; /data/mpp/backup/zhck/restore_test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following information will be returned:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nfexhtbub0aodgntdny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nfexhtbub0aodgntdny.png" alt="Image description" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(6) Log in to the Database to Verify the Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 restore_test]&lt;span class="nv"&gt;$ &lt;/span&gt;gsql &lt;span class="nt"&gt;-d&lt;/span&gt; postgres &lt;span class="nt"&gt;-p&lt;/span&gt; 15432 &lt;span class="nt"&gt;-r&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eyplh95jg0esb0nkbfc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eyplh95jg0esb0nkbfc.png" alt="Image description" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Point-in-Time Incremental Recovery
&lt;/h3&gt;

&lt;p&gt;Similarly, restore to a separate directory on the current host. In production environments, data recovery should not be performed directly on the original cluster, as this may lead to further damage. It is advisable to restore the data to another node, verify it, and then import the data into the production cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(1) View the Backup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# gs_probackup show &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View the backup as shown in the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjfrmqgtx4qruhlrtll1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjfrmqgtx4qruhlrtll1q.png" alt="Image description" width="800" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(2) Merge Incremental Backup &lt;code&gt;SNYUUR&lt;/code&gt; to &lt;code&gt;SNYUPG&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 zhck]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_probackup merge &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;-i&lt;/span&gt; SNYUUR &lt;span class="nt"&gt;--progres&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(3) Copy the Archive Logs to the Backup's WAL Directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This step may be required depending on your backup configuration. If the WAL archive directory is already set to archive to the physical backup's WAL directory, you can skip this step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 gbase_zhck]&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; /data/mpp/backup/zhck/archive_dir/&lt;span class="k"&gt;*&lt;/span&gt; /data/mpp/backup/zhck/iicp/wal/gbase_zhck/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(4) View the Backup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgio0dobggyxuq4esd6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgio0dobggyxuq4esd6s.png" alt="Image description" width="800" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(5) Restore to the Specific Time Point &lt;code&gt;2024-12-04 19:00:00&lt;/code&gt; on the Database Server &lt;code&gt;172.16.71.58&lt;/code&gt; to the &lt;code&gt;/data/mpp/backup/zhck/restore_test&lt;/code&gt; Directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 zhck]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_probackup restore &lt;span class="nt"&gt;-B&lt;/span&gt; /data/mpp/backup/zhck/iicp &lt;span class="nt"&gt;-D&lt;/span&gt; /data/mpp/backup/zhck/restore_test &lt;span class="nt"&gt;--instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase_zhck &lt;span class="nt"&gt;--remote-host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;172.16.71.58 &lt;span class="nt"&gt;--remote-user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gbase &lt;span class="nt"&gt;--recovery-target-time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'2024-12-04 19:00:00'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(6) Change the Database Port to Avoid Conflicts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@gbase8c-iicp-db01 ~]# su - gbase
&lt;span class="o"&gt;[&lt;/span&gt;gbase@ZSC-GB8C-NODE1 ~]# &lt;span class="nb"&gt;cd&lt;/span&gt; /data/mpp/backup/zhck/restore_test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the port in the configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 restore_test]&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;postgresql.conf
...
port &lt;span class="o"&gt;=&lt;/span&gt; 15432
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(7) Start the Database&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;gbase@gbase8c-iicp-db01 restore_test]&lt;span class="nv"&gt;$ &lt;/span&gt;gs_ctl start &lt;span class="nt"&gt;-D&lt;/span&gt; /data/mpp/backup/zhck/restore_test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(8) Log in to the Database to Verify the Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to the database server &lt;code&gt;172.16.71.58&lt;/code&gt;. Once data verification is complete, the recovery is finished.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In summary, GBase 8c's backup and recovery functions play a critical role in ensuring data security and reliability. To meet the diverse needs of users and different scenarios, the product offers flexible backup strategies and media options. By choosing GBase 8c, users can enjoy the benefits of its backup and recovery features, ensuring data security, reliability, and the stable operation of the database system.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE数据库 | GBase 8a Cluster Automated Installation and Deployment Using ansible</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Fri, 07 Feb 2025 02:30:34 +0000</pubDate>
      <link>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-cluster-automated-installation-and-deployment-using-ansible-a98</link>
      <guid>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-cluster-automated-installation-and-deployment-using-ansible-a98</guid>
      <description>&lt;p&gt;In this article, we will guide you through the process of automating the installation and deployment of a GBase 8a cluster using Ansible. This solution simplifies the deployment of the GBase 8a database (GBase数据库) in a cluster environment, making it easier to manage and scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  Host Configuration
&lt;/h3&gt;

&lt;p&gt;An example configuration is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[all]&lt;/span&gt;
&lt;span class="err"&gt;192.168.56.3&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;coor RoleId=1 vc_name='' private_ip1=192.168.56.3 private_ip2=192.168.56.3 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.4&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;newcoor RoleId=1 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.5&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;newnode RoleId=2 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.6&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;node RoleId=1 vc_name=vc2 private_ip1=192.168.56.4 private_ip2=192.168.56.6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;192.168.56.3&lt;/code&gt;: Business network IP&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gbaseRole&lt;/code&gt;: The role of GBase (management node: &lt;code&gt;coor&lt;/code&gt;, compute node: &lt;code&gt;node&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RoleId&lt;/code&gt;: Role ID, fill in sequentially&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vc_name&lt;/code&gt;: Virtual Cluster name for compute nodes, leave empty for management nodes, set to &lt;code&gt;data&lt;/code&gt; in compatibility mode&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;private_ip1&lt;/code&gt;: Private network IP address 1 for compute nodes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;private_ip2&lt;/code&gt;: Private network IP address 2 for compute nodes (not required for single-instance setups)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Variables Explanation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# GBase installation package name&lt;/span&gt;
&lt;span class="na"&gt;gbase_setup_file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;xxxx.tar.bz2'&lt;/span&gt;
&lt;span class="c1"&gt;# Operating system root password&lt;/span&gt;
&lt;span class="na"&gt;root_passwd&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# GBase password for the operating system&lt;/span&gt;
&lt;span class="na"&gt;gbase_passwd&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# Database DBA user (root, gbase) password&lt;/span&gt;
&lt;span class="na"&gt;dba_password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# Database character set (utf8, utf8mb4, gbk, etc.)&lt;/span&gt;
&lt;span class="na"&gt;db_charset&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;utf8&lt;/span&gt;
&lt;span class="na"&gt;vc_lists&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;vc1'&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;span class="c1"&gt;# Management node ID list, generally recommended to be the IP address's last segment, separated by commas&lt;/span&gt;
&lt;span class="na"&gt;coorHostNodeIDlist&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1,2,3'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Task Descriptions
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Initial Installation Preparation
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install necessary RPM packages&lt;/span&gt;
  &lt;span class="na"&gt;yum&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;name={{ item }} state=installed&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bzip2&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;expect&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcc&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*cgroup*'&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bc&lt;/span&gt;  
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;numactl&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;rsync&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload GBase installation package&lt;/span&gt;
  &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;files/{{ gbase_setup_file }}&lt;/span&gt; 
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Extract GBase installation package&lt;/span&gt;
  &lt;span class="na"&gt;unarchive&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/{{ gbase_setup_file }}&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/&lt;/span&gt;
    &lt;span class="na"&gt;remote_src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create GBase user&lt;/span&gt;
  &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
    &lt;span class="na"&gt;update_password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase_passwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;password_hash('sha512') }}'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Change ownership of /opt directory&lt;/span&gt;
  &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;directory&lt;/span&gt;
    &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;recurse&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload system environment variable initialization script&lt;/span&gt;
  &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SetSysEnv.py&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize system environment variables&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/tmp/SetSysEnv.py&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--dbaUser=gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--installPrefix=/opt&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--cgroup'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Installation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate installation configuration file&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;demo.options.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gbase_workspace/setup/gcinstall/demo.options&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;InstanceType&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;           
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;demo.options.j2&lt;/code&gt; Template:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;installPrefix&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
&lt;span class="py"&gt;coordinateHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;coordinateHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dataHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='node'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dbaUser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaGroup&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ gbase_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;rootPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ root_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;characterSet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ db_charset }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Environment Installation and Deployment
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install and deploy GBase&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sh&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;ansible_install.sh'&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;ansible_install.sh&lt;/code&gt; Script:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;###########################################################&lt;/span&gt;
&lt;span class="c"&gt;##creator :                                               &lt;/span&gt;
&lt;span class="c"&gt;##create time:                                       &lt;/span&gt;
&lt;span class="c"&gt;##Description: Silent installation script&lt;/span&gt;
&lt;span class="c"&gt;##Version:                                            &lt;/span&gt;
&lt;span class="c"&gt;###########################################################&lt;/span&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; /opt/gcinstall
spawn python gcinstall.py &lt;span class="nt"&gt;--silent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;demo.options &lt;span class="nt"&gt;-i&lt;/span&gt;
expect &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"*])?"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;send &lt;span class="s2"&gt;"y&lt;/span&gt;&lt;span class="se"&gt;\r&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; exp_continue&lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="s2"&gt;"*])?"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;send &lt;span class="s2"&gt;"y&lt;/span&gt;&lt;span class="se"&gt;\r&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; exp_continue&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Re-initialize System Environment Variables
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Reinitialize system environment variables&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/tmp/SetSysEnv.py&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--dbaUser=gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--installPrefix=/opt&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--cgroup'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate VC Creation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate VC creation configuration file&lt;/span&gt;
  &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;createvc.xml.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gcinstall/createvc_{{ item }}.xml&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;          
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;createvc.xml.j2&lt;/code&gt; Template:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version='1.0' encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;servers&amp;gt;&lt;/span&gt;

{% for host in groups['all'] %}
{% if hostvars[host]['vc_name']==cur_vcname %}
    &lt;span class="nt"&gt;&amp;lt;rack&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;node&lt;/span&gt; &lt;span class="na"&gt;ip=&lt;/span&gt;&lt;span class="s"&gt;"{{ hostvars[host]['private_ip1'] }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/rack&amp;gt;&lt;/span&gt;
{% endif %}
{% endfor %}

    &lt;span class="nt"&gt;&amp;lt;vc_name&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"{{ cur_vcname }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;comment&lt;/span&gt; &lt;span class="na"&gt;message=&lt;/span&gt;&lt;span class="s"&gt;"{{ cur_vcname }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/servers&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create VC
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create VC&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;cd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/opt/gcinstall;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcadmin&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;createvc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;createvc_{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}.xml'&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Distribution Creation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate initialization configuration file&lt;/span&gt;
  &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcChangeInfo_vcname.xml.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gcinstall/gcChangeInfo_{{ item }}.xml&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;          
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Configuration File Template for Creating Distribution (&lt;code&gt;gcChangeInfo_vcname.xml.j2&lt;/code&gt;)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;installPrefix&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
&lt;span class="py"&gt;coordinateHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;coordinateHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dataHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='node'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="c"&gt;#existCoordinateHost =
#existDataHost =
#existGcwareHost=
&lt;/span&gt;&lt;span class="py"&gt;gcwareHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dbaUser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaGroup&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ gbase_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;rootPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ root_passwd }}'&lt;/span&gt;
&lt;span class="c"&gt;#dbRootPwd = ''
#rootPwdFile = rootPwd.json
&lt;/span&gt;&lt;span class="py"&gt;characterSet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ db_charset }}&lt;/span&gt;
&lt;span class="c"&gt;#sshPort = 22
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create Distribution
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize distribution for VC (multi-VC mode)&lt;/span&gt;
    &lt;span class="s"&gt;shell&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;cd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/opt/gcinstall;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcadmin&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;distribution&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcChangeInfo_{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}.xml&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;d&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;db_user&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;db_pwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'gbase20110531'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;dba_os_password&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase_passwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
    &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s"&gt;install&lt;/span&gt;
    &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Initialize nodedatamap
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize nodedatamap for VC&lt;/span&gt;
    &lt;span class="s"&gt;vars&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gccli&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-ugbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-pgbase20110531&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-e"use&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}};&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;initnodedatamap;"'&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
    &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s"&gt;install&lt;/span&gt;    
    &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By automating the installation and deployment of GBase 8a clusters (GBase数据库) with Ansible, you can significantly reduce manual intervention and increase the efficiency of your database environment. This method is particularly useful for large-scale deployments and environments where consistency is crucial.&lt;/p&gt;

&lt;p&gt;If you have any questions or need further clarification, feel free to reach out in the comments or via direct messages.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>GBASE数据库 | GBase 8a Cluster Automated Installation and Deployment Using ansible</title>
      <dc:creator>GBASE Database</dc:creator>
      <pubDate>Fri, 07 Feb 2025 02:30:34 +0000</pubDate>
      <link>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-cluster-automated-installation-and-deployment-using-ansible-235e</link>
      <guid>https://dev.to/generaldata/gbaseshu-ju-ku-gbase-8a-cluster-automated-installation-and-deployment-using-ansible-235e</guid>
      <description>&lt;p&gt;In this article, we will guide you through the process of automating the installation and deployment of a GBase 8a cluster using Ansible. This solution simplifies the deployment of the GBase 8a database (GBase数据库) in a cluster environment, making it easier to manage and scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  Host Configuration
&lt;/h3&gt;

&lt;p&gt;An example configuration is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[all]&lt;/span&gt;
&lt;span class="err"&gt;192.168.56.3&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;coor RoleId=1 vc_name='' private_ip1=192.168.56.3 private_ip2=192.168.56.3 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.4&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;newcoor RoleId=1 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.5&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;newnode RoleId=2 vc_name=vc1 private_ip1=192.168.56.4 private_ip2=192.168.56.6 &lt;/span&gt;
&lt;span class="err"&gt;192.168.56.6&lt;/span&gt; &lt;span class="py"&gt;gbaseRole&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;node RoleId=1 vc_name=vc2 private_ip1=192.168.56.4 private_ip2=192.168.56.6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;192.168.56.3&lt;/code&gt;: Business network IP&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gbaseRole&lt;/code&gt;: The role of GBase (management node: &lt;code&gt;coor&lt;/code&gt;, compute node: &lt;code&gt;node&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RoleId&lt;/code&gt;: Role ID, fill in sequentially&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vc_name&lt;/code&gt;: Virtual Cluster name for compute nodes, leave empty for management nodes, set to &lt;code&gt;data&lt;/code&gt; in compatibility mode&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;private_ip1&lt;/code&gt;: Private network IP address 1 for compute nodes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;private_ip2&lt;/code&gt;: Private network IP address 2 for compute nodes (not required for single-instance setups)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Variables Explanation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# GBase installation package name&lt;/span&gt;
&lt;span class="na"&gt;gbase_setup_file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;xxxx.tar.bz2'&lt;/span&gt;
&lt;span class="c1"&gt;# Operating system root password&lt;/span&gt;
&lt;span class="na"&gt;root_passwd&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# GBase password for the operating system&lt;/span&gt;
&lt;span class="na"&gt;gbase_passwd&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# Database DBA user (root, gbase) password&lt;/span&gt;
&lt;span class="na"&gt;dba_password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;111111'&lt;/span&gt;
&lt;span class="c1"&gt;# Database character set (utf8, utf8mb4, gbk, etc.)&lt;/span&gt;
&lt;span class="na"&gt;db_charset&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;utf8&lt;/span&gt;
&lt;span class="na"&gt;vc_lists&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;vc1'&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;span class="c1"&gt;# Management node ID list, generally recommended to be the IP address's last segment, separated by commas&lt;/span&gt;
&lt;span class="na"&gt;coorHostNodeIDlist&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1,2,3'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Task Descriptions
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Initial Installation Preparation
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install necessary RPM packages&lt;/span&gt;
  &lt;span class="na"&gt;yum&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;name={{ item }} state=installed&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bzip2&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;expect&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcc&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*cgroup*'&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bc&lt;/span&gt;  
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;numactl&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;rsync&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload GBase installation package&lt;/span&gt;
  &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;files/{{ gbase_setup_file }}&lt;/span&gt; 
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Extract GBase installation package&lt;/span&gt;
  &lt;span class="na"&gt;unarchive&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/{{ gbase_setup_file }}&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/&lt;/span&gt;
    &lt;span class="na"&gt;remote_src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create GBase user&lt;/span&gt;
  &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
    &lt;span class="na"&gt;update_password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase_passwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;password_hash('sha512') }}'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Change ownership of /opt directory&lt;/span&gt;
  &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;directory&lt;/span&gt;
    &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
    &lt;span class="na"&gt;recurse&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload system environment variable initialization script&lt;/span&gt;
  &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SetSysEnv.py&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize system environment variables&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/tmp/SetSysEnv.py&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--dbaUser=gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--installPrefix=/opt&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--cgroup'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Installation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate installation configuration file&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;demo.options.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gbase_workspace/setup/gcinstall/demo.options&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;InstanceType&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;           
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;demo.options.j2&lt;/code&gt; Template:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;installPrefix&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
&lt;span class="py"&gt;coordinateHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;coordinateHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dataHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='node'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dbaUser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaGroup&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ gbase_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;rootPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ root_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;characterSet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ db_charset }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Environment Installation and Deployment
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install and deploy GBase&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sh&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;ansible_install.sh'&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;ansible_install.sh&lt;/code&gt; Script:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;###########################################################&lt;/span&gt;
&lt;span class="c"&gt;##creator :                                               &lt;/span&gt;
&lt;span class="c"&gt;##create time:                                       &lt;/span&gt;
&lt;span class="c"&gt;##Description: Silent installation script&lt;/span&gt;
&lt;span class="c"&gt;##Version:                                            &lt;/span&gt;
&lt;span class="c"&gt;###########################################################&lt;/span&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; /opt/gcinstall
spawn python gcinstall.py &lt;span class="nt"&gt;--silent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;demo.options &lt;span class="nt"&gt;-i&lt;/span&gt;
expect &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"*])?"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;send &lt;span class="s2"&gt;"y&lt;/span&gt;&lt;span class="se"&gt;\r&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; exp_continue&lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="s2"&gt;"*])?"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;send &lt;span class="s2"&gt;"y&lt;/span&gt;&lt;span class="se"&gt;\r&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; exp_continue&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Re-initialize System Environment Variables
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Reinitialize system environment variables&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/tmp/SetSysEnv.py&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--dbaUser=gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--installPrefix=/opt&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--cgroup'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;init_env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate VC Creation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate VC creation configuration file&lt;/span&gt;
  &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;createvc.xml.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gcinstall/createvc_{{ item }}.xml&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;          
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;code&gt;createvc.xml.j2&lt;/code&gt; Template:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version='1.0' encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;servers&amp;gt;&lt;/span&gt;

{% for host in groups['all'] %}
{% if hostvars[host]['vc_name']==cur_vcname %}
    &lt;span class="nt"&gt;&amp;lt;rack&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;node&lt;/span&gt; &lt;span class="na"&gt;ip=&lt;/span&gt;&lt;span class="s"&gt;"{{ hostvars[host]['private_ip1'] }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/rack&amp;gt;&lt;/span&gt;
{% endif %}
{% endfor %}

    &lt;span class="nt"&gt;&amp;lt;vc_name&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"{{ cur_vcname }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;comment&lt;/span&gt; &lt;span class="na"&gt;message=&lt;/span&gt;&lt;span class="s"&gt;"{{ cur_vcname }}"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/servers&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create VC
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create VC&lt;/span&gt;
  &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;cd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/opt/gcinstall;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcadmin&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;createvc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;createvc_{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}.xml'&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Distribution Creation Configuration File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate initialization configuration file&lt;/span&gt;
  &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcChangeInfo_vcname.xml.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/gcinstall/gcChangeInfo_{{ item }}.xml&lt;/span&gt;
  &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
  &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;install&lt;/span&gt;          
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generate Configuration File Template for Creating Distribution (&lt;code&gt;gcChangeInfo_vcname.xml.j2&lt;/code&gt;)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;installPrefix&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/opt&lt;/span&gt;
&lt;span class="py"&gt;coordinateHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;coordinateHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dataHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='node'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="c"&gt;#existCoordinateHost =
#existDataHost =
#existGcwareHost=
&lt;/span&gt;&lt;span class="py"&gt;gcwareHost&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{% for host in groups['all'] -%}&lt;/span&gt;
        &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['gbaseRole']&lt;/span&gt;&lt;span class="err"&gt;=='coor'&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                &lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['RoleId']&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;else&lt;/span&gt; &lt;span class="err"&gt;-%}&lt;/span&gt;
                        &lt;span class="err"&gt;,{{&lt;/span&gt; &lt;span class="err"&gt;hostvars&lt;/span&gt;&lt;span class="nn"&gt;[host]['private_ip1']&lt;/span&gt; &lt;span class="err"&gt;}}&lt;/span&gt;
                &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
        &lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endif&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;
&lt;span class="err"&gt;{%-&lt;/span&gt; &lt;span class="err"&gt;endfor&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt;

&lt;span class="py"&gt;gcwareHostNodeID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ coorHostNodeIDlist }}&lt;/span&gt;
&lt;span class="py"&gt;dbaUser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaGroup&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;span class="py"&gt;dbaPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ gbase_passwd }}'&lt;/span&gt;
&lt;span class="py"&gt;rootPwd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'{{ root_passwd }}'&lt;/span&gt;
&lt;span class="c"&gt;#dbRootPwd = ''
#rootPwdFile = rootPwd.json
&lt;/span&gt;&lt;span class="py"&gt;characterSet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{{ db_charset }}&lt;/span&gt;
&lt;span class="c"&gt;#sshPort = 22
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create Distribution
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize distribution for VC (multi-VC mode)&lt;/span&gt;
    &lt;span class="s"&gt;shell&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;cd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/opt/gcinstall;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcadmin&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;distribution&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gcChangeInfo_{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}.xml&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;d&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;db_user&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;db_pwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'gbase20110531'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;dba_os_password&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gbase_passwd&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
    &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s"&gt;install&lt;/span&gt;
    &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Initialize nodedatamap
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize nodedatamap for VC&lt;/span&gt;
    &lt;span class="s"&gt;vars&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;cur_vcname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;  
  &lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~/.bash_profile;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;gccli&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-ugbase&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-pgbase20110531&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-e"use&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}};&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;initnodedatamap;"'&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gbaseRole&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'coor'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;RoleId&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
    &lt;span class="na"&gt;with_items&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;vc_lists&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="s"&gt;install&lt;/span&gt;    
    &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;become_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By automating the installation and deployment of GBase 8a clusters (GBase数据库) with Ansible, you can significantly reduce manual intervention and increase the efficiency of your database environment. This method is particularly useful for large-scale deployments and environments where consistency is crucial.&lt;/p&gt;

&lt;p&gt;If you have any questions or need further clarification, feel free to reach out in the comments or via direct messages.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
  </channel>
</rss>
