SuSE Linux Enterprise Server: basic usage memo

# SuSE Linux Enterprise Server: basic usage memo

## いきさつ: なぜに SLES?

- Oracle Database Express Edition(XE) を AWS 上で利用したいと思ったときに RHEL よりも Subscription 費用が安かったので…

## 目的

- 基本的な管理方法を備忘録的に残しておく
    - SLES に固有っぽいもの中心に
        - 基本的な情報収集
        - パッケージ管理コマンド
        - サービスの開始・終了 etc
- 気がついたら書き足していく

## 対象

- バージョン: SLES 11 SP4
    - Oracle XE 11 のサポート環境を想定しているので

## 実験環境

**※ 注意: 以下の環境は無料ではありません!**

- AWS
    - Region: N.Virginia
    - AMI: suse-sles-11-sp4-v20160804-hvm-ssd-x86_64 (ami-0434a713)
    - Instance Type: t2.micro
    - あくまで参考価格:
        - $0.022 per On Demand SUSE t2.micro instance Hour
        - $0.053 per On Demand SUSE t2.small instance Hour
        - ちなみに RHEL だと $0.072/1Hour t2.micro

- CFn サンプル

```json
% cat cloudformation-sles.json
{
	"Description" : "test template",
	"Resources" : {
		"myec2instance" : {
			"Type" : "AWS::EC2::Instance",
			"Properties" : {
				"ImageId" : "ami-0434a713",
				"InstanceType" : "t2.micro",
				"SubnetId" : "subnet-bd809696",
				"KeyName" : "aws-n.virginia-default001",
				"SecurityGroupIds" : [ "sg-a55506db" ],
				"IamInstanceProfile" : "ec2-001",
				"Tags" : [ { "Key" : "Name", "Value" : "sles-oracle-xe" } ]
			}
		}
	}
}
```

## システム情報

- ref. https://www.suse.com/documentation/sled11/singlehtml/book_sle_tuning/book_sle_tuning.html

```shell-session:command
cat /etc/SuSE-release
```
```shell-session:output_sample
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 4
```

## パッケージ管理コマンド(zypper)

ref. https://en.opensuse.org/images/1/17/Zypper-cheat-sheet-1.pdf

### Update

```shell-session:command
sudo zypper update

# or 

sudo zypper up
```

### List Repository

```shell-session:command
sudo zypper repos

# or

sudo zypper lr
```
```shell-session:output_sample
Refreshing service 'cloud_update'.
# | Alias                                                      | Name                        | Enabled | Refresh
--+------------------------------------------------------------+-----------------------------+---------+--------
1 | SMT-http_smt-ec2_susecloud_net:SLE11-Public-Cloud-Module   | SLE11-Public-Cloud-Module   | No      | Yes
2 | SMT-http_smt-ec2_susecloud_net:SLE11-SDK-SP4-Pool          | SLE11-SDK-SP4-Pool          | Yes     | Yes
3 | SMT-http_smt-ec2_susecloud_net:SLE11-SDK-SP4-Updates       | SLE11-SDK-SP4-Updates       | Yes     | Yes
4 | SMT-http_smt-ec2_susecloud_net:SLE11-SP4-Debuginfo-Pool    | SLE11-SP4-Debuginfo-Pool    | No      | Yes
5 | SMT-http_smt-ec2_susecloud_net:SLE11-SP4-Debuginfo-Updates | SLE11-SP4-Debuginfo-Updates | No      | Yes
6 | SMT-http_smt-ec2_susecloud_net:SLES11-Extras               | SLES11-Extras               | No      | Yes
7 | SMT-http_smt-ec2_susecloud_net:SLES11-SP4-Pool             | SLES11-SP4-Pool             | Yes     | Yes
8 | SMT-http_smt-ec2_susecloud_net:SLES11-SP4-Updates          | SLES11-SP4-Updates          | Yes     | Yes
9 | nVidia-Driver-SLE11-SP3                                    | nVidia-Driver-SLE11-SP3     | Yes     | Yes
```

### Refresh Repository

