1
0

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 1 year has passed since last update.

スイッチ後のユーザーでもローカルPCでX Windowの画面表示をする方法

Posted at

前置き

クラウド環境のCompute VMではログインユーザーが指定されています(OCI Compute VMの場合はopcユーザー)。そのため、Compute VMにOracle DBを入れるために、GUIのDBCAで構築したいというとき、ログインユーザーからスイッチしたoracleユーザーでも、X WindowによってローカルPCに画面を飛ばす操作をする必要があります。
ここでは、スイッチ後のユーザー(oracleユーザー)でX Windowの画面表示するまでの手順を記述します。
環境はOracle Linux 7で実施しています。

手順

0.前提

opcユーザーにてローカルPCへのX転送ができる状態であるとします。
自分はこちらのQiitaの記事にお世話になりました。
https://qiita.com/ora_gonsuke777/items/765189e9e301415e7ba5
image.png

opcユーザーでは表示できても、oracleユーザーにスイッチしたあとは表示できなくなってしまいます。
oracleユーザーにスイッチした後にX Windowの表示をローカルPC上で実施する手順を以下で紹介します

[opc@ymzkdb ~]$ sudo su - oracle
Last login: Thu Nov 24 17:53:40 GMT 2022 on pts/0
[oracle@ymzkdb ~]$ xeyes
Error: Can't open display:

1. oracleユーザーでX転送を実施するため、opcユーザーのxauthの情報をoracleユーザーにaddする

opcユーザーのxauth情報を表示

[opc@ymzkdb ~]$ xauth list $DISPLAY
ymzkdb/unix:10  MIT-MAGIC-COOKIE-1  910381ebfbdc544809baa1f00401d88e

oracleユーザーになり、opcユーザーのxauth情報を追加する

[opc@ymzkdb ~]$ sudo su - oracle
Last login: Mon Oct 24 06:26:19 GMT 2022 on pts/1
[oracle@ymzkdb ~]$ xauth add ymzkdb/unix:10  MIT-MAGIC-COOKIE-1  910381ebfbdc544809baa1f00401d88e

このとき、初回実行時など、以下のようなエラーがでることがあります。

xauth:  file /home/oracle/.Xauthority does not exist

.Xauthorityについては、xのアプリケーション(xeyesなど)を実行すれば作ってくれるとのことなのでxeyesを実行します
http://nalab.mind.meiji.ac.jp/~mk/knowhow-2014/node4.html

[oracle@ymzkdb ~]$ xeyes
Error: Can't open display:
[oracle@ymzkdb ~]$ ls -l  /home/oracle/.Xauthority
-rw-------. 1 oracle oinstall 52 May 26 07:42 /home/oracle/.Xauthority

2.DISPLAY環境変数を設定します

[oracle@ymzkdb ~]$ export DISPLAY=localhost:10.0

DISPLAY=localhost:10.0の10の部分はopcユーザーのxauth情報と合わせます
ymzkdb/unix:10(←これ) MIT-MAGIC-COOKIE-1 910381ebfbdc544809baa1f00401d88e

3.x アプリケーションを実行して表示を確認

[oracle@ymzkdb ~]$ xeyes

これでoracleユーザーでも無事X Windowの表示がされました。
image.png

目的であったDBCAの表示もできます。
image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?