Db2

在 linux (LUW) 上使用 db2 express c 執行 db2start 時在 linux 上出現 SQL1641N 錯誤,但未使用 nosuid 掛載文件系統

  • December 30, 2015

我正在嘗試使用以下腳本在我的 linux 機器上安裝和啟動 db2:

#!/usr/bin/env bash

MKDIR=/bin/mkdir
RM=/bin/rm
TAR=/bin/tar

DB2_SERVER_PROGRAM_PATH=/home/alok/Documents/Installers
DB2_SERVER_PROGRAM=v10.5_linuxx64_expc.tar.gz

echo "changing to $DB_SERVER_PROGRAM_PATH"
cd ${DB2_SERVER_PROGRAM_PATH}
echo "removing expc"
${RM} -rf expc
echo "untarring ${DB2_SERVER_PROGRAM}"
${TAR} zxf ${DB2_SERVER_PROGRAM}

echo "changing to expc"
cd expc

echo "Installing db2 as root"
sudo ./db2_install

echo "Adding user group db2grp1 as root"
sudo groupadd db2grp1
echo "Adding user group dasadm1 as root"
sudo groupadd dasadm1
echo "Adding user group db2fgrp1 as root"
sudo groupadd db2fgrp1

echo "Adding user db2inst1. Please provide password for new user db2inst1."
sudo useradd -g db2grp1 -G dasadm1 -m db2inst1
sudo passwd db2inst1

echo "Adding user dasusr1. Please provide password for new user dasusr1."
sudo useradd -g dasadm1 -G db2grp1 -m dasusr1
sudo passwd dasusr1

echo "Adding user db2fenc1. Please provide password for new user db2fenc1."
sudo useradd -g db2fgrp1 -m db2fenc1
sudo passwd db2fenc1

cd /opt/ibm/db2/V10.5/instance

echo "Creating DAS as root via user dasusr1."
sudo ./dascrt -u dasusr1

echo "Creating database instance as root via user db2fenc1 and db2inst1."
sudo ./db2icrt -u db2fenc1 db2inst1

echo "Setting communication protocol to tcpip as user db2inst1."
sudo -u db2inst1 ../adm/db2set DB2COMM=tcpip
echo "Setting SVCENAME 50000 for dbm cfg as user db2inst1."
sudo -u db2inst1 ../bin/db2 update dbm cfg using SVCENAME 50000

echo "starting db2 as user db2inst1."
sudo chmod +x ../adm/db2start
sudo -u db2inst1 ../adm/db2start

netstat -an | grep 50000

一切正常,直到我到達倒數第二行:

sudo -u db2inst1 ../adm/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.

現在我檢查了一下/etc/fstab,它說:

proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sda1       /               ext4    errors=remount-ro,user_xattr 0       1
UUID=d4d794eb-1e68-4ddf-a9ec-249a22f084fb none            swap    sw             0       0
/swapfile swap swap defaults 0 0

我的安裝路徑,/opt/ibm/db2/V10.5/adm基本上是打開/dev/sda1的,並且沒有使用該nosuid選項安裝。

這是輸出mount

alok@hostname:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro,user_xattr)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
shmfs on /dev/shm type tmpfs (rw,size=2048m)
gvfs-fuse-daemon on /home/alok/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=alok)

這再次表明/未安裝在nosuid模式下。那麼為什麼我會出錯SQL1641N?而是拋出此消息是一個不同的問題嗎?

中的文件/opt/ibm/db2/V10.5/不用於特定實例。當您執行該db2icrt命令時,它會將一系列文件和目錄複製到~db2inst1/sqllib中,並相應地設置權限。(其中的一些目錄~db2inst1/sqllib將軟連結回 中的目錄/opt/ibm/db2/V10.5)。

例如,您應該發現~db2inst1/sqllib/adm/db2start權限設置為6555(ie -r-sr-sr-x),由 擁有root,並且組所有者設置為實例所有者的主要組。

你不應該從/opt/ibm/db2/V10.5/adm. 這就是為什麼該目錄中文件的權限設置為它們的方式 -/opt/ibm/db2/V10.5/adm/db2start應該是0444.

因此,要啟動您的實例,您應該執行~db2inst1/sqllib/adm/db2start.

請注意,您還需要db2inst1在啟動實例之前初始化使用者環境,因此您應該使用-i選項 forsudo來處理此問題:

sudo -i -u db2inst1 /home/db2inst1/sqllib/adm/db2start

最後一點:所有這些配置(可能除了db2start)都可以使用響應文件db2setup. db2_install已被棄用,因此使用響應文件是處理此問題的方法。

引用自:https://dba.stackexchange.com/questions/49807