2020年12月17日 星期四

免費安裝註冊RHEL(Red Hat Enterprise Linux)

因為CentOS 8之後政策修改,只好研究官方的RHEL如何安裝註冊
免費的Red Hat Developer Subscription授權僅限用於開發用途(development environment)

註冊Red Hat網站帳號
https://www.redhat.com

下載最新版ISO檔安裝
https://developers.redhat.com/products/rhel/download

下載舊版ISO檔、Supplementary、virt-p2v、KVM Guest Image、原始碼等(以RHEL 7.5為例)
https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.5/x86_64/product-software


參考文件
https://developers.redhat.com/products/rhel/hello-world

查看已註冊的產品
https://access.redhat.com/management/subscriptions/

2021/02/01更新
小型企業可以免費使用16套授權
https://www.redhat.com/en/blog/new-year-new-red-hat-enterprise-linux-programs-easier-ways-access-rhel

紅帽推出免費與低成本RHEL計畫
https://www.ithome.com.tw/news/142391

FAQ: Changes to the Red Hat Developer program’s no-cost subscriptions
https://developers.redhat.com/articles/faq-changes-red-hat-developer-programs-no-cost-subscriptions
新政策只能安裝16個VM中
Under the new no-cost Red Hat Developer Subscription available from March 2018 onward, the maximum number of VMs supported by RHEL is now 16.

舊的
Program members who have activated the legacy Red Hat Enterprise Linux Developer Subscription may continue run up to 99 VMs inside their activated copy of Red Hat Enterprise Linux (RHEL.) 

透過指令註冊:
subscription-manager register
https://access.redhat.com/solutions/253273

透過介面註冊:





輸入subscription.rhn.redhat.com




2020年12月13日 星期日

MQ connection is terminating with error code 2009

某次系統升級IBM MQ Server從7升到9
新的Channel採用加密連線,一連線就出2009的錯誤
如果採不加密連線可以正常
後來發現是AP Client端的MQ Driver的jar檔沒有換成新版的
都不是以下六種原因@@


https://www.ibm.com/support/pages/mq-connection-terminating-error-code-2009

Problem

MQ connection is terminating with error code 2009.

Cause

The connection may be broken for a number of different reasons. The 2009 return code indicates that something prevented a successful connection to the Queue Manager. The most common causes for this are the following are:

1. A firewall that is terminating the connection
2. An IOException that causes the socket to be closed
3. An explicit action to cause the socket to be closed by one end
4. The queue manager is offline
5. The maximum number of channels allowed by the queue manager are open
6. A configuration problem in the Queue Connection Factory (QCF)

2020年12月6日 星期日

華碩ASUS ROG Zenith Extreme主機板8 DIMM記憶體插槽可以支援256GB記憶體

 https://news.xfastest.com/amd/58097/intel-128gb-amd-tr4-256gb/

華碩已經在ASUS ROG Zenith Extreme上實現了單條32GB non-ECC記憶體支援,這麼一來8 DIMM記憶體插槽就可以支援256GB記憶體

2020年7月19日 星期日

Deploying a two-node clustered file server

Deploying a two-node clustered file server
部署雙節點叢集檔案伺服器 
https://docs.microsoft.com/zh-tw/windows-server/failover-clustering/deploy-two-node-clustered-file-server

英文版Windows安裝注音輸入法

原來只要把繁體中文版Windows位於C:\Windows\IME\底下的IMETC資料夾複製貼上到英文版Windows一樣路徑(需重開機)就有注音輸入法了

備註一:字型檔路徑是C:\Windows\Fonts
備註二:Language Pack沒有IME,只有中文UI

參考:
https://www.youtube.com/watch?v=lvon3n16vEM

2020年7月18日 星期六

locate: 無法執行 stat()「/var/lib/mlocate/mlocate.db」: 沒有此一檔案或目錄

需要先執行updatedb


[root@db ~]# locate postgresql.conf
locate: 無法執行 stat()「/var/lib/mlocate/mlocate.db」: 沒有此一檔案或目錄
[root@db ~]# updatedb
[root@db ~]# locate postgresql.conf
/etc/postgresql-setup/upgrade/postgresql.conf
/usr/lib/tmpfiles.d/postgresql.conf
/usr/share/pgsql/postgresql.conf.sample
/var/lib/pcp/pmdas/postgresql/pmdapostgresql.conf
/var/lib/pgsql/data/postgresql.conf
[root@db ~]#
[root@db ~]# locate pg_hba.conf
/usr/share/pgsql/pg_hba.conf.sample
/var/lib/pgsql/data/pg_hba.conf
[root@db ~]#

 
LAB環境: CentOS-8.2.2004

