Windowsのhostsにワイルドカードを使いたい(proxy.pacの活用)

OpenShiftの試験中、例えば、「osakana.local」というADドメインに参加しているクライアント端末から、テスト環境「apps.osakana.local」に作ったOpenShift上に作ったサービスにアクセスしようとする。

このとき、ADドメインの方に「*.app.osakana.local A 192.168.12.132」といったような感じでDNSレコードが登録されていれば特に問題はない。

しかし、テスト段階では、DNS登録がされていない場合がある。その場合、c:\windows\system32\drivers\etc\hosts にエントリを書くという手段があるが、hostsファイルにはワイルドカード記述を書くことはできないので、いちいち列挙していく必要があるし、管理者権限が必要になる。

権限が低くても対処する方法があるのか確認してたところ、ブラウザのproxy設定で自動構成スクリプトproxy.pacを設定する、という適用しやすい手法があった。

まず、下記記述のproxy.pacファイルを作成する。

function FindProxyForURL(url, host) {
  if (shExpMatch(host, "*.app.osakana.local")) {
    return "PROXY 192.168.12.132";
  }
  return "DIRECT";
}

上記ファイルをproxy設定の「自動構成スクリプトを使用する」のアドレス欄で指定する。

Windows10の場合「file:///~」といった記述をしなくても、そのままのドライブパスで問題なかった。


2026/01/16追記

Windows 11の場合、プロキシ設定の「セットアップ スクリプトを使う」が該当するようだ

関連ドキュメント

Microsoft: Windows でプロキシ サーバーを使用する の プロキシサーバー接続を自動的に設定するには
Moziila: プロキシー自動構成ファイル (PAC)

MSSQL Always on構成でのデータベースリカバリ手順の概要

MSSQL Always on構成で、バックアップソフトを使ってデータベースバックアップを行っている場合、リストア/リカバリをどのように行うのか、わかりにくかったのでメモ。

(1) SQLマネージメントスタジオでAlways on設定から該当データベースを削除

(2) フェールオーバークラスタマネージャーにてSQLの役割を全て停止(一部だけだとうまくいかないケースあり)

(3)バックアップソフトからリストア実施

(4)フェールオーバークラスタマネージャーにてSQLの役割を開始

(5)SQLマネージメントスタジオでAlways on設定に該当データベースを追加

Orange Piの新製品はAIスティックのOrange Pi AI Stick 2801 $74.12

ここしばらく新製品が出ていなかったOrange Piより新製品が・・・

Orange Pi AI Stick 2801

gyrfalcon社の「Lightspeeur 2801S」というチップを使っている。

ウリは0.3Wで2.8TOPSという性能が出せるというもの。

2018年1月のLightspeeur 2801S出荷開始に関する記事「IntelのAIスティック比で効率90倍、Gyrfalconが対抗品」で、競合製品であるIntelの「Movidius Neural Compute Stick(Movidius NCS)」との比較して電力効率が90倍、という話が書かれている。
で、おととい、新製品の「Movidius Neural Compute Stick 2」が発表&発売された。
Intel、性能が8倍に向上したUSB式AIアクセラレータ「Neural Compute Stick 2」」によれば、「Movidius Neural Compute Stickの8倍の性能」としており、また「1TOPS」とも記載されている。

つまりは、Lightspeeur 2801Sは、現状であっても、「Neural Compute Stick 2」よりは高性能であるらしい。

ただ、問題点としては、資料が少ない、ということ。
果たして、どの程度使い物になるのか???

SQL Management Studioでunixtimeを1分おきにINSERTするSQL文

バックアップの試験のため、定期的にMSSQLデータベースの指定テーブル上にデータをインサートさせる必要が出た。

データベース「pubs」にテーブル「test3」を作り、そこに数字を格納する「counter」を作成。

create table [pubs].[dbo].[test3](
[counter][CHAR](128)NULL
) on [PRIMARY]

そして、ここに対して、1分おきにunixtimeで時刻を追加していく、というもの

下記はとりあえず40分実行するサンプル

declare @i int
declare @date numeric
set @i = 1
while @i < 40
begin
 SELECT @date = DATEDIFF(s,'1970/1/1', GETUTCDATE() );
 insert into [pubs].[dbo].[test3](counter)values (@date);
 set @i = @i + 1
 waitfor delay '00:01:00' 
