12.8. データベースの移行
12.8.1. 組み込みデータベースから管理データベースへの移行
- Red Hat Satellite のインストール ISO
- 組み込みデータベースを使用する Red Hat Satellite サーバーの完全インストール (
satellite.example.com) - 管理データベースをホストする Red Hat Enterprise Linux 6 がインストール済みの新規システム (
manageddb.example.com)
手順12.2 管理データベースへの移行
- Red Hat Satellite インスタンスをシャットダウンします。
[root@satellite ~]# rhn-satellite stop
- サーバーに
rhn-upgradeパッケージがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
db-controlを使ってデータベースのバックアップを作成します。[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# db-control backup ~/dbbackup
- Satellite サーバーから管理データベースサーバーにデータベースのバックアップをコピーします。
[root@satellite ~]# scp -r ~/dbbackup root@manageddb.example.com:~/.
- Red Hat Satellite インストール ISO を使用して管理データベースをインストールします。
- 管理データベースをインストールしたら、これをシャットダウンして、データベース設定ファイルおよびアクセス制御ファイルのバックアップを作成します。
[root@manageddb ~]# db-control stop [root@manageddb ~]# cp /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf ~/dbbackup [root@manageddb ~]# cp /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf ~/dbbackup
移行プロセスではこれらのファイルが削除されるため、バックアップの作成が必要になります。 db-controlを使ってデータベースのバックアップを管理データベースサーバーに復元します。[root@manageddb ~]# db-control restore ~/dbbackup
- データベース設定ファイルおよびアクセス制御ファイルをバックアップから管理データベースに復元します。
[root@manageddb ~]# cp ~/dbbackup/postgresql.conf /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf [root@manageddb ~]# cp ~/dbbackup/pg_hba.conf /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf
- Satellite サーバーでは、
/etc/rhn/rhn.confファイルを編集してdb_hostを管理データベースのドメイン名に変更し、db_portを 5432 に設定します。以下のようになります。db_host = manageddb.example.com db_port = 5432
- Satellite サーバーの
/etc/rhn/service-listファイルからrh-postgresql95-postgresqlを削除します。[root@satellite ~]# sed -i 's/rh-postgresql95-postgresql //g' /etc/rhn/service-list
- 管理データベースでは、
/etc/rhn/rhn.confファイルを編集し、db_name、db_user、db_passwordで Satellite サーバーにある/etc/rhn/rhn.confファイルの同一の値を反映させるように変更します。以下に例を示します。db_name = mydb db_user = mydbuser db_password = mydbpassword
db-controlを使って管理データベースのインスタンスを開始します。[root@manageddb ~]# db-control start
- Satellite サーバーから PostgreSQL と
spacewalk-dobbyのパッケージを削除します。[root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
- Red Hat Satellite を再起動します。
[root@satellite ~]# rhn-satellite start
12.8.2. 組み込みデータベースから外部 PostgreSQL データベースへの移行
- 組み込みデータベースを使用する Red Hat Satellite サーバーの完全インストール (
satellite.example.com) - 実行中の PostgreSQL (
postgresql.example.com) インスタンスをホストするシステム。設定の詳細については、「PostgreSQL データベースの要件」 を参照してください。
手順12.3 外部 PostgreSQL データベースへの移行
- Red Hat Satellite サーバー上ですべてのサービスをシャットダウンし、
db-controlで組み込みデータベースを起動します。[root@satellite ~]# rhn-satellite stop [root@satellite ~]# db-control start
- サーバーに
rhn-upgradeがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- データベースを最新のスキーマバージョンに更新します。
[root@satellite ~]# yum update satellite-schema [root@satellite ~]# spacewalk-schema-upgrade
これにより、使用中のデータベースのバージョンが外部 PostgreSQL データベースの最新バージョンに一致するようになります。 - データベースのスナップショットを格納するディレクトリーを作成します。
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
spacewalk-dump-schemaを使ってデータベースをエクスポートします。[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- 組み込みデータベースを停止します。
[root@satellite dbbackup]# db-control stop
spacewalk-setupを使って外部 PostgreSQL データベースを設定します。[root@satellite dbbackup]# spacewalk-setup --db-only --external-postgresql
このスクリプトはデータベースの詳細を要求して、Satellite がデータベースの接続と設定を実行できるようにします。外部 PostgreSQL データベースの詳細を入力します。** Database: Setting up database connection for PostgreSQL backend. Hostname (leave empty for local)? postgresql.example.com Port [5432]? Database? myextdb Username? root Password?
スクリプトでデータベースを設定します。- スクリプトでのデータベース作成が完了したら、データベーススキーマを復元します。
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Satellite サーバーから PostgreSQL と
spacewalk-dobbyのパッケージを削除します。[root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start
12.8.3. 組み込みデータベースから外部 Oracle データベースへの移行
- 組み込みデータベースを使用する Red Hat Satellite サーバーの完全インストール (
satellite.example.com) - 実行中の Oracle データベース (
oracledb.example.com) インスタンスをホストするシステム。設定の詳細については、「外部データベースの要件」 を参照してください。
手順12.4 外部 Oracle データベースへの移行
- Red Hat Satellite サーバー上ですべてのサービスをシャットダウンし、
db-controlで組み込みデータベースを起動します。[root@satellite ~]# rhn-satellite stop [root@satellite ~]# db-control start
- サーバーに
rhn-upgradeパッケージがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- データベースを最新のスキーマバージョンに更新します。
[root@satellite ~]# yum update satellite-schema [root@satellite ~]# spacewalk-schema-upgrade
これにより、使用中のデータベースのバージョンが外部 Oracle データベースの最新バージョンに一致するようになります。 - データベースのスナップショットを格納するディレクトリーを作成します。
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
spacewalk-dump-schemaを使ってデータベースをエクスポートします。[root@satellite dbbackup]# spacewalk-dump-schema --to=oracle > migrate-to-oracle.sql
- 組み込みデータベースを停止します。
[root@satellite dbbackup]# db-control stop
- Satellite サーバー上で PostgreSQL ドライバーおよび設定スクリプトを Oracle ドライバーおよび設定スクリプトに交換します。
[root@satellite dbbackup]# yum remove -y spacewalk-postgresql [root@satellite dbbackup]# yum install -y spacewalk-oracle [root@satellite dbbackup]# yum remove -y spacewalk-java-postgresql spacewalk-backend-sql-postgresql
spacewalk-setupを使って外部 Oracle データベースを作成します。[root@satellite dbbackup]# spacewalk-setup --db-only --external-oracle
このスクリプトはデータベースの詳細を要求して、Satellite がデータベースの接続と設定を実行できるようにします。外部 Oracle データベースの詳細を入力します。** Database: Setting up database connection for Oracle backend. Database service name (SID)? oracledb Database hostname [localhost]? oracledb.example.com Database (listener) port [1521]?
スクリプトでデータベースを設定します。重要
Red Hat Satellite データベースには、デフォルトの Oracle データベースポート (1521) を使用してください。別のポートを使用すると SELinux エラーが発生する場合があります。- スクリプトでデータベース作成を完了したら、データベーススキーマを復元します。
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-oracle.sql
重要
移行スクリプトの SELinux コンテキストは、Oracle データベースに読み込む前に変更する必要がある場合があります。[root@satellite dbbackup]# semanage fcontext -a -t oracle_sqlplus_exec_t /root/dbbackup/migrate-to-oracle.sql [root@satellite dbbackup]# restorecon -v /root/dbbackup/migrate-to-oracle.sql
同様に、ダンプされた表の SELinux コンテキストを変更する必要があることがあります。[root@satellite dbbackup]# semanage fcontext -a -t oracle_tmp_t "/tmp/dumped-tables(/.*)?" [root@satellite dbbackup]# restorecon -R -v /tmp/dumped-tables/
- Satellite サーバーから PostgreSQL および
spacewalk-dobbyパッケージを削除します。[root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start
12.8.4. 管理データベースから組み込みデータベースへの移行
- Red Hat Satellite のインストール ISO
- Red Hat Satellite サーバーの完全インストール (
satellite.example.com) と組み込みデータベースを使用した別個のサーバー (manageddb.example.com)
手順12.5 組み込みデータベースへの移行
- Satellite サーバーで主要サービスを停止します。
[root@satellite ~]# rhn-satellite stop
- 管理データベースサーバーでデータベースをシャットダウンします。
[root@manageddb ~]# db-control stop
- サーバーに
rhn-upgradeパッケージがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- db-control を使ってデータベースのバックアップを管理データベースサーバー上に作成し、これを Satellite サーバーにコピーします。
[root@manageddb ~]# mkdir ~/dbbackup [root@manageddb ~]# db-control backup ~/dbbackup [root@manageddb ~]# scp -r ~/dbbackup root@satellite.example.com:~/.
これで、管理データベースサーバーは他の目的に使用できるようになりました。これ以降の動作 Satellite サーバーで実行します。 - Red Hat Satellite インストール ISO を Satellite サーバーにマウントし、YUM0 変数を Red Hat Satellite のマウントポイントの値で設定し、エクスポートします。
[root@satellite ~]# mkdir /media/cdrom [root@satellite ~]# mount -o loop Red_Hat_Satellite_58.iso /media/cdrom [root@satellite ~]# export YUM0=/media/cdrom
red-hat-satelliteリポジトリーを有効にします。red-hat-satelliteリポジトリー定義が存在しない場合は、$YUM0/Satelliteにあるsatellite-repoパッケージをインストールします。red-hat-satelliteリポジトリーを有効にしたら、@satellite-databaseパッケージグループをインストールし、red-hat-satelliteリポジトリーを無効にします。[root@satellite ~]# yum install @satellite-database --enablerepo=red-hat-satellite
db-controlを使ってデータベースのバックアップを復元します。[root@satellite ~]# db-control restore ~/dbbackup
/etc/rhn/rhn.confファイルで db_port と db_hostname の値を削除します。[root@satellite ~]# sed -i 's/db_host\s*=.*/db_host = /' /etc/rhn/rhn.conf [root@satellite ~]# sed -i 's/db_port\s*=.*/db_port = /' /etc/rhn/rhn.conf
rh-postgresql95-postgresqlサービスを/etc/rhn/service-listファイルに追加し、これが Red Hat Satellite と並行して起動し、停止されることを確認します。[root@satellite ~]# echo "SERVICES=\"rh-postgresql95-postgresql \$SERVICES\"" >> /etc/rhn/service-list
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start
12.8.5. 外部 PostgreSQL データベースから組み込みデータベースへの移行
- 外部 PostgreSQLデータベース (
postgresql.example.com) を使用する Red Hat Satellite サーバーの完全インストール (satellite.example.com)
手順12.6 外部 PostgreSQL データベースから組み込みデータベースへの移行
- Red Hat Satellite サーバー上ですべてのサービスをシャットダウンします。
[root@satellite ~]# rhn-satellite stop
- 外部 PostgreSQL データベースが実行中であることを確認します。
- サーバーに
rhn-upgradeがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- 外部 PostgreSQL データベースを最新のスキーマバージョンに更新します。
[root@satellite ~]# yum update satellite-schema [root@satellite ~]# spacewalk-schema-upgrade
これにより、使用中のデータベースのバージョンが組み込みデータベースの最新バージョンに一致するようになります。 - データベースのスナップショットを格納するディレクトリーを作成します。
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
spacewalk-dump-schemaを使ってデータベースをエクスポートします。[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- 外部データベースが不要になったので、これを停止します。
- Satellite サーバーに PostgreSQL インストールおよび Satellite データベースツールのパッケージをインストールします。
[root@satellite dbbackup]# yum install -y spacewalk-setup-postgresql spacewalk-dobby
spacewalk-setupを使って組み込みデータベースを設定します。[root@satellite dbbackup]# spacewalk-setup --db-only
このスクリプトでデータベースが作成されます。プロセスが完了するまで待機します。** Database: Setting up database connection for PostgreSQL backend. ** Database: Installing the database: ** Database: This is a long process that is logged in: ** Database: /var/log/rhn/install_db.log *** Progress: # ** Database: Installation complete. ** Database: Populating database. *** Progress: ####################################
- スクリプトがデータベース作成を完了したら、データベーススキーマを復元します。
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start
12.8.6. 外部 Oracle データベースから組み込みデータベースへの移行
- 外部 Oracle データベース (
oracledb.example.com) を使用する Red Hat Satellite サーバーの完全インストール (satellite.example.com)
手順12.7 Oracle データベースから組み込みデータベースへの移行
- Red Hat Satellite サーバー上ですべてのサービスをシャットダウンします。
[root@satellite ~]# rhn-satellite stop
- 外部 Oracle データベースが実行中であることを確認します。
- サーバーに
rhn-upgradeがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- 外部 Oracle データベースを最新のスキーマバージョンに更新します。
[root@satellite ~]# yum update satellite-schema [root@satellite ~]# spacewalk-schema-upgrade
これにより、使用中のデータベースのバージョンが組み込みデータベースの最新バージョンに一致するようになります。 - データベースのスナップショットを格納するディレクトリーを作成します。
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
spacewalk-dump-schemaを使ってデータベースをエクスポートします。[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- 外部 Oracle データベースが不要になったので、これを停止します。
- Satellite サーバー上で Oracle ドライバーおよび設定スクリプトを PostgreSQL ドライバーおよび設定スクリプトと交換します。
[root@satellite dbbackup]# yum remove -y spacewalk-oracle [root@satellite dbbackup]# yum install -y spacewalk-postgresql spacewalk-setup-postgresql spacewalk-dobby [root@satellite dbbackup]# yum remove -y spacewalk-java-oracle spacewalk-backend-sql-oracle
spacewalk-setupを使って組み込みデータベースを作成します。[root@satellite dbbackup]# spacewalk-setup --db-only
このスクリプトでデータベースが作成されます。プロセスが完了するまで待機します。** Database: Setting up database connection for PostgreSQL backend. ** Database: Installing the database: ** Database: This is a long process that is logged in: ** Database: /var/log/rhn/install_db.log *** Progress: # ** Database: Installation complete. ** Database: Populating database. *** Progress: ####################################
- スクリプトがデータベース作成を完了したら、データベーススキーマを復元します。
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start
12.8.7. 外部 Oracle データベースから外部 PostgreSQL データベースへの移行
- 外部 Oracle データベース (
oracledb.example.com) を使用する Red Hat Satellite サーバーの完全インストール (satellite.example.com) - 実行中の PostgreSQL (
postgresql.example.com) インスタンスをホストするシステム。設定の詳細については、「PostgreSQL データベースの要件」 を参照してください。
手順12.8 Oracle データベースから外部データベースへの移行
- Red Hat Satellite サーバー上ですべてのサービスをシャットダウンします。
[root@satellite ~]# rhn-satellite stop
- 外部 Oracle データベースが実行中であることを確認します。
- サーバーに
rhn-upgradeがある場合は、これを削除します。[root@satellite ~]# yum remove rhn-upgrade
- 外部 Oracle データベースを最新のスキーマバージョンに更新します。
[root@satellite ~]# yum update satellite-schema [root@satellite ~]# spacewalk-schema-upgrade
これにより、使用中のデータベースのバージョンが外部データベースの最新バージョンに一致するようになります。 - データベースのスナップショットを格納するディレクトリーを作成します。
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
spacewalk-dump-schemaを使ってデータベースをエクスポートします。[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- 外部 Oracle データベースが不要になったので、これを停止します。
- Satellite サーバー上で Oracle ドライバーおよび設定スクリプトを PostgreSQL ドライバーおよび設定スクリプトと交換します。
[root@satellite dbbackup]# yum remove -y spacewalk-oracle [root@satellite dbbackup]# yum install -y spacewalk-postgresql [root@satellite dbbackup]# yum remove -y spacewalk-java-oracle spacewalk-backend-sql-oracle
spacewalk-setupを使って外部データベースを作成します。[root@satellite dbbackup]# spacewalk-setup --db-only --external-postgresql
このスクリプトはデータベースの詳細を要求し、Satellite がデータベースの接続と設定を実行できるようにします。外部 PostgreSQL データベースの詳細を入力します。** Database: Setting up database connection for PostgreSQL backend. Hostname (leave empty for local)? postgresql.example.com Port [5432]? Database? myextdb Username? root Password?
- スクリプトでデータベースの作成を完了したら、データベーススキーマを復元します。
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Red Hat Satellite を起動します。
[root@satellite ~]# rhn-satellite start

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.