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 3 years have passed since last update.

AWS上で自作のテトリス風ゲームを動かした際の備忘録

Last updated at Posted at 2021-05-05

AWS上で自作のテトリス風ゲームを動かした際の備忘録です。
https://github.com/seigot/tetris_game

前提条件

  • https://github.com/seigot/tetris_gameにアクセスできること
  • AWSアカウントを登録していること
  • EC2を起動していることこと
     (今回は無料枠、ubuntu18.04 server, CPU 1G, メモリ1GB, ストレージ20GBの環境を利用)
  • 起動したEC2にアクセスするための鍵ペアを作成して、秘密鍵をローカルに保存する。(パスは一旦、~/.ssh/aws_privatekey としている)

以降は起動済のEC2がある状態の手順を残す。

起動後にSSH経由でログイン

手元のPCから以下を実行してログインする。

ssh -i ~/.ssh/aws_privatekey ubuntu@xxx.xxx.xxx.xxx   #xxx.xxx.xxx.xxxはパブリックipv4アドレス

パブリックipv4アドレスはAWSのサイトから以下の通り確認できる。

EC2ダッシュボード -> インスタンス -> 起動しているインスタンス選択し、パブリックipv4アドレスを確認

VNC経由でログイン

Desktop環境をインストールする

sudo apt install -y ubuntu-desktop xterm x11vnc

ifupdownをPurgeする

sudo apt purge ifupdown

Display manager を lightdm に変更

sudo apt install lightdm

念のためpasswordを設定しておく

sudo passwd ubuntu

以下を参考にVNCクライアントからx11vncを接続する

https://mixture.dcmnjp.net/linux/ubuntu/x11vnc.html

VNC経由でアプリをお試し実行

自作のテトリスをお試し実行する

https://github.com/seigot/tetris_game

必要なものをインストール

実行環境(Ubuntuの場合)

Need python3, PyQt5 and NumPy to be installed.

install pyqt5 and NumPy

sudo apt-get install -y python3-pip
sudo apt-get install -y python3-pyqt5
pip3 install --upgrade pip
pip3 install numpy
その他、パッケージのインストール

sudo apt-get install -y git

実行

cd ~
git clone https://github.com/seigot/tetris_game
cd tetris_game
bash start.sh

動いた。でも無料枠(CPU 1G, メモリ1GB, ストレージ20GB)での利用のためか、かなりもっさりします。

MacからEC2にvncが繋がらない

以下の方法だと繋がった。VNC Viewer使っています。

https://biomodeling.co.jp/2020/04/30/ubuntu18にリモートデスクトップ接続する手順/

ただし毎回以下の設定が要る。

# 5901ポートフォワード
ssh -i ~/.ssh/aws_privatekey ubuntu@xxx.xxx.xxx.xxx -L 5901:localhost:5901
# vnc serverの設定
vncserver :1

5900をポートフォワードする場合は以下

# 5900ポートフォワード
ssh -i ~/.ssh/aws_privatekey ubuntu@xxx.xxx.xxx.xxx -L 5900:localhost:5900

kswapdが重い

swap領域を追加して一旦落ち着いた
kswapが頻発してシステムが重い

参考

https://github.com/seigot/tetris_game
https://biomodeling.co.jp/2020/04/30/ubuntu18にリモートデスクトップ接続する手順/
kswapが頻発してシステムが重い
https://mixture.dcmnjp.net/linux/ubuntu/x11vnc.html

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?