2015年7月22日水曜日

CentOS7 on Amazon EC2(4) ホスト名変更

参考

CentOS7のAMIから起動したインスタンスのホスト名を固定にする →OK

Linux インスタンスのホスト名の変更 →ダメ

CentOS 7 の Hostname を変更する →ダメ


やり方

/etc/hostnameや/etc/sysconfig/networkにホスト名を書いてもダメ。
/etc/cloud/cloud.cfgのupdate_hostnameをコメントアウトした上で、/etc/hostnameをいじる。


$ sudo vi /etc/cloud/cloud.cfg
$ sudo vi /etc/hostname
$ sudo reboot



2015年7月19日日曜日

CentOS7 on Amazon EC2(3) glassfish on amazon ec2

Amazon EC2上のCentOS7にglassfishをインストールする。

1、JDK8ダウンロード、インストール

yumのリポジトリにはjavac入りのJDKはない模様
sudo yum provides javac

以下サイトからOracle JDKをインストールする
http://www.oracle.com/technetwork/java/javase/downloads/index.html

(1)コマンドラインからダウンロード

参考:Think deeply, Do less, More effective

$ sudo yum install wget -y
$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.rpm"

(2)インストール

$ sudo rpm -ivh jdk-7u71-linux-x64.rpm 

2、glassfish ダウンロード&インストール

参考:【Glassfish】CentOS7.0へGlasssfish4.1インストール

(1)ダウンロード

サイト:https://glassfish.java.net/download.html

Full Platformをダウンロードする。

コマンド
$ wget http://download.java.net/glassfish/4.1/release/glassfish-4.1.zip

(2)glassfish起動ユーザー追加

$ sudo useradd glassfish

(3)解凍&インストール

$ sudo yum install unzip -y
$ sudo su - glassfish
glassfish$ unzip glassfish-4.1.zip
glassfish$ mv glassfish4 /opt/.

3、起動テスト&セキュア設定

$ cd /opt/glassfish4/bin
$ ./asadmin change-admin-password --user admin
Enter the admin password> 
Enter the new admin password> 
Enter the new admin password again> 
Command change-admin-password executed successfully.
$ ./asadmin start-domain
$ ./asadmin enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> 
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.
$ ./asadmin stop-domain
Waiting for the domain to stop ..
Command stop-domain executed successfully.
$ ./asadmin start-domain
Waiting for domain1 to start ...............................................................
Successfully started the domain : domain1
domain  Location: /home/pi/glassfish4/glassfish/domains/domain1
Log File: /home/pi/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

4、サービス作成

$ sudo vi /lib/systemd/system/glassfish.service
[Unit]
Description=GlassFish Server
After=network.target remote-fs.target

[Service]
Type=forking
PIDFile=/opt/glassfish4/glassfish/domains/domain1/config/pid
ExecStart=/opt/glassfish4/bin/asadmin start-domain
ExecReload=/opt/glassfish4/bin/asadmin restart-domain
ExecStop=/opt/glassfish4/bin/asadmin stop-domain
TimeoutStartSec=300
TimeoutStopSec=30
User=glassfish

[Install]
WantedBy=multi-user.target

5、サービス有効化

$ sudo systemctl enable glassfish.service
ln -s '/usr/lib/systemd/system/glassfish.service' '/etc/systemd/system/multi-user.target.wants/glassfish.service'

6、停止・起動

$ sudo systemctl stop glassfish.service
$ sudo systemctl start glassfish.service

7、ログを確認

less /var/log/messages

2015年7月18日土曜日

CentOS7 on Amazon EC2(2) MySQL

CentOS7では、mariaDBなるDBになっているらしい!
Wikipedia MariaDB

1、インストール

mysqlをインストールしようとするとmariadbがインストールされる

$ sudo yum install mysql
Loaded plugins: fastestmirror
....
Dependencies Resolved

================================================================================
 Package             Arch          Version                    Repository   Size
================================================================================
Installing:
 mariadb             x86_64        1:5.5.41-2.el7_0           base        8.9 M
Installing for dependencies:
 mariadb-libs        x86_64        1:5.5.41-2.el7_0           base        754 k

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 9.7 M
Installed size: 53 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): mariadb-libs-5.5.41-2.el7_0.x86_64.rpm              | 754 kB   00:00     
(2/2): mariadb-5.5.41-2.el7_0.x86_64.rpm                   | 8.9 MB   00:00     
--------------------------------------------------------------------------------
Total                                               12 MB/s | 9.7 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64                         1/2 
  Installing : 1:mariadb-5.5.41-2.el7_0.x86_64                              2/2 
  Verifying  : 1:mariadb-5.5.41-2.el7_0.x86_64                              1/2 
  Verifying  : 1:mariadb-libs-5.5.41-2.el7_0.x86_64                         2/2 
Installed:
  mariadb.x86_64 1:5.5.41-2.el7_0                                               
Dependency Installed:
  mariadb-libs.x86_64 1:5.5.41-2.el7_0                                          
Complete!

2、バージョン確認

$ mysql --version
mysql  Ver 15.1 Distrib 5.5.41-MariaDB, for Linux (x86_64) using readline 5.1
mariadbになっている

3、Serverインストール

$ sudo yum install mariadb-server

4、サービス確認

$ systemctl list-unit-files | grep mariadb
mariadb.service                        disabled
無効になっている

5、サービス有効化

$ sudo systemctl enable mariadb.service
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
$ systemctl list-unit-files | grep mariadb
mariadb.service                        enabled 

6、サービス起動

$ sudo systemctl start mariadb.service