2020年7月7日 星期二

IPv6遠端桌面的port

TCP 45001

luci-app-ddns

https://www.opencli.com/internet/openwrt-setup-ddns

https://openwrt.org/docs/guide-user/services/ddns/client
https://openwrt.org/docs/guide-user/base-system/ddns

OpenWrt安裝fwknopd

root@myrouter:~# opkg install fwknopd
Installing fwknopd (2.6.10-3) to root...
Downloading http://downloads.openwrt.org/releases/19.07.3/packages/arm_cortex-a9/packages/fwknopd_2.6.10-3_arm_cortex-a9.ipk
Installing libfko (2.6.10-3) to root...
Downloading http://downloads.openwrt.org/releases/19.07.3/packages/arm_cortex-a9/packages/libfko_2.6.10-3_arm_cortex-a9.ipk
Installing libpcap1 (1.9.1-2.1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.3/packages/arm_cortex-a9/base/libpcap1_1.9.1-2.1_arm_cortex-a9.ipk
Configuring libfko.
Configuring libpcap1.
Configuring fwknopd.


安裝完後再安裝luci-app-fwknopd
https://openwrt.org/docs/guide-user/services/fwknop


ref:
https://newtoypia.blogspot.com/2018/02/spa.html

2020年7月6日 星期一

Differences between global Azure, Azure Stack Hub, and Azure Stack HCI

https://docs.microsoft.com/zh-tw/azure-stack/operator/compare-azure-azure-stack?view=azs-2002

https://www.facebook.com/groups/AzureTWUG/permalink/2689088474653853/
  • HPE 推出 Edgeline EL8000 較小型一體機規格支援 Azure Stack Hub
  • HPE ProLiant for Microsoft Azure Stack Hub 與 Dell EMC Integrated System for Azure Stack Hub 針對 GPU 機型支援進入技術預覽階段

HPE EDGELINE 系統
HPE推電訊級實時處理平台 Edgeline EL8000
http://itpromag.com/2019/03/01/hpeedgeline-el8000/
HPE Solutions for Microsoft Azure Stack HCI


2020年7月5日 星期日

修改Docker組態檔開放外部透過TCP 2375操作Docker

修改Docker組態檔開放TCP 2375 (有資安風險,請僅用於開發環境!)
vi /usr/lib/systemd/system/docker.service
加入以下組態
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

重啟Docker服務
systemctl daemon-reload
systemctl restart docker

開通防火牆
firewall-cmd --zone=public --add-port=2375/tcp --permanent
firewall-cmd --reload


環境:CentOS

參考
https://www.cnblogs.com/hongdada/p/11512901.html

SQL Server 2016 標準版SP1之後下放的企業版功能

SQL Server 2016 標準版SP1之後下放的企業版功能,居然連免費的Express版也支援(驚)

https://docs.microsoft.com/zh-tw/archive/blogs/sqlreleaseservices/sql-server-2016-service-pack-1-sp1-released



各版本比較

AD server和DB透過DNS SRV達成高可用性

※本文章只是網路找到的解決方案,尚未實測或導入 ※

https://serverfault.com/questions/374154/how-to-make-ad-highly-available-for-applications-that-use-it-as-an-ldap-service

The correct way to do this is to use the DNS SRV records to look up the domain controller names and ports, as well as ascertain which servers to use in what order. Unfortunately, not many LDAP applications seem to support SRV record lookups.
The SRV record for Active Directory domain controllers is _ldap._tcp.domain.tld. This will return a list of hosts and ports, as well as a priority and weight for each (these values can be set using Group Policy) that together indicate which server to use.


也意外發現資料庫也開始支援DNS SRV的方式達成高可用性
MySQL 8.0.19
https://mp.weixin.qq.com/s/G3dW_GPDd1l1MJ86c7iFTA
我还在想这事儿就应该由 MySQL Connector 来实现访问链路的 Failover 和 Loadbalance, 现在有了 DNS SRV 的支持,router 不必和应用端绑定部署,也可以省了 VIP 和负载均衡,MySQL InnoDB Cluster 方案更加完善,配合 consul 等服务发现组件,更容易适配 service mesh 架构。

PostgreSQL 12.0
https://mp.weixin.qq.com/s/hGeGiqm3D52aQJsS61QoGg

開啟效能魔力窗 T-SQL 視窗函數的實務技巧

使用Window Function改善效能
比如:累計彙總(cumulative aggregates)、移動平均值(moving averages)
https://channel9.msdn.com/Events/TechDays/TechDays-Taiwan-2014/DBI307

許致學老師在channel9的影片
https://channel9.msdn.com/Events/Speakers/lancelot-hsu

sendStringParametersAsUnicode

JDBC預設是true,會自動把字元資料轉成Unicode格式送到伺服器
但是資料庫column不是開nchar之類的Unicode UCS-2欄位
因為SQL Server需要做型別轉換,會需要用到平行處理,會很耗cpu
從執行計畫可以看到"type conversion in expression"的警告訊息
解法一:column改成nvarvhar nchar這類的欄位
解法二:sendStringParametersAsUnicode設定成false,使用非Unicode格式送到伺服器(比如ASCII/MBCS)
今天上許致學老師的課才知道有這參數


"type conversion in expression" sql server

2020年6月26日 星期五

Windows10下載語言Basic typing(基本鍵入)都會0x80240438的Error code

如果只需要在 英文版Windows安裝注音輸入法可以參考http://it.rex.tw/2020/07/windows.html

因為英文版Win10安裝繁體中文language pack之後還是無法使用注音輸入法
所以還是得安裝Basic typing(基本鍵入)
Windows10下載語言Basic typing都會0x80240438的Error code
不管是透過GUI介面
還是指令(DISM.exe /Online /Add-Capability /CapabilityName:Language.Basic~~~zh-TW~0.0.1.0)
錯誤畫面如下圖:


https://docs.microsoft.com/en-us/windows/deployment/update/fod-and-lang-packs
The Specify settings for optional component installation and component repair policy, located under Computer Configuration\Administrative Templates\System in the Group Policy Editor, can be used to specify alternate ways to acquire FOD packages, language packages, and content for corruption repair. However, it’s important to note this policy only allows specifying one alternate location and behaves differently across OS versions.

https://answers.microsoft.com/en-us/windows/forum/all/traditional-chinese-ime-is-not-ready-yet-on-win10/df59048c-34e5-4835-9e96-6c972a27c913
I'm in an enterprise, and I was able to resolve this once I stumbled upon this.
"For Windows domain environments running WSUS or SCCM, change the Specify settings for optional component installation and component repair policy to enable downloading FOD and language packs from Windows Update. This setting is located in Computer Configuration\Administrative Templates\System in the Group Policy Editor."
I created a test policy, with this setting enabled, and got everything to work on my test box.
Hope this can help someone.



原因可能是因為該電腦曾經加入過網域,機碼被改成向內部WSUS更新
所以要改成直接跟微軟Windows Update更新


2020年6月25日 星期四

國外買的Windows 10切換到注音輸入法出現“Traditional Chinese IME is not ready yet”

已經安裝繁體中文Language Pack,但切換到注音輸入法出現“Traditional Chinese IME is not ready yet”


https://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/problems-using-a-japanese-or-traditional-chinese/db5a0ddf-2c50-4f0d-a961-58902f40acda

  • For Traditional Chinese basic typing:
DISM.exe /Online /Add-Capability /CapabilityName:Language.Basic~~~zh-TW~0.0.1.0


如果只需要在 英文版Windows安裝注音輸入法可以參考http://it.rex.tw/2020/07/windows.html

ref:
http://www.infomate.tw/2020/01/windows10-traditional-chinese-ime-is.html

https://blog.dino9021.com/2017/02/windows-10.html
Add-WindowsCapability -Name "Language.Basic~~~zh-TW~0.0.1.0" -Online
Add-WindowsCapability -Name "Language.Handwriting~~~zh-TW~0.0.1.0" -Online
Add-WindowsCapability -Name "Language.OCR~~~zh-TW~0.0.1.0" -Online
Add-WindowsCapability -Name "Language.Speech~~~zh-TW~0.0.1.0" -Online
Add-WindowsCapability -Name "Language.TextToSpeech~~~zh-TW~0.0.1.0" -Online
Add-WindowsCapability -Name "Language.Fonts.Hant~~~und-HANT~0.0.1.0" -Online
Add-WindowsCapability -Name "International.Locale.Taiwan~~~zh-TW~0.0.1.0" -Online


 

2020年6月19日 星期五

Windows10英文版內網安裝繁體中文語系和介面

會有這個需求是因為內網電腦不能連Internet,國外只買的到英文版,但是公文和內部系統是中文,需要offline方式安裝中文Language Pack

參考這個網站作法
https://4sysops.com/archives/local-experience-packs-add-languages-to-windows-10-and-server-2019/
實測沒有LXP(LocalExperiencePack)也可以成功,不太清楚LXP的用途

安裝完Language Pack之後仍需要安裝Basic typing(基本鍵入)
請參考 http://it.rex.tw/2020/06/windows10basic-typing0x80240438error.html

(1)
到大量授權中心或是MSDN網站下載mu_windows_10_language_pack_version_1809之類的iso檔,如果是2004版的Win10請下載對應的2004版本


(2)
透過lpksetup安裝zh-TW的LanguagePack(Microsoft-Windows-Client-Language-Pack_x64_zh-tw.cab)



(3)
使用PowerShell執行以下指令
繁體中文版
Set-WinUILanguageOverride -Language zh-TW

英文版
Set-WinUILanguageOverride -Language en-US

簡體中文版
Set-WinUILanguageOverride -Language zh-CN

(4)
登出再登入Windows

備註:
不能是Single language edition的Windows 10

其他參考資料:
https://blog.miniasp.com/post/2018/10/03/PowerShell-Custom-Scripts-for-Azure-Windows-VM


https://docs.microsoft.com/zh-tw/windows-hardware/manufacture/desktop/add-language-packs-to-windows
Language Interface Packs (LIPs): Partially-localized language pack. Requires a base language pack. In Windows 10, version 1809, LIPs are delivered as Local Experience Packs (LXPs) .appx files,

2020年6月13日 星期六

免費用於開發測試用途的IBM MQ Advanced for Developers

https://developer.ibm.com/messaging/mq-downloads/

No cost non-production use downloads

MQ Advanced for Developers

版本功能比較:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.1.0/com.ibm.mq.pro.doc/q126140_.htm

2020年6月12日 星期五

移轉TIBCO MFT組態檔設定到新的伺服器

https://support.tibco.com/s/article/How-to-copy-TIBCO-MFT-Platform-Server-for-Windows-DNI-definitions-to-a-new-installation

Details
 Is there a way of exporting DNI Templates and Initiation Directories from one TIBCO MFT Platform Server for Windows machine and then importing them on another TIBCO MFT Platform Server for Windows machine?
Resolution
 The DNI Templates and Initiation Directories are stored in the ftmssvr.pqf file. To copy the DNI Templates and Initiation Directories between two machines, copy the ftmssvr.pqf file from the current machine and replace the same file on the new server. This file is located in the <MFTPS> directory (i.e. MFT Platform Server for Windows home directory). To replace the ftmssvr.pqf file, follow these steps:

- Stop the Platform Server for Windows service
- Rename the existing Platform Server for Windows ftmssvr.pqf file to ftmssvr.pqf.backup
- Copy ftmssvr.pqf file to the Platform Server directory
- Start the Platform Server service
- Check the Transfer Templates and the Initiation Directories on the Platform Server Administrator.


Note:

1.  This article does not apply to pDNI.

2. The copy of the ftmssvr.pqf file works very well as long as both servers have the same configuration (server name/file paths etc.) 
This is very useful if the new server is configured exactly like the parent (server name/file paths etc.).

3. If the server has a different configuration, copying to a new server configuration may require additional steps with regards to configuring the DNI templates. Most of the DNI transfer information will need to be changed.

2020年6月7日 星期日

wkhtmltopdf

https://wkhtmltopdf.org

SQL Server Trace Flag List

https://seniordba.wordpress.com/2015/12/09/sql-server-trace-flag-list-2330-update/

UNION和UNION ALL的差別,UNION會移除重複資料

UNION會移除重複資料
UNION ALL會保留重複資料


執行計畫:
UNION會先Concatenation 再Distinct Sort再輸出結果
UNION ALL只有Concatenation就輸出結果

GROUP BY會去掉重複的資料


2020年6月6日 星期六

T-SQL Querying: TOP and OFFSET-FETCH

https://www.microsoftpressstore.com/articles/article.aspx?p=2314819

OFFSET 25 ROWS

從第26筆資料開始(跳過前25筆)

 use Northwind
 GO

SELECT * FROM Orders
ORDER BY OrderID
OFFSET 25 ROWS

OFFSET 0 ROWS FETCH FIRST 25 ROWS ONLY

 use Northwind
 GO

SELECT * FROM Orders
ORDER BY OrderID
OFFSET 0 ROWS FETCH FIRST 25 ROWS ONLY


效果同
SELECT TOP(25) * FROM Orders
ORDER BY OrderID

差別:
TOP不是ANSI SQL,但是TOP還可以搭配PERCENT和WITH TIES很方便
OFFSET是 ANSI SQL

OFFSET 50 ROWS FETCH NEXT 25 ROWS ONLY

找出51筆到75筆的資料
通常用在分頁
要加ORDER BY

 use Northwind
 GO

SELECT * FROM Orders
ORDER BY OrderID
OFFSET 50 ROWS FETCH NEXT 25 ROWS ONLY



分頁效果(每頁25筆,顯示第2頁的資料)
DECLARE @pagesize AS BIGINT = 25, @pagenum AS BIGINT = 2;
SELECT *
FROM Orders
ORDER BY OrderID DESC
OFFSET (@pagenum - 1) * @pagesize ROWS FETCH NEXT @pagesize ROWS ONLY;

(重要)使用WITH TIES語法找出成績排名前8名的學生,因為平分,得到9筆資料

SELECT TOP 8 WITH TIES * FROM students ORDER BY score DESC

因為需求是排名前8名
如果用沒加WITH TIES只會有8筆,導致資料不正確

REF:
https://blog.csdn.net/whaxrl/article/details/51218230

order by (select null)

https://stackoverflow.com/questions/10066819/what-does-order-by-select-null-mean


T-SQL Querying: TOP and OFFSET-FETCH
https://www.microsoftpressstore.com/articles/article.aspx?p=2314819

ORDER BY要搭配indexes使用

資料量大,有index時SQL Server就不用真的去Sort資料
效能會比較好

SELECT TOP (1) PERCENT

SELECT TOP (1) PERCENT *
FROM Orders
ORDER BY orderdate DESC;

取出前1%的資料

ORDER BY NULLS FIRST、ORDER BY NULLS LAST

原來Oracle有這種語法,SQL Server沒有這語法
https://www.oracletutorial.com/oracle-basics/oracle-order-by/

而且是ANSI SQL:2003語法
https://en.wikipedia.org/wiki/Order_by

TSQL個別取得年月日

SELECT YEAR(GETDATE()) , MONTH(GETDATE()) ,DAY(GETDATE())

CONVERT(nvarchar(30), GETDATE(), 126) AS UsingConvertTo_ISO8601

https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15#g-using-cast-and-convert-with-datetime-data

找出開頭不是數字的資料

開頭不是數字的資料
SELECT * FROM Table_1 WHERE T1 LIKE '[^0-9]%' 

開頭數字的資料
SELECT * FROM Table_1 WHERE T1 LIKE '[0-9]%'

找出開頭第二個字是D的資料 LIKE '_D%'

SELECT * FROM Table_1 WHERE T1 LIKE '_D%'

找出開頭第二個字是D的資料

TRY_CAST

SELECT * FROM  Table_1 WHERE  TRY_CAST(T1 AS INT) > 10
=>可以得到結果

SELECT * FROM  Table_1 WHERE  CAST(T1 AS INT) > 10
=>將 varchar 值 'A         ' 轉換成資料類型 int 時,轉換失敗。

2020年5月23日 星期六

SQLServer隔離層級RCSI和SI的比較

https://github.com/imrexhuang/SQLServerIsolation-RCSIvsSI/

  • SQL Server預設的隔離層級是RC(Read Committed)
  • 使用Row Version Base的隔離層級,要好好管理TempDB並最佳化、大型交易分批做
  • 使用RCSI要注意副作用(特別是和金額有關),最好不要在舊系統使用,新系統上線前可以完整測試比較安全
  • SQL Server 2005之後支援RSCI(Read Committed Snapshot Isolation)和SI(Snapshot Isolation)的隔離層級,但這兩種層級不支援分散式交易

GROUP BY無法使用alias column name

原因
https://stackoverflow.com/questions/3841295/sql-using-alias-in-group-by

SQL is implemented as if a query was executed in the following order:
  1. FROM clause
  2. WHERE clause
  3. GROUP BY clause
  4. HAVING clause
  5. SELECT clause
  6. ORDER BY clause
For most relational database systems, this order explains which names (columns or aliases) are valid because they must have been introduced in a previous step.
So in Oracle and SQL Server, you cannot use a term in the GROUP BY clause that you define in the SELECT clause because the GROUP BY is executed before the SELECT clause.
There are exceptions though: MySQL and Postgres seem to have additional smartness that allows it.

問題描述:
SELECT country AS c, YEAR(hiredate) AS yearhired, COUNT(*) AS numemployees
FROM HR.Employees
WHERE hiredate >= '20140101'
GROUP BY country, YEAR(hiredate)
-- GROUP BY country, yearhired -- 無效的資料行名稱 'yearhired'。
HAVING COUNT(*) > 1
ORDER BY country, yearhired DESC;
--ORDER BY c, yearhired DESC; --可以執行