情況描述:
1. 該網域之前在GCP上,有申請SSL證書,但想使用Region的Load Balance需要自已提供證書。
2. 在某網站購買SSL證書,但在認證的時候提示CAA紀錄異常。
3. 使用CAA Lookup Tool查看CAA紀錄,發現Google把CAA紀錄加入DNS。
4. 在DNS管理平台上,添加CAA紀錄,以cloudflare為例
Wildcard SSL CAA紀錄設定
在知識的殿堂裡,學術的領域不分國界
每個靈感,每到聲音,每個思想,每個研究,都會妥善被珍重,被珍視
進而激發出更多的火花,交融出更多的經典。
情況描述:
1. 該網域之前在GCP上,有申請SSL證書,但想使用Region的Load Balance需要自已提供證書。
2. 在某網站購買SSL證書,但在認證的時候提示CAA紀錄異常。
3. 使用CAA Lookup Tool查看CAA紀錄,發現Google把CAA紀錄加入DNS。
4. 在DNS管理平台上,添加CAA紀錄,以cloudflare為例
Wildcard SSL CAA紀錄設定
mysqldump命令:
导出数据库:mysqldump -h ip -u root -p dbname > db.sql;
导出数据库中的某个表:mysqldump -h ip -u root -p dbname tablename > tablename.sql;
错误提示:
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS
原因:
因为新版的mysqldump默认启用了一个新标志,通过 --column-statistics=0 来禁用他
解决方法:
mysqldump --column-statistics=0 -h 192.168.0.1 -u root -p dbname > db.sql;
最近有個專案想抓取PDF的檔案內容,進行檔案rename的動作,因此才開始瞭解Tesseract相關的用法,以下是使用的一些心得。
1. Windows上安裝Tesseract 5.0後,如果想轉移到其他台Windows PC,該PC要先安裝 Visual Studio 2015 的 Visual C++ 可轉散發套件,再將Tesseract安裝的目錄整個zip起來後,在其他台Windows PC上解壓縮後,設定Tesseract相關windows環境變數路徑後,Java程式就可以直接使用。
2. Tesseract程式中辨識資料的路徑與繁體中文語言設定如下:
tesseract.setDatapath("D:\\Tesseract-OCR\\tessdata\\");
tesseract.setLanguage("chi_tra");
3. 不要透過抓取PDF文字後再辨識,因為會抓不到PDF內容文字,要先轉成圖檔(TIFF)後,在進行圖片辨識文字,會比較不會出錯,下面是範例的Code。
private boolean pdfToTiffConverter(String inputPdf, String outputTiff) {
int dpi = 300; // the resolution of the output image in DPI
boolean result = false;
PDDocument document = null;
PDFRenderer pdfRenderer = null;
BufferedImage image = null;
try {
File pdfFile = new File(inputPdf);
Thread.sleep(100); // wait 100ms for loading pdf to memory to avoid NullPointException
document = PDDocument.load(pdfFile);
pdfRenderer = new PDFRenderer(document);
image = pdfRenderer.renderImageWithDPI(0, dpi); // render the first page of the PDF document
ImageIO.write(image, "TIFF", new File(outputTiff)); // write the image to a TIFF file
result = true;
document.close();
} catch (IOException e) {
logger.error(e.getStackTrace());
result = false;
} catch (InterruptedException e) {
logger.error(e.getStackTrace());
} finally {
}
return result;
}
private String tiffOcr(String outputTiff) {
String tiffPath = outputTiff;
Tesseract tesseract = new Tesseract();
String result = "";
try {
tesseract.setDatapath("D:\\Tesseract-OCR\\tessdata\\"); // set the path to the Tesseract data directory
tesseract.setLanguage("chi_tra");
result = tesseract.doOCR(new File(tiffPath));
} catch (TesseractException e) {
logger.error(e.getStackTrace());
} finally {
File imageFile = new File(outputTiff);
if(imageFile.exists()) imageFile.delete();
}
return result;
}
javax.imageio.spi.ImageOutputStreamSpi: Provider com.sun.media.imageioimpl.stream.ChannelImageOutputStreamSpi could not be instantiated
解決方式:Eclipse匯出方式需要變更為【copy required libraries into sub-folder....】。
PowerShell是一套Windows上非常強大的工具,透過它也可以操作AD相關功能,。
• 查詢AD人員
Get-ADUser -Filter * -SearchBase "CN=user1,OU=IT,OU=Test,DC=DevOps,DC=com"
• 修改人員屬性值
Set-ADUser -Identity "user1" -Replace @{company="DevOps";division="IT";department="system";title="資深工程師";manager="CN=manager1,OU=IT,DC=DevOps,DC=com";employeeID="1234567";mobile="0912345678";poRoleNames=@("MR");poRoleLevels=@("0");}
雖然我感覺不出來在 Linux 一般系統裡安裝防毒軟體的作用,但在某些應用有可能被外部使用者更改檔案,且資安要求需要安裝所以就會在 CentOS 裡安裝 ClamAV ,之前寫過一篇「Linux 系統安裝防毒 - ClamAV」但後來在套用指令發現綴詞太多,於是再寫一篇快速應用,只要簡單貼上下面指令,就能在 CentOS 裡配置防毒軟體 ClamAV。
安裝套件庫 EPEL Repository
sudo yum install epel-release -y
安裝防毒軟體
sudo yum install clamav clamd -y
會安裝:clamav、clamd 及 clamav-db
設定 selinux
sudo setsebool -P antivirus_can_scan_system 1
啟動服務 clamd
(CentOS 6) sudo chkconfig clamd on; sudo service clamd start
(CentOS 7 )sudo systemctl start clamd
若病毒碼未更新會跳出這個警告訊息
Starting Clam AntiVirus Daemon:
LibClamAV Warning: **************************************************
LibClamAV Warning: *** The virus database is older than 7 days! ***
LibClamAV Warning: *** Please update it as soon as possible. ***
LibClamAV Warning: **************************************************
增加台灣病毒碼更新資料庫 - 不增加也可以,但速度會差很多
sudo vi /etc/freshclam.conf
DatabaseMirror clamav.stu.edu.tw
DatabaseMirror db.tw.clamav.net
更新病毒碼
sudo freshclam
ClamAV update process started at Mon Nov 6 11:54:40 2017
WARNING: DNS record is older than 3 hours.
WARNING: Invalid DNS reply. Falling back to HTTP mode.
Reading CVD header (main.cvd): OK
Downloading main-58.cdiff [100%]
main.cld updated (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
Reading CVD header (daily.cvd): OK
WARNING: getfile: daily-21724.cdiff not found on clamav.stu.edu.tw (IP: 2001:e10:c41:eeee::1)
WARNING: getpatch: Can't download daily-21724.cdiff from clamav.stu.edu.tw
Trying host clamav.stu.edu.tw (120.119.118.1)...
WARNING: getfile: daily-21724.cdiff not found on clamav.stu.edu.tw (IP: 120.119.118.1)
WARNING: getpatch: Can't download daily-21724.cdiff from clamav.stu.edu.tw
WARNING: getpatch: Can't download daily-21724.cdiff from clamav.stu.edu.tw
WARNING: Incremental update failed, trying to download daily.cvd
Downloading daily.cvd [100%]
daily.cvd updated (version: 24010, sigs: 1769510, f-level: 63, builder: neo)
Reading CVD header (bytecode.cvd): OK
Downloading bytecode-279.cdiff [100%]
(略)
Downloading bytecode-315.cdiff [100%]
bytecode.cld updated (version: 315, sigs: 75, f-level: 63, builder: raynman)
Database updated (6335834 signatures) from clamav.stu.edu.tw (IP: 120.119.118.1)
設定每日排程更新病毒碼 與 掃描特定目錄,當然也可以針對 root /
sudo vi /etc/crontab
# 1 1 * * * root /usr/bin/freshclam --quiet -l /var/log/clamav/freshclam.log
# 以 yum 套件方式安裝,不需要額外設定每日更新事件,他會自動在 /etc/cron.daily/freshclam 排程更新
1 2 * * * root /usr/bin/clamscan -r /target_directory
即時掃描某目錄,若掃描正常會在檔名後面顯示OK
sudo clamscan -r /www/webroot
最後會產出掃描結果
----------- SCAN SUMMARY -----------
Known viruses: 6330125
Engine version: 0.99.2
Scanned directories: 39
Scanned files: 2196
Infected files: 0
Data scanned: 2860.51 MB
Data read: 12931.74 MB (ratio 0.22:1)
Time: 629.235 sec (10 m 29 s)
預設的mysqldump備份出來的sql檔案,是不包含StoredProcedure,但是包含Trigger指令,因此我們如過發現資料庫中有StoredProcedure的話,需要透過下方的指令,將StoredProcedure備份出來。
mysqldump -h 127.0.0.1 -u root -p -n -d -t
--routines --triggers example > example.sql
在mysql匯入SQL檔案時,如果遇到亂碼問題,可透過指定編碼的方式,將資料正確匯入。
mysql -u root -p --default-character-set=utf8 example < example.sql
當使用mysqldump匯出資料庫檔案時,若有些欄位是直接將檔案儲存進去,在匯入資料庫時會導致失敗,因此需要透過以下指令將資料庫匯出後,才能在其他台mysql主機上匯入。
1. 使用--hex-blob匯出資料庫檔案
mysqldump -u root -p --hex-blob example > example.sql
2. 使用一般方式匯入資料庫檔案
mysql -u root -p example < example.sql
GCP上除了使用VM架設Web Server建置靜態網頁外,另外也提供了其他方式可以不使用VM的情況下,將html檔案,放置在雲端儲存體內,透過相關設定,來建構靜態網頁網站,但相關流程較為複雜,但因為是Serverless的架構,因此穩定度會高很多。
在GCP Console下,透過下面六個步驟(範例域名:example.com.tw),即可建置一個靜態網站。
1. 新增一個example.com.tw名稱的bucket
2. Edit access > Access-control -> Fine-grained: Object-level ACLs enabled
3. 上傳檔案
4. 使用cloud console輸入:gsutil -m acl set -R -a public-read gs://example.com.tw
5. 檢查檔案權限都設定為public
6. 設定@的CNAME DNS為c.storage.googleapis.com
步驟參考:https://ikala.cloud/cloud-storage-application-website/
網站建置完後,如果要套用HTTPS連線,可以依照以下步驟進行:
SSL設定:https://www.minwt.com/website/server/21585.html
結論:
1. 設定較為複雜。
2. 費用跟架設便宜的VM沒差多少。
3. 更新檔案較不方便。
4. 穩定性與安全性較高。
5. 不用擔心硬體效能。
在windows下,很多系統人員都很想建立像是linux上使用ln指令建立的連結給程式使用,目前windows指令中有提供mklink指令,來達成目的。
cmd下, 輸出目前目錄下的檔案:
dir /A:A /B /S > ..\files.txt
cmd下,輸出目前目錄下的資料夾:
dir /A:B /B /S > ../folders.txt