In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
PostgreSQL how to control the file generated during initialization, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
The control file is generated during initialization and records the key information in the running process of PG, which is roughly divided into the following categories.
Automatically generated during initialization, and modification is not allowed during operation, such as system identifiers
Allows users to customize at one time during initialization, and no longer allows modification, such as WAL segment size
Record the compile-time information that creates the database, such as the catalog version, and the program that starts the database must have the same properties
Real-time information, such as checkpoint records, rebooting in a crash can know where to start recovery.
1. Pass the parameters to postgres during initialization
I won't talk much about this process here. Initdb uses postgres-- boot-x1 to start the database program and enter bootstrap mode:
If (argc > 1 & & strcmp (argv [1], "--boot") = 0) AuxiliaryProcessMain (argc, argv); / * does not return * /
This code is in the main (int argc, char * argv []) function, which was mentioned in previous articles.
Parameter resolution in AuxiliaryProcessMain:
Case "x": MyAuxProcType = atoi (optarg); break
Get the type of worker process here, and we'll talk about it when other parameters are encountered.
2. Definition of auxiliary process
Typedef enum {NotAnAuxProcess =-1, CheckerProcess = 0, BootstrapProcess,... NUM_AUXPROCTYPES / * Must be last! * /} AuxProcType
As you know, initdb starts a BootstrapProcess process.
3. Automatically generate parameters (system identifier) during initialization
Looking further down, you will see the call to BootStrapXLOG (src/backend/access/transam/xlog.c), where the system identifier is generated and finally written to disk:
VoidBootStrapXLOG (void) {... Gettimeofday (& tv, NULL); sysidentifier = ((uint64) tv.tv_sec) xlog_seg_size = wal_segment_size
5. Compile-time options
The function WriteControlFile writes to the control file
ControlFile- > pg_control_version = PG_CONTROL_VERSION; ControlFile- > catalog_version_no = CATALOG_VERSION_NO; ControlFile- > maxAlign = MAXIMUM_ALIGNOF; ControlFile- > floatFormat = FLOATFORMAT_VALUE; ControlFile- > blcksz = BLCKSZ; ControlFile- > relseg_size = RELSEG_SIZE;...
6. Real-time information
The system updates the ControlFile while it is running, and then when some nodes write to disk (call UpdateControlFile), such as CheckPoint, you can see that information such as the system identifier does not change.
7. Check
CRC is calculated when writing and updating, and it is also written into the control file.
/ * Contents are protected with a CRC * / INIT_CRC32C (ControlFile- > crc); COMP_CRC32C (ControlFile- > crc, (char *) ControlFile, offsetof (ControlFileData, crc)); FIN_CRC32C (ControlFile- > crc)
Verify that it ensures integrity when reading the file:
/ * Now check the CRC. * / INIT_CRC32C (crc); COMP_CRC32C (crc, (char *) ControlFile, offsetof (ControlFileData, crc)); FIN_CRC32C (crc) If (! EQ_CRC32C (crc, ControlFile- > crc)) ereport (FATAL, (errmsg ("incorrect checksum in control file"); after reading the above, have you mastered how to control the method of file generation during initialization in PostgreSQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.