4
2

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

elastic beanstalk の .ebextensions で設定しておくと良いかもしれないもの

Posted at

aws elastic beanstalk で .ebextensions に共通して設定しているものを抜き出してみた。

files

  • .gemrc--no-rdoc --no-riを設定しておく
  "/root/.gemrc":
    mode: "000644"
    owner: "root"
    group: "root"
    content: |
      gem: --no-rdoc --no-ri
  • リソース制限
  "/etc/security/limits.d/60-nofile-limit.conf":
    mode: "000644"
    owner: "root"
    group: "root"
    content: |
      nginx  soft  nofile  65535
      nginx  hard  nofile  65535
      root   soft  nofile  65535
      root   hard  nofile  65535

commands

  • カーネルパラメータ
  01_sysctl:
    command: |
      sysctl -w net.core.somaxconn=8192
      ...
  • swap
    *.microのインスタンスに保険としてswaponしておく
  02_swapon:
    command: |
      if (curl -s http://169.254.169.254/latest/meta-data/instance-type | grep -E "\.micro$" > /dev/null)
      then
      SWAPFILENAME=/swap.img
      test -e $SWAPFILENAME && exit 0
      MEMSIZE=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
      if [ $MEMSIZE -lt 2097152 ]; then
        SIZE=$((MEMSIZE * 2))k
      elif [ $MEMSIZE -lt 8388608 ]; then
        SIZE=${MEMSIZE}k
      elif [ $MEMSIZE -lt 67108864 ]; then
        SIZE=$((MEMSIZE / 2))k
      else
        SIZE=4194304k
      fi
      fallocate -l $SIZE $SWAPFILENAME && mkswap $SWAPFILENAME && chmod 0600 $SWAPFILENAME && swapon $SWAPFILENAME
      fi
  • localtime
  03_localtime:
    command: |
      if [ ! -e /etc/localtime.orig ] ; then
      cp -pf /etc/localtime{,.orig}
      cp -pf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
      fi
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?