CẬP NHẬT:
Tôi đã kết thúc bằng cách sử dụng tiện ích logrotate để xử lý các tệp nhật ký ngày càng phát triển. Thỉnh thoảng tôi cũng thiết lập một số công việc định kỳ sẽ kiểm tra các tệp tạm thời không cần thiết.
Tôi có cron Magento 2 tiêu chuẩn được cấu hình và chạy. Sau hai ngày, tôi gặp một số vấn đề trong khi chạy một số hành động trong bảng Quản trị. Khi tôi kiểm tra nhật ký máy chủ, tôi phát hiện ra rằng đó là sự cố không gian đĩa. Sau khi điều tra thêm, tôi phát hiện ra rằng đây update.log.txt
là thủ phạm. Kích thước tệp đã tăng> 1MB mỗi phút. Đã có lúc nó đạt hơn 20GB.
Có phải là bình thường cho một thiết lập Magento 2 tiêu chuẩn? Hoặc có thể & làm thế nào tôi có thể vô hiệu hóa nó hoặc ít nhất là giảm thiểu nó?
Nó xảy ra cho cả nhà phát triển và chế độ sản xuất.
Thiết lập cron được dựa trên hướng dẫn này .
Thẻ cron:
* * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log
* * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log
* * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run >> <magento install dir>/var/log/setup.cron.log
MẪU NỘI DUNG CỦA LOG
/var/www/html/setup/src/Magento/setup/Console/Command/I18nCollectPhTHERCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/Maint /setup/src/Magento/setup/Console/Command/BackupCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/DependenciesShowFrameworkCommand.php / var / www / /Setup/Console/Command/UninstallCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/InfoTimezoneListCommand.php / var / www / html / setup / src / Magento / Setup / Console /Maintenance ALLowIpsCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/ModuleStatusCommand.php /var/www/html/setup/src/Magento/setup/ons / www / html / setup / src / Magento / Setup / Console / Command / InfoBackupsListCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/MaintenanceDisableCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/DiCileCompand html / setup / src / Magento / Setup / Console / Command / InstallCommand.php /var/www/html/setup/src/Magento/setup/Console/Command/UpTHERCommand.php / var / www / html / setup / src / Magento / Setup / Fixture / IndexersStatesApplyFixture.php /var/www/html/setup/src/Magento/setup/Fixenses/StoresFixture.php /var/www/html/setup/src/Magento/setup/Fixture var / www / html / setup / src / Magento / Setup / Fixture / Simple ProductsFixture.php /var/www/html/setup/src/Magento/setup/Fixenses/tax_rates.csv / var / www / html / setup / src / Magento / Setup / Trình xác thực / var / www / html / setup / src / Magento / Setup / Trình xác thực / DbValidator.php /var/www/html/setup/src/Magento/setup/Validator/IpValidator.php /var/www/html/setup/src/Magento/setup/Validator/AdminCredentialsValidator.php / var / www / html index.php / var / www / html / setup / Performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / Performance -toolkit / README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []php /var/www/html/setup/src/Magento/setup/Validator/AdminCredentialsValidator.php /var/www/html/setup/index.php / var / www / html / setup / Performance-toolkit / var / www / html / setup / Performance-toolkit / .htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce / var / www / html / setup / Performance -toolkit / profile / ce / Large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml /var/www/html/setup/performance-toolkit/README.txt / var / www / html / setup / Performance-toolkit / điểm chuẩn .jmx /var/www/html/vendor/.htaccess [] []php /var/www/html/setup/src/Magento/setup/Validator/AdminCredentialsValidator.php /var/www/html/setup/index.php / var / www / html / setup / Performance-toolkit / var / www / html / setup / Performance-toolkit / .htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce / var / www / html / setup / Performance -toolkit / profile / ce / Large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml /var/www/html/setup/performance-toolkit/README.txt / var / www / html / setup / Performance-toolkit / điểm chuẩn .jmx /var/www/html/vendor/.htaccess [] []php / var / www / html / setup / Performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml / var /www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / Performance-toolkit /README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htmlaccess [] []php / var / www / html / setup / Performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml / var /www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / Performance-toolkit /README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htmlaccess [] []htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce / var / www / html / setup / Performance-toolkit / profile / ce / Large. xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml / var / www / html / setup / Performance-toolkit / profile / ce / Extra_large.xml /var/www/html/setup/performance-toolkit/README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx / var / www / html / nhà cung cấp / .htaccess [] []htaccess / var / www / html / setup / Performance-toolkit / profile / var / www / html / setup / Performance-toolkit / profile / ce / var / www / html / setup / Performance-toolkit / profile / ce / Large. xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml / var / www / html / setup / Performance-toolkit / profile / ce / Extra_large.xml /var/www/html/setup/performance-toolkit/README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx / var / www / html / nhà cung cấp / .htaccess [] []txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []
Tôi tìm thấy một vài nơi mà nhật ký này có thể được tạo / cập nhật:
<INSTALL_DIR>setup\src\Magento\Setup\Console\Command\CronRunCommand.php:
75 protected function execute(InputInterface $input, OutputInterface $output)
76 {
77: $notification = 'setup-cron: Please check var/log/update.log for execution summary.';
78
79 if (!$this->deploymentConfig->isAvailable()) {
<INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\ReadinessCheck.php:
164 $write->writeFile(self::SETUP_CRON_JOB_STATUS_FILE, $resultJson);
165
166: // write to permanent log file, var/log/update.log
167 foreach ($errorLogMessages as $errorLog) {
168 $this->status->add($errorLog, \Psr\Log\LogLevel::ERROR, false);
<INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\SetupLoggerFactory.php:
22 {
23 $logger = new \Monolog\Logger($channelName);
24: $path = BP . '/var/log/update.log';
25 $logger->pushHandler(new \Monolog\Handler\StreamHandler($path));
26 return $logger;
<INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\SetupStreamHandler.php:
17 * @var string
18 */
19: protected $fileName = '/var/log/update.log';
20
21 /**
<INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\Status.php:
81 $this->varReaderWriter = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
82 $this->statusFilePath = $statusFilePath ? $statusFilePath : '.update_status.txt';
83: $this->logFilePath = $logFilePath ? $logFilePath : DirectoryList::LOG . '/update.log';
84 $this->updateInProgressFlagFilePath = $updateInProgressFlagFilePath
85 ? $updateInProgressFlagFilePath
<INSTALL_DIR>setup\src\Magento\Setup\Test\Unit\Model\Cron\StatusTest.php:
71 $this->varReaderWriter->expects($this->any())
72 ->method('getAbsolutePath')
73: ->with('log/update.log')
74: ->willReturn('DIR/var/log/update.log');
75: $this->assertEquals('DIR/var/log/update.log', $this->status->getLogFilePath());
76 }
77
<INSTALL_DIR>update\app\code\Magento\Update\CronReadinessCheck.php:
16 const CRON_JOB_STATUS_FILE = '.update_cronjob_status';
17
18: const UPDATE_CRON_LOG_FILE = 'var/log/update.log';
19
20 /**#@+
..
91 file_put_contents(MAGENTO_BP . '/var/' . self::CRON_JOB_STATUS_FILE, $resultJson);
92
93: // If non-accessible paths are found, log an 'error' entry for the same in update.log
94 if ( !$success && !empty($outputString) ) {
95 $updateLoggerFactory = new UpdateLoggerFactory();
<INSTALL_DIR>update\app\code\Magento\Update\Status.php:
67 ) {
68 $this->statusFilePath = $statusFilePath ? $statusFilePath : MAGENTO_BP . '/var/.update_status.txt';
69: $this->logFilePath = $logFilePath ? $logFilePath : MAGENTO_BP . '/var/log/update.log';
70 $this->updateInProgressFlagFilePath = $updateInProgressFlagFilePath
71 ? $updateInProgressFlagFilePath
<INSTALL_DIR>update\app\code\Magento\Update\UpdateLoggerFactory.php:
29 */
30 public function __construct(
31: $logFile = '/var/log/update.log',
32 $channelName = 'update-cron'
33 ) {
<INSTALL_DIR>update\cron.php:
15 $status = new \Magento\Update\Status();
16 $cronReadinessChecker = new \Magento\Update\CronReadinessCheck();
17: $notification = 'update-cron: Please check var/log/update.log for execution summary.' . PHP_EOL;
18
19 if (!$cronReadinessChecker->runReadinessCheck()) {
<INSTALL_DIR>update\dev\tests\integration\testsuite\Magento\Update\StatusTest.php:
43 $this->statusFilePath = __DIR__ . '/_files/update_status.txt';
44 $this->tmpStatusFilePath = TESTS_TEMP_DIR . '/update_status.txt';
45: $this->tmpStatusLogFilePath = TESTS_TEMP_DIR . '/update.log';
46 $this->updateInProgressFlagFilePath = TESTS_TEMP_DIR . '/update_in_progress.flag';
47 $this->updateErrorFlagFilePath = TESTS_TEMP_DIR . '/update_error.flag';
CẬP NHẬT:
Tôi đã kết thúc bằng cách sử dụng tiện ích logrotate để xử lý các tệp nhật ký ngày càng phát triển. Thỉnh thoảng tôi cũng thiết lập một số công việc định kỳ sẽ kiểm tra các tệp tạm thời không cần thiết.