end

なお、データを確認する場合は、以下を実行する

select * from [pubs].[dbo].[test3];

Orange Pi 2/armbianでVMware PowerCLIが動いた

先日、「CentOS7環境にPowerShell CoreとVMware PowerCLIをインストール」で書いたように、普通のCentOS7環境でVMware PowerCLIを動かしてみた。

で、ラズパイの上でもPowerShell Coreは動く。
Running PowerShell Core on Raspberry Pi 2

arm32というくくりでは同じだけど、SoCがAllwinner H3のOrange Pi 2でPowerShell Coreが動くか、
また、VMware PowerCLIがインストールでき、仮想マシン操作を行えるかを確認してみた。

現時点では、ARM Linux向けにはtar.gzで固めたものしか出ていないのでgithubのPowerShell Releasesからlinux-arm32.tar.gzとなっているものを入手。

2018/07/13時点だと「wget https://github.com/PowerShell/PowerShell/releases/download/v6.1.0-preview.3/powershell-6.1.0-preview.3-linux-arm32.tar.gz」でダウンロードした。

これを~/powershellディレクトリに展開

# mkdir ~/powershell
# cd ~/powershell
# tar xfz ../powershell-6.1.0-preview.3-linux-arm32.tar.gz
#

そして、PowerShell Coreを実行

PS /root> uname -a
uname -a
Linux orangepi2 4.14.18-sunxi #24 SMP Fri Feb 9 16:24:32 CET 2018 armv7l GNU/Linux
PS /root> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.3
PSEdition                      Core
GitCommitId                    v6.1.0-preview.3
OS                             Linux 4.14.18-sunxi #24 SMP Fri Feb 9 16:24:3...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS /root>

普通に動いているようだ。

続いて、PowerCLIのインストール

PS /root> Install-Module -Name VMware.PowerCLI

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
 cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "N"):y
PS /root>

何事もなく終了。
モジュールの確認

PS /root> Install-Module -Name VMware.PowerCLI

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
 cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "N"):y
PS /root>
PS /root> Get-Module                                                            
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clea...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-T...
Script     1.1.7.0    PackageManagement                   {Find-Package, Fin...
Script     1.6.0      PowerShellGet                       {Find-Command, Fin...
Script     2.0.0      PSReadLine                          {Get-PSReadLineKey...


PS /root> Get-Module -ListAvailable


    Directory: /usr/local/share/powershell/Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.7.0.8... VMware.DeployAutomation             {Add-DeployRule, A...
Script     6.7.0.8... VMware.ImageBuilder                 {Add-EsxSoftwareDe...
Manifest   10.1.1.... VMware.PowerCLI
Script     6.7.0.8... VMware.Vim
Script     10.1.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer...
Script     10.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, ...
Script     10.1.0.... VMware.VimAutomation.Common
Script     10.1.0.... VMware.VimAutomation.Core           {Add-PassthroughDe...
Script     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo
Script     7.5.0.8... VMware.VimAutomation.HorizonView    {Connect-HVServer,...
Script     10.0.0.... VMware.VimAutomation.License        Get-LicenseDataMan...
Script     10.1.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServe...
Script     10.0.0.... VMware.VimAutomation.PCloud         {Connect-PIServer,...
Script     10.1.0.... VMware.VimAutomation.Sdk
Script     10.0.0.... VMware.VimAutomation.Srm            {Connect-SrmServer...
Script     10.1.0.... VMware.VimAutomation.Storage        {Add-KeyManagement...
Script     1.2.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script     10.1.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysi...
Script     10.0.0.... VMware.VimAutomation.Vmc            {Connect-Vmc, Disc...
Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer,...
Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaselin...


    Directory: /root/powershell/Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.1.0.0    Microsoft.PowerShell.Archive        {Compress-Archive,...
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript,...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clea...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Credential, G...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Form...
Script     1.1.7.0    PackageManagement                   {Find-Package, Get...
Script     1.6.0      PowerShellGet                       {Install-Module, F...
Script     0.0        PSDesiredStateConfiguration         {ThrowError, Node,...
Script     2.0.0      PSReadLine                          {Get-PSReadLineKey...


PS /root>

で・・・画面は省略しますが、connect-viserverして、get-vmして、とか普通に動きました。