0
3

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.

LinuxのDB環境構築

Last updated at Posted at 2018-07-29

CentOS 7.5の環境に構築する。

Oracle

Oracle11gR2(64bit)をインストールする
11.2.0.1.0 Standard Editionをダウンロードする。

ファイル

約2GB
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

参考URL

https://docs.oracle.com/cd/E16338_01/index.htm
https://docs.oracle.com/cd/E16338_01/install.112/b56277/toc.htm

必要なディスク容量

ソフトウェア 4.6GB
データファイル 1.5GB

ODBC

Red Hat Enterprise Linux 6

unixODBC-2.2.14-11以上

Red Hat Enterprise Linux 7

unixODBC-2.3.1-6以上

インストール手順(suで実行)

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
passwd oracle
カーネルパラメータとリソース制限の構成
mkdir -p /u01/app/
chown -R oracle:oinstall /u01/app/
chmod -R 775 /u01/app/

zipを展開し、oracleユーザーの権限で/u01下に移動する。

.bashrcに以下を追加
DISPLAY=:0.0; export DISPLAY

xhost +
./runInstaller

文字化けする場合は以下を参考にする
http://abcmark2010.hatenablog.com/entry/2016/01/10/140549
readlink -e /usr/bin/java
sh ./runInstaller -jreLoc /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64/jre

インストールオプションでは、「データベース・ソフトウェアのみインストール」を選択する。

インストール中にOSカーネルパラメータのチェックに失敗した場合は、「修正および再チェック」でrootユーザーで修正用のスクリプトを実行する。

インストール中に失敗したらモジュールが足りないのが原因。
yum install binutils
yum install compat-libcap1
yum install compat-libstdc++-33
yum install ksh

yum install gcc
yum install libaio-devel
yum install unixODBC

モジュールインストール

su - root
cd /etc/yum.repos.d/
wget https://public-yum.oracle.com/public-yum-ol6.repo --no-check-certificate
wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle --no-check-certificate
yum install oracle-rdbms-server-11gR2-preinstall
yum install unixODBC-devel
yum install unixODBC
yum install elfutils-libelf-devel

文字化け対応

https://virtnote.blogspot.com/2014/01/centos-6x-oracle.html?m=1
yum install ipa-gothic-fonts
yum install ipa-mincho-fonts
cd /usr/share/fonts ; mkdir -p ja/TrueType
cd /usr/share/fonts/ja/TrueType ; ln -s ../../ipa-gothic/ipag.ttf ./kochi-gothic-subst.ttf
cd /usr/share/fonts/ja/TrueType ; ln -s ../../ipa-mincho/ipam.ttf ./kochi-mincho-subst.ttf

インストール後の設定

vi .bash_profile
以下を追加
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin

以下を実行
netca
dbca

ODBC接続

https://qiita.com/mon_tu/items/772cc46ab6518bf9e73a
http://ksaito11.blogspot.com/2014/02/ubuntu1310unixodbcisqloracle.html
https://gerardnico.com/db/oracle/odbc_linux

[ORA]
Driver = /u01/app/oracle/product/11.2.0/dbhome_1/lib/libsqora.so.11.1
ServerName=***
UserID=***
Password=****

ユーザー名はUserNameではなくUserID

使い方

起動確認

MySQL

MySQL5.6をインストールする

参考URL

インストール手順

yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum -y install mysql-community-server

yumリポジトリ
https://dev.mysql.com/downloads/repo/yum/

バージョン確認

mysqld --version

ユーザーの作成

CREATE USER 'user2'@'%' IDENTIFIED WITH mysql_native_password BY 'mypass';
GRANT ALL ON . TO 'user2'@'%';

起動と停止

service mysqld start
service mysqld stop
自動起動
chkconfig mysqld on

ODBC

yum install mysql-connector-odbc
以下がインストールされた
mysql-connector-odbc-8.0.12-1.el6.x86_64

ODBC.ini

[mysqlsjis]
Driver=/usr/lib64/libmyodbc8a.so
Server=localhost
Port=3306
User=ユーザ名
Password=パスワード
Database=DB名
charset=cp932

エラー

INSERT時に「Incorrect string value」

PostgreSQL

PostgreSQL 9.6をインストールする。

インストール

yum install -y https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
yum install -y postgresql96-server postgresql96-contrib
DB作成。上のコマンドが見つからない場合はsu - postgresqlでユーザーを変更し、下のコマンドを実行する。(RHEL6と7の違い?)
/usr/pgsql-9.6/bin/postgresql96-setup initdb
/usr/pgsql-9.6/bin/initdb --encoding=utf8 --no-locale

バージョン確認

psql --version

起動と停止

RHEL7

systemctl start postgresql-9.6.service
systemctl stop postgresql-9.6.service

RHEL6

service postgresql-9.6 start

接続準備

passwd postgres
su - postgres
psql
create role {ユーザー名} login createdb password '{パスワード}';

ODBC

yum install postgresql96-odbc

Windows

https://www.postgresql.org/ftp/odbc/versions/msi/
Windows10(64bit)に「psqlodbc_09_06_0500-x86.zip」を入れてみた。

参考URL

ident認証で失敗する場合

ODBC接続するための設定

/var/lib/pgsql/9.6/data/pg_hba.conf
ファイルを編集する。

host all all 127.0.0.1/32 trust

host all all 0.0.0.0/0 trust
また、postgresq.confファイルも編集する。
listen_addresses = '*' ←コメントを解除し、''内を * に修正

0
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?