（解決）mysql（mariadb）が起動しなくなった



# 環境
GCP (Google Cloud Platform)
Compute Engine



# 

状態チェック

```
sudo systemctl status mariadb
```


`Active: failed `で起動していません（涙
Status: "MariaDB server is down" が哀愁を深めます。


```
● mariadb.service - MariaDB 10.1.31 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since 日 2019-01-27 20:26:45 JST; 2min 17s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 1694 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/F
AILURE)
  Process: 1587 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $?
 -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 1583 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 1694 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"
 1月 27 20:26:43 instance-sugasaki-gom-kusanagi-02 systemd[1]: Starting MariaDB 10.1.31 database server...
 1月 27 20:26:45 instance-sugasaki-gom-kusanagi-02 mysqld[1694]: 2019-01-27 20:26:45 140290193697024 [Note] /usr/sbi......
 1月 27 20:26:45 instance-sugasaki-gom-kusanagi-02 systemd[1]: mariadb.service: main process exited, code=exited, st...URE
 1月 27 20:26:45 instance-sugasaki-gom-kusanagi-02 systemd[1]: Failed to start MariaDB 10.1.31 database server.
 1月 27 20:26:45 instance-sugasaki-gom-kusanagi-02 systemd[1]: Unit mariadb.service entered failed state.
 1月 27 20:26:45 instance-sugasaki-gom-kusanagi-02 systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
```




以下のファイルにログファイルのパスを発見
/etc/my.cnf.d/server.cnf


```shell:/etc/my.cnf.d/server.cnf
...
log-error = /var/log/mysql/mysqld.log
...

```



`vi /var/log/mysql/mysqld.log`でログファイルを確認


```
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: The InnoDB memory heap is disabled
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Compressed tables use zlib 1.2.7
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Using Linux native AIO
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Using SSE crc32 instructions
2019-01-27 19:16:22 140146316003584 [Note] InnoDB: Initializing buffer pool, size = 384.0M
```


`The InnoDB memory heap is disabled`

と書いてあります。
はっ！


## 結果

GCPのVMインスタンスの料金をケチって、メモリを最小（0.6GB）に変えてたのが原因でした。
![スクリーンショット 2019-01-27 20.43.44.png](https://qiita-image-store.s3.amazonaws.com/0/49910/eb4f3664-6206-851e-01cf-22cfb777822e.png "スクリーンショット 2019-01-27 20.43.44.png")

　　↓

![Kobito.7TpvlM.png](https://qiita-image-store.s3.amazonaws.com/0/49910/8b9d30ca-4756-4e99-772d-1c70a94c5420.png "Kobito.7TpvlM.png")