0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Db2 Express-C 10.1 を Macにインストール

Last updated at Posted at 2019-11-15

思いつきでDb2をMacにいれてみよう、と思ったのでやってみた。

手順

参照記事: Stack Overflow How do I install db2 Express-C 10.1 on OSX Mavericksを参考にインストール。
参考記事: DB2 on Mac for DBFlute

ここからエラーの解決手順

まず一番最初。これは何も考えずに下記コマンドを実行し、内容を追記すればよいです。

1.Modify system parameters with this command:

$ sudo vi /etc/sysctl.conf
kern.sysv.shmmax=1073741824
kern.sysv.shmmin=1
kern.sysv.shmmni=4096
kern.sysv.shmseg=32
kern.sysv.shmall=1179648
kern.maxfilesperproc=65536
kern.maxfiles=65536

13.Initialize the sample database using this command:
db2sampl

次にここでこけました。

$ db2sampl
SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR  
PASSWORD INVALID"). SQLSTATE=08001

エラーが発生。

これは db2sampl コマンドを発行したのがadminユーザーだったため。

$ su db2inst1

を実行します。
そしてsuした後に、bashを編集します。(一番はじめはadminユーザー側のbashを編集してしまった。)

しかし、db2samplインスタンスが作れない。。

bash-3.2$ db2sampl

  Starting the DB2 instance...
  Creating database "SAMPLE"...
  Attempt to create the database "SAMPLE" failed.
  SQL1032N  No start database manager command was issued.  SQLSTATE=57019

db2startしたらいいだけ?と思い発行

bash-3.2$ db2start
SQL1042C  An unexpected system error occurred.

意味不明なエラーすぎますね。
ですがググった結果下記を実行すれば次に進んだ。

$ sudo chown db2inst1 /Users/db2inst1/sqllib/adm/*
$ sudo -i -u db2inst1 /Users/db2inst1/sqllib/adm/db2start
SQL1063N  DB2START processing was successful.

次はコードページとテリトリーコードの違いのエラー。。

bash-3.2$ db2sampl

  Creating database "SAMPLE"...
  Attempt to create the database "SAMPLE" failed.
  SQL1205N  The code page "1208" and/or territory code "0" that has been 
specified is not valid.

とりあえず下記を実行

bash-3.2$ db2set DB2CODEPAGE=1208
bash-3.2$ db2set DB2TERRITORY=1
bash-3.2$ db2set DB2COUNTRY=1
bash-3.2$ db2 terminate
DB20000I  The TERMINATE command completed successfully.
bash-3.2$ db2sampl

  Creating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "DB2INST1"...
  Creating tables with XML columns and XML data in schema "DB2INST1"...

  'db2sampl' processing complete.

bash-3.2$ db2 connect to SAMPLE

   Database Connection Information

 Database server        = DB2/DARWIN 10.1.0
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

bash-3.2$ db2 list tables

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------
ACT                             DB2INST1        T     2019-11-15-17.35.35.019581
ADEFUSR                         DB2INST1        S     2019-11-15-17.35.35.560564
CATALOG                         DB2INST1        T     2019-11-15-17.35.36.203478
CL_SCHED                        DB2INST1        T     2019-11-15-17.35.34.915366
CUSTOMER                        DB2INST1        T     2019-11-15-17.35.36.160802
DEPARTMENT                      DB2INST1        T     2019-11-15-17.35.34.928925
DEPT                            DB2INST1        A     2019-11-15-17.35.34.952615
EMP                             DB2INST1        A     2019-11-15-17.35.34.966517
EMPACT                          DB2INST1        A     2019-11-15-17.35.35.018150
EMPLOYEE                        DB2INST1        T     2019-11-15-17.35.34.953254
EMPMDC                          DB2INST1        T     2019-11-15-17.35.35.732809
EMPPROJACT                      DB2INST1        T     2019-11-15-17.35.35.012793
EMP_ACT                         DB2INST1        A     2019-11-15-17.35.35.018845
EMP_PHOTO                       DB2INST1        T     2019-11-15-17.35.34.967025
EMP_RESUME                      DB2INST1        T     2019-11-15-17.35.34.978571
INVENTORY                       DB2INST1        T     2019-11-15-17.35.36.153554
IN_TRAY                         DB2INST1        T     2019-11-15-17.35.35.031703
ORG                             DB2INST1        T     2019-11-15-17.35.35.035364
PRODUCT                         DB2INST1        T     2019-11-15-17.35.36.138174
PRODUCTSUPPLIER                 DB2INST1        T     2019-11-15-17.35.36.244712
PROJ                            DB2INST1        A     2019-11-15-17.35.35.003532
PROJACT                         DB2INST1        T     2019-11-15-17.35.35.004115
PROJECT                         DB2INST1        T     2019-11-15-17.35.34.990695
PURCHASEORDER                   DB2INST1        T     2019-11-15-17.35.36.184609
SALES                           DB2INST1        T     2019-11-15-17.35.35.042211
STAFF                           DB2INST1        T     2019-11-15-17.35.35.038617
STAFFG                          DB2INST1        T     2019-11-15-17.35.35.498247
SUPPLIERS                       DB2INST1        T     2019-11-15-17.35.36.223280
VACT                            DB2INST1        V     2019-11-15-17.35.35.052692
VASTRDE1                        DB2INST1        V     2019-11-15-17.35.35.059804
VASTRDE2                        DB2INST1        V     2019-11-15-17.35.35.060979
VDEPMG1                         DB2INST1        V     2019-11-15-17.35.35.056553
VDEPT                           DB2INST1        V     2019-11-15-17.35.35.045812
VEMP                            DB2INST1        V     2019-11-15-17.35.35.050315
VEMPDPT1                        DB2INST1        V     2019-11-15-17.35.35.058499
VEMPLP                          DB2INST1        V     2019-11-15-17.35.35.073268
VEMPPROJACT                     DB2INST1        V     2019-11-15-17.35.35.055309
VFORPLA                         DB2INST1        V     2019-11-15-17.35.35.068494
VHDEPT                          DB2INST1        V     2019-11-15-17.35.35.049325
VPHONE                          DB2INST1        V     2019-11-15-17.35.35.072117
VPROJ                           DB2INST1        V     2019-11-15-17.35.35.051334
VPROJACT                        DB2INST1        V     2019-11-15-17.35.35.053680
VPROJRE1                        DB2INST1        V     2019-11-15-17.35.35.062221
VPSTRDE1                        DB2INST1        V     2019-11-15-17.35.35.063658
VPSTRDE2                        DB2INST1        V     2019-11-15-17.35.35.067136
VSTAFAC1                        DB2INST1        V     2019-11-15-17.35.35.069650
VSTAFAC2                        DB2INST1        V     2019-11-15-17.35.35.070860

  47 record(s) selected.

できた。。

とりあえずDb2をインストールするだけであれば、これで終了。

もしリモートサーバー上のDBとJavaクライアント等と接続したい場合は

参考資料の下記を続けて行なってください。

Steps to Enable Remote Connections:

特に難しい操作はないのですが、その通りにやってしまうと下記だけエラーが発生しました。

$ sudo -u db2inst1 db2start
SQL1641N  The db2start command failed because one or more DB2 database manager program files was prevented from executing with root privileges by file system mount settings.

db2startコマンドは、上記でやったように、

$ sudo -i -u db2inst1 /Users/db2inst1/sqllib/adm/db2start

を実行しましょう。
ここまで完了できたら、DBeaverなどでホストIP、ポート番号を正しく設定することで、Macからもリモートデータベースを参照することができます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?