```shell-session:command
sudo zypper refresh

# or

sudo zypper ref
```
```shell-session:output_sample
Refreshing service 'cloud_update'.
Repository 'SLE11-SDK-SP4-Pool' is up to date.
Repository 'SLE11-SDK-SP4-Updates' is up to date.
Repository 'SLES11-SP4-Pool' is up to date.
Repository 'SLES11-SP4-Updates' is up to date.
Repository 'nVidia-Driver-SLE11-SP3' is up to date.
All repositories have been refreshed.
```

### Search Package

```shell-session:command
sudo zypper search vim

# or

sudo zypper se vim
```
```shell-session:output_sample
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...

S | Name              | Summary                 | Type
--+-------------------+-------------------------+-----------
  | gvim              | A GUI for Vi            | package
i | slessp4-vim-12862 | Security update for vim | patch
i | vim               | Vi IMproved             | package
  | vim               | Vi IMproved             | srcpackage
i | vim-base          | Vi IMproved             | package
i | vim-data          | Vi IMproved             | package
```

- Search by Pattern (Group Packages)

```shell-session:command
sudo zypper se --type pattern
```
```shell-session:command
sudo zypper se --type pattern devel
```
```shell-session:output_sample
S | Name        | Summary                  | Type
--+-------------+--------------------------+--------
  | Basis-Devel | C/C++ Compiler and Tools | pattern
```

### List Installed Packages

```shell-session:command
sudo zypper se --installed-only
```
```shell-session:command
sudo zypper se --installed-only --type pattern
```
```shell-session:output_sample
S | Name        | Summary                     | Type
--+-------------+-----------------------------+--------
i | Minimal     | Minimal System (Appliances) | pattern
i | lamp_server | Web and LAMP Server         | pattern
i | sdk_ruby    | SDK: Ruby Development       | pattern
i | sdk_web     | SDK: Web Development        | pattern
```

- List contained packages in pattern

```shell-session:command
sudo zypper info -t pattern Basis-Devel
```
```shell-session:output_sample
Information for pattern Basis-Devel:

Repository: SLES11-SP4-Pool
Name: Basis-Devel
Version: 11-38.47.37
Arch: x86_64
Vendor:
Installed: No
Summary: C/C++ Compiler and Tools
Description:
Minimal set of tools for compiling and linking applications
Contents:

S | Name            | Type    | Dependency
--+-----------------+---------+-----------
  | glibc-info      | package |
  | flex            | package |
  | libaio-devel    | package |
  | gdbm-devel      | package |
  | emacs           | package |
  | emacs-info      | package |
  | kernel-source   | package |
  | emacs-x11       | package | Suggested
  | libstdc++-devel | package |
  | bison           | package |
  | glibc-devel     | package |
  | autoconf        | package |
  | automake        | package |
  | gcc             | package |
  | gcc-c++         | package |
  | gcc-info        | package |
  | texinfo         | package |
  | pkg-config      | package |
  | ncurses-devel   | package |
  | gcc-locale      | package |
  | rcs             | package |
  | aspell-ispell   | package |
  | cvs             | package |
```

### Install Package

```shell-session:command
sudo zypper install

# or

sudo zypper in
```
```shell-session:command
sudo zypper in -y -t pattern Basis-Devel
```

## ログファイル

### syslog

- /var/log/syslog

### zypper

- /var/log/zypper.log

## ネットワーク情報

```shell-session:command
hostname
```
```shell-session:output_sample
ip-172-31-52-214
```
```shell-session:command
ip a

# or

/sbin/ifconfig
```
```shell-session:command
netstat -rn

# or

ip route show
```
```shell-session:command
netstat -aon

# or

/usr/sbin/ss -an
```
```shell-session:command
sudo /usr/sbin/ss -ltp
```
```shell-session:output_sample
Recv-Q Send-Q                     Local Address:Port                         Peer Address:Port
0      0                                      *:sunrpc                                  *:*        users:(("rpcbind",2651,8))
0      0                                      *:ssh                                     *:*        users:(("sshd",3064,3))
0      0                              127.0.0.1:smtp                                    *:*        users:(("master",3303,12))
```

## サービス管理

- SLES 11 はまだ Systemd ではない様子

ref. https://en.opensuse.org/SDB:Systemd

> Systemd is the default and only init system since openSUSE 12.3

```shell-session:command
sudo /sbin/service sshd status

# or

sudo /etc/init.d/sshd status
```
```shell-session:output_sample
Checking for service sshd                                            running
```