Ubuntu 16.04 LTS + mono(c#) で Linux版 SQL Server にアクセスしてみる

Ubuntu 16.04 LTS + mono(c#) で LinuxSQL Server にアクセスしてみる

 

MONO + LLVM は下記でも試したのだが、16.04 LTS でのビルドは問題ないので、ついでに必要場部分だけまとめる

Ubuntu 18.04 で MONO + LLVM をビルドしてみる

※18.04 LTS ではビルドに失敗することが多い

動作の確認もかねて vs2017 で作成した SQL Server にアクセスするコードを動かしてみる

※もう少しちゃんとしたコードで試せよなぁ・・・

※フォークしているllvmが本体にマージされるまでは、この手順で試してみるかな?

※本体とのマージに関してはどこかに記述があった気はするんだけど

 

Ubuntu 16.04 LTS で MONO + LLVM をビルドしてみる

Mono LLVMのインストール

適当な dir で

$ git clone --recursive git://github.com/llvm.git
$ cd llvm
$ ./configure --prefix=/opt/llvm --enable-optimized --enable-targets="x86 x86_64"
$ make
$ sudo make install

以下の環境変数を設定する

export MONO_USE_LLVM=1
PATH=/opt/llvm/bin:/opt/mono/bin:$PATH:/opt/mssql-tools/bin

mono/monoのインストール

適当な dir で

$ git clone --recursive git@github.com:mono/mono
$ cd mono
$ ./autogen.sh --prefix=/opt/mono --with-llvm=/opt/llvm --enable-llvm --enable-loadedllvm --enable-llvm-runtime --with-wasm=yes
$ make
$ sudo make install

・VS2017で対象データにアクセスするコードを作成後 Ubuntu にコピー&修正する

※デフォで追加されている以下を削除

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System;
using System.Data.SqlClient;

namespace Con0001
{
    class Program
    {
        static void Main(string[] args)
        {
            string constr = @"Data Source=xxx.xxx.xx.xxx;";
            constr += "Initial Catalog=demo;";
            constr += "User ID=demo;";
            constr += "Password =demo;";
            constr += "Connect Timeout=60;";
            constr += "Persist Security Info=True";

            SqlConnection con = new SqlConnection(constr);
            con.Open();
            try
            {
                string sqlstr = "SELECT * FROM ZIPCODE WHERE SEQ = '00000001'";
                SqlCommand com = new SqlCommand(sqlstr, con);
                SqlDataReader sdr = com.ExecuteReader();

                while (sdr.Read() == true)
                {
                    Console.WriteLine(sdr["SEQ"] + "," + sdr["PREFCODE"] + "," + sdr["PREFKANJI"] + "," + sdr["CITIESKANJI"]);
                }
            }
            finally
            {
                Console.ReadLine();
               con.Close();
            }
        }
    }
}

$ mcs Con0001.cs -r:System.Data.dll

$ mono Con0001.exe

00000001,01 ,北海道 ,札幌市中央区

 

$ which mcs

/opt/mono/bin/mcs

$ which mono

/opt/mono/bin/mono

Ubuntu 16.04 LTS + mono(c#) で Linux版 SQL Server にアクセスしてみる

Ubuntu 16.04 LTS + mono(c#) で LinuxSQL Server にアクセスしてみる
 
MONO + LLVM は下記でも試したのだが、16.04 LTS でのビルドは問題ないので、ついでに必要場部分だけまとめる
Ubuntu 18.04 で MONO + LLVM をビルドしてみる
※18.04 LTS ではビルドに失敗することが多い
動作の確認もかねて vs2017 で作成した SQL Server にアクセスするコードを動かしてみる
※もう少しちゃんとしたコードで試せよなぁ・・・
※フォークしているllvmが本体にマージされるまでは、この手順で試してみるかな?
※本体とのマージに関してはどこかに記述があった気はするんだけど
 
Ubuntu 16.04 LTS で MONO + LLVM をビルドしてみる
Mono LLVMのインストール
適当な dir で


$ git clone --recursive git://github.com/llvm.git
$ cd llvm
$ ./configure --prefix=/opt/llvm --enable-optimized --enable-targets="x86 x86_64"
$ make
$ sudo make install
以下の環境変数を設定する

export MONO_USE_LLVM=1
PATH=/opt/llvm/bin:/opt/mono/bin:$PATH:/opt/mssql-tools/bin
mono/monoのインストール
適当な dir で

$ git clone --recursive git@github.com:mono/mono
$ cd mono
$ ./autogen.sh --prefix=/opt/mono --with-llvm=/opt/llvm --enable-llvm --enable-loadedllvm --enable-llvm-runtime --with-wasm=yes
$ make
$ sudo make install
・VS2017で対象データにアクセスするコードを作成後 Ubuntu にコピー&修正する
※デフォで追加されている以下を削除
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System;
using System.Data.SqlClient;

namespace Con0001
{
class Program
{
static void Main(string[] args)
{
string constr = @"Data Source=xxx.xxx.xx.xxx;";
constr += "Initial Catalog=demo;";
constr += "User ID=demo;";
constr += "Password =demo;";
constr += "Connect Timeout=60;";
constr += "Persist Security Info=True";

SqlConnection con = new SqlConnection(constr);
con.Open();
try
{
string sqlstr = "SELECT * FROM ZIPCODE WHERE SEQ = '00000001'";
SqlCommand com = new SqlCommand(sqlstr, con);
SqlDataReader sdr = com.ExecuteReader();

while (sdr.Read() == true)
{
Console.WriteLine(sdr["SEQ"] + "," + sdr["PREFCODE"] + "," + sdr["PREFKANJI"] + "," + sdr["CITIESKANJI"]);
}
}
finally
{
Console.ReadLine();
con.Close();
}
}
}
}

$ mcs Con0001.cs -r:System.Data.dll
$ mono Con0001.exe
00000001,01 ,北海道 ,札幌市中央区
 
$ which mcs
/opt/mono/bin/mcs
$ which mono
/opt/mono/bin/mono

Ubuntu 16.04 LTS で ASP.NET Core MVC のプロジェクトを作成してみる

Ubuntu 16.04 LTS で ASP.NET Core MVC のプロジェクトを作成してみる

 

VsCode で編集できるのかな?と試そうと思ったけど、まずはプロジェクトの作成から試してみることにする

 

VsCodeで実行する場合

launch.json を作成する

Project.csproj を開いて code runner で起動する

※出力パネルが文字化けする場合 export LANG=ja_JP.UTF-8 後再起動

※.profile に自分は追加

※ $ dotnet publish -c Debug -r ubuntu.16.04-x64  Project.csproj
  $ dotnet ./bin/Debug/netcoreapp2.1/ubuntu.16.04-x64/publish/samp0001.dll
 (相当を実行 かな?)
Ctrl+Alt+M で終了する

参考にしたのは以下のサイト

dotnet new

Ubuntu 16.04 LTS で ASP.NET Core を試してみる

・プロジェクトを新規作成する

$ dotnet new mvc -au None
テンプレート "ASP.NET Core Web App (Model-View-Controller)" が正常に作成されました。
このテンプレートには Microsoft 以外からのテクノロジが含まれています。詳細については https://aka.ms/aspnetcore-template-3pn-210 をご覧くださ い。

作成後のアクションを処理しています...
'dotnet restore' を /home/tabizou/dev/code/core/samp0001/samp0001.csproj で実行しています...
  /home/tabizou/dev/code/core/samp0001/samp0001.csproj のパッケージを復元しています...
  Microsoft.NETCore.DotNetAppHost 2.1.0 をインストールしています。
  Microsoft.NETCore.DotNetHostResolver 2.1.0 をインストールしています。
  Microsoft.NETCore.DotNetHostPolicy 2.1.0 をインストールしています。
  Microsoft.NETCore.Targets 2.1.0 をインストールしています。
  Microsoft.NETCore.App 2.1.0 をインストールしています。
  MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.props を生成しています。
  MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.targets を生成しています。
  /home/tabizou/dev/code/core/samp0001/samp0001.csproj の復元が 12.47 sec で完了しました。

正常に復元されました。

・作成された csproj の内容を比較する(2.0 と 2.1 の違いはあるんだけど)

$ cat samp0001.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

・vs2017 Community で作成したプロジェクトのファイル

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
  </ItemGroup>

</Project>

・実行イメージを作成してみる

$ dotnet publish -c Release -r ubuntu.16.04-x64  samp0001.csproj
.NET Core 向け Microsoft (R) Build Engine バージョン 15.7.179.6572
Copyright (C) Microsoft Corporation.All rights reserved.

  /home/tabizou/dev/code/core/samp0001/samp0001.csproj のパッケージを復元しています...
  runtime.linux-x64.Microsoft.NETCore.DotNetAppHost 2.1.1 をインストールしています。
  runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver 2.1.1 をインストールしています。
  runtime.linux-x64.Microsoft.NETCore.DotNetHostPolicy 2.1.1 をインストールしています。
  runtime.linux-x64.Microsoft.NETCore.App 2.1.1 をインストールしています。
  MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.props を生成しています。
  MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.targets を生成しています。
  /home/tabizou/dev/code/core/samp0001/samp0001.csproj の復元が 44.21 sec で完了しました。
  samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/samp0001.dll
  samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/samp0001.Views.dll
  samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish/

・起動してみる

$ dotnet ./bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish/samp0001.dll
Hosting environment: Production
Content root path: /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

https://localhost:5001/ で正しく表示されることを確認

Ubuntu 16.04 LTS で ASP.NET Core MVC のプロジェクトを作成してみる

Ubuntu 16.04 LTS で ASP.NET Core MVC のプロジェクトを作成してみる
 
VsCode で編集できるのかな?と試そうと思ったけど、まずはプロジェクトの作成から試してみることにする
 
VsCodeで実行する場合
launch.json を作成する
Project.csproj を開いて code runner で起動する
※出力パネルが文字化けする場合 export LANG=ja_JP.UTF-8 後再起動
※.profile に自分は追加


※ $ dotnet publish -c Debug -r ubuntu.16.04-x64 Project.csproj
  $ dotnet ./bin/Debug/netcoreapp2.1/ubuntu.16.04-x64/publish/samp0001.dll
 (相当を実行 かな?)
Ctrl+Alt+M で終了する
参考にしたのは以下のサイト
dotnet new
Ubuntu 16.04 LTS で ASP.NET Core を試してみる

・プロジェクトを新規作成する


$ dotnet new mvc -au None
テンプレート "ASP.NET Core Web App (Model-View-Controller)" が正常に作成されました。
このテンプレートには Microsoft 以外からのテクノロジが含まれています。詳細については https://aka.ms/aspnetcore-template-3pn-210 をご覧くださ い。

作成後のアクションを処理しています...
'dotnet restore' を /home/tabizou/dev/code/core/samp0001/samp0001.csproj で実行しています...
/home/tabizou/dev/code/core/samp0001/samp0001.csproj のパッケージを復元しています...
Microsoft.NETCore.DotNetAppHost 2.1.0 をインストールしています。
Microsoft.NETCore.DotNetHostResolver 2.1.0 をインストールしています。
Microsoft.NETCore.DotNetHostPolicy 2.1.0 をインストールしています。
Microsoft.NETCore.Targets 2.1.0 をインストールしています。
Microsoft.NETCore.App 2.1.0 をインストールしています。
MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.props を生成しています。
MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.targets を生成しています。
/home/tabizou/dev/code/core/samp0001/samp0001.csproj の復元が 12.47 sec で完了しました。

正常に復元されました。

・作成された csproj の内容を比較する(2.0 と 2.1 の違いはあるんだけど)

$ cat samp0001.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>

・vs2017 Community で作成したプロジェクトのファイル

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>

</Project>

・実行イメージを作成してみる

$ dotnet publish -c Release -r ubuntu.16.04-x64 samp0001.csproj
.NET Core 向け Microsoft (R) Build Engine バージョン 15.7.179.6572
Copyright (C) Microsoft Corporation.All rights reserved.

/home/tabizou/dev/code/core/samp0001/samp0001.csproj のパッケージを復元しています...
runtime.linux-x64.Microsoft.NETCore.DotNetAppHost 2.1.1 をインストールしています。
runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver 2.1.1 をインストールしています。
runtime.linux-x64.Microsoft.NETCore.DotNetHostPolicy 2.1.1 をインストールしています。
runtime.linux-x64.Microsoft.NETCore.App 2.1.1 をインストールしています。
MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.props を生成しています。
MSBuild ファイル /home/tabizou/dev/code/core/samp0001/obj/samp0001.csproj.nuget.g.targets を生成しています。
/home/tabizou/dev/code/core/samp0001/samp0001.csproj の復元が 44.21 sec で完了しました。
samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/samp0001.dll
samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/samp0001.Views.dll
samp0001 -> /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish/

・起動してみる

$ dotnet ./bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish/samp0001.dll
Hosting environment: Production
Content root path: /home/tabizou/dev/code/core/samp0001/bin/Release/netcoreapp2.1/ubuntu.16.04-x64/publish
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

https://localhost:5001/ で正しく表示されることを確認

Ubuntu 16.04 LTS で ASP.NET Core を試してみる

Ubuntu 16.04 LTS で ASP.NET Core を試してみる

 

そういえばそんな話もあったよね・・・ ということで試してみる

開発環境は Windows 10 Pro x64 + VS2017 Community

 

参考にしたのは以下のサイト

Nginx 搭載の Linux で ASP.NET Core をホストする

.NET Core で dll ではなく、exe を作りたい

Get started with ASP.NET Core以下

dotnet publish

 

・インストール

All Downloads

から current を選択後 ubuntu のバージョンを選択

Install .NET Core 2.1 SDK (v2.1.301) on Linux Ubuntu 16.04

を参考に

$ wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
$ sudo apt-get install apt-transport-https
$ sudo apt-get update
$ sudo apt-get install dotnet-sdk-2.1
~
取得:1 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liburcu4 amd64 0.9.1-3 [47.3 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust-ctl2 amd64 2.7.1-1 [72.2 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust0 amd64 2.7.1-1 [127 kB]
取得:4 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-deps-2.1 amd64 2.1.1-1 [2,604 B]
取得:5 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-host amd64 2.1.1-1 [36.4 kB]
取得:6 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-hostfxr-2.1 amd64 2.1.1-1 [143 kB]
取得:7 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-2.1 amd64 2.1.1-1 [20.5 MB]
取得:8 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 aspnetcore-runtime-2.1 amd64 2.1.1-1 [22.1 MB]
取得:9 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-sdk-2.1 amd64 2.1.301-1 [87.5 MB]
~
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. 
The data is anonymous and doesn't include command-line arguments. The data is collected 
by Microsoft and shared with the community. 
You can opt-out of telemetry by setting the 
DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed 
and enable offline access. This command takes up to one minute to complete and only runs once.
libc-bin (2.23-0ubuntu10) のトリガを処理しています ...

microsoft-prod.list と msprod.list が同一なので microsoft-prod.listを削除

※プロダクトごとに名前を変えるなって気もする

 

ASP.NET Core のアプリを作成して Ubuntu で動かしてみる

.NET Core

 -> ASP.NET Core Web アプリケーション

  -> Web アプリケーション

> dotnet publish -c Release -r ubuntu.16.04-x64 Core0001\Core0001.csproj
~
Restore completed in 1.27 min for C:\Dev\code\vs2017\Core0001\Core0001\Core0001.csproj.
Core0001 -> C:\Dev\code\vs2017\Core0001\Core0001\bin\Release\netcoreapp2.0\ubuntu.16.04-x64\Core0001.dll
Core0001 -> C:\Dev\code\vs2017\Core0001\Core0001\bin\Release\netcoreapp2.0\ubuntu.16.04-x64\publish\

publish フォルダごと WinSCPUbuntu にコピーする

※sambaが楽なんだろうなぁ・・・

$ cd publish
$ dotnet Core0001.dll
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {76244e4e-d7d6-451d-a0cd-022e99508643} may be persisted to storage in unencrypted form.
Hosting environment: Production
Content root path: /home/tabizou/dev/code/core/publish
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

ブラウザで http://localhost:5000 をアクセスして動作を確認

Ubuntu 16.04 LTS で ASP.NET Core を試してみる

Ubuntu 16.04 LTS で ASP.NET Core を試してみる
 
そういえばそんな話もあったよね・・・ ということで試してみる
開発環境は Windows 10 Pro x64 + VS2017 Community
 
参考にしたのは以下のサイト
Nginx 搭載の Linux で ASP.NET Core をホストする
.NET Core で dll ではなく、exe を作りたい
Get started with ASP.NET Core以下
dotnet publish
 
・インストール
All Downloads
から current を選択後 ubuntu のバージョンを選択
Install .NET Core 2.1 SDK (v2.1.301) on Linux Ubuntu 16.04
を参考に


$ wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
$ sudo apt-get install apt-transport-https
$ sudo apt-get update
$ sudo apt-get install dotnet-sdk-2.1

取得:1 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liburcu4 amd64 0.9.1-3 [47.3 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust-ctl2 amd64 2.7.1-1 [72.2 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust0 amd64 2.7.1-1 [127 kB]
取得:4 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-deps-2.1 amd64 2.1.1-1 [2,604 B]
取得:5 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-host amd64 2.1.1-1 [36.4 kB]
取得:6 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-hostfxr-2.1 amd64 2.1.1-1 [143 kB]
取得:7 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-2.1 amd64 2.1.1-1 [20.5 MB]
取得:8 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 aspnetcore-runtime-2.1 amd64 2.1.1-1 [22.1 MB]
取得:9 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-sdk-2.1 amd64 2.1.301-1 [87.5 MB]

This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET Core!

                                        • -

Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry

                • -

The .NET Core tools collect usage data in order to help us improve your experience.
The data is anonymous and doesn't include command-line arguments. The data is collected
by Microsoft and shared with the community.
You can opt-out of telemetry by setting the
DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...

                          • -

A command is running to populate your local package cache to improve restore speed
and enable offline access. This command takes up to one minute to complete and only runs once.
libc-bin (2.23-0ubuntu10) のトリガを処理しています ...

microsoft-prod.list と msprod.list が同一なので microsoft-prod.listを削除
※プロダクトごとに名前を変えるなって気もする
 
ASP.NET Core のアプリを作成して Ubuntu で動かしてみる
.NET Core
 -> ASP.NET Core Web アプリケーション
  -> Web アプリケーション

> dotnet publish -c Release -r ubuntu.16.04-x64 Core0001\Core0001.csproj

Restore completed in 1.27 min for C:\Dev\code\vs2017\Core0001\Core0001\Core0001.csproj.
Core0001 -> C:\Dev\code\vs2017\Core0001\Core0001\bin\Release\netcoreapp2.0\ubuntu.16.04-x64\Core0001.dll
Core0001 -> C:\Dev\code\vs2017\Core0001\Core0001\bin\Release\netcoreapp2.0\ubuntu.16.04-x64\publish\
publish フォルダごと WinSCPUbuntu にコピーする
※sambaが楽なんだろうなぁ・・・

$ cd publish
$ dotnet Core0001.dll
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {76244e4e-d7d6-451d-a0cd-022e99508643} may be persisted to storage in unencrypted form.
Hosting environment: Production
Content root path: /home/tabizou/dev/code/core/publish
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
ブラウザで http://localhost:5000 をアクセスして動作を確認

Ubuntu 16.04 LTS に fess-12.1.3.deb をインストールしてみる

Ubuntu 16.04 LTS に fess-12.1.3.deb をインストールしてみる

 

以前 Windows 10 にインストールしてみたんだが Ubuntu でも試してみる

※wi版でやったのと全然違うのね・・・・・

ついでにPostgreSQL10のドキュメントも作成してみる

 

参考にしたのは以下のサイト

Ubuntu 16.04 LTS に Fess(deb版) を 外部 Elasticsearch を使う設定でインストールする方法

Ubuntuユーザ追加とsudo権限付与。ユーザ/グループ操作まとめ

 

以下は SQLDeveloper用にインストール済

$ sudo apt-get install openjdk-8-jre-headless

$ sudo apt-get install openjdk-8-jdk-headless

$ sudo apt-get install openjfx

 

・Elasticsearch をインストールする

Download Elasticsearch

より プラグインに対応しているバージョンをDLする(最新版とは合っていない感じ)

org/codelibs/elasticsearch-analysis-fess等でpluginのバージョンを確認する

$ sudo dpkg -i elasticsearch-6.2.1.deb

 

・fess をインストールする

ダウンロード

より 安定版の最新版をDLする>fess-12.1.3.deb

$ sudo dpkg -i fess-12.1.3.deb

# vipw で以下を確認

fess:x:122:129::/var/lib/fess:/bin/false

# cat /etc/group で以下を確認

fess:x:129:

 

・Elasticsearch の設定ファイルに追記する

/etc/elasticsearch/elasticsearch.yml の最下行に以下の表記を追加する

configsync.config_path: /var/lib/elasticsearch/config

 

・Elasticsearch のプラグインをインストールする

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-fess:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-ja:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-synonym:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-configsync:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-dataformat:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-langfield:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-minhash:6.2.1

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-kuromoji-neologd:6.2.1

 

・Fess の設定ファイルを修正する

/usr/share/fess/bin/fess.in.sh で以下をコメントアウト&修正

# ES_HTTP_URL=http://localhost:9200

# ES_TRANSPORT_URL=localhost:9300

# FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/

FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.port=8088" # port:8088に

 

$ sudo systemctl start elasticsearch.service

http://localhost:9200/ にアクセスして正常に表示されることを確認する

 

$ sudo systemctl status fess.service

http://localhost:8088/ にアクセスして正常に表示されることを確認する

 

$ sudo systemctl start elasticsearch.service

$ sudo systemctl stop elasticsearch.service

$ sudo systemctl restart elasticsearch.service

$ sudo systemctl status elasticsearch.service

 

$ sudo systemctl start fess.service

$ sudo systemctl stop fess.service

$ sudo systemctl restart fess.service

$ sudo systemctl status fess.service

自動起動の設定 

$ sudo systemctl list-unit-files --type=service | grep fess.service

fess.service disabled

$ sudo systemctl list-unit-files --type=service | grep elasticsearch.service

elasticsearch.service disabled

$ sudo systemctl enable fess

$ sudo systemctl enable elasticsearch

再起動後、自elasticsearch, fess が起動していることを確認

 

PostgreSQL10のドキュメントを作成する

・必要なパッケージのインストール

$ sudu apt-get install -y libreadline6-dev \

zlib1g-dev \

flex \

bison \

libxslt-dev \

jade \

docbook \

docbook-dsssl \

docbook-xml \

docbook-xsl \

gettext \

sp \

libxml2-utils \

xsltproc

 

$ which collateindex.pl

/usr/bin/collateindex.pl

 

$ git clone git@github.com:pgsql-jp/jpug-doc

$ ./configure --enable-nls --with-libxml --with-libxslt

 

ドキュメントのビルド

・トップディレクトリで以下を実行すると、doc/src/sgml/html に html が生成される

$ make html

 

再度、全ビルドをしたい場合

・一度 make html をすると移行差分だけの更新になります。再度全ドキュメントを更新したい場合は、

$ make clean

$ make html

としても、更新がおこなわれないので(生成されたhtmlフォルダを削除してもダメです)

一度sgmlのファイルを更新してから再生成する

$ touch ./doc/src/sgml/*.sgml

$ make html

$ cd doc/src/sgml/html

 

・dir の作成&ファイルのコピー

$ sudo mkdir /var/export/web/fess

$ chown fess /var/export/web/fess

$ chgrp fess /var/export/web/fess

$ sudo mkdir /var/export/web/fess/pgsql10

$ sudo chgrp fess /var/export/web/fess/pgsql10

$ sudo chown fess /var/export/web/fess/pgsql10

$ su - fess

$ cp -r * /var/export/web/fess/pgsql10/

 

http://localhost:8088/admin/ にアクセス

 Crawler

 ->File System

  ->Create New ボタン

   Name:Postgres 10

   Paths:file:/var/export/web/fess/pgsql10/

   Included Paths For Indexing:file:/var/export/web/fess/pgsql10/.+\.html$

   Excluded Paths For Indexing:file:/var/export/web/fess/pgsql10/.+\.css$

   +Create ボタン

 

 System

 ->Scheduler

  ->Default Crawler をクリック

   ->Start Now ボタンをクリック

$ sudo tail -f /var/log/fess/fess-crawler.log

cssファイルが対象外になると思っていたけど、違うなぁ・・・

終了後 TOPの画面から Postgres で検索してみる