Ubuntu 10.04 LTS (Lucid Lynx) AMI: Difference between revisions

 
(54 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://gienkin.jrc.or.jp/ http://s3.egrep.jp/jrclogo.gif]
'''EOLです'''
 
 


= 雑多なメモ =
= 雑多なメモ =
Line 8: Line 6:
== はじめの第一歩 ==
== はじめの第一歩 ==


<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
echo "Asia/Tokyo" | sudo tee /etc/timezone
echo "Asia/Tokyo" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
sudo dpkg-reconfigure --frontend noninteractive tzdata
Line 83: Line 81:


ec2-set-hosts
ec2-set-hosts
<syntaxhighlight lang="python" enclose="pre">
<syntaxhighlight lang="python" enclose="div">
#!/usr/bin/python
#!/usr/bin/python
#
#
Line 116: Line 114:
my_hostname = os.popen("/bin/hostname -s").read().rstrip()
my_hostname = os.popen("/bin/hostname -s").read().rstrip()


# replace the ubuntu hostname in /etc/hosts                                                                                
# replace the ubuntu hostname in /etc/hosts
mp = {'localipv4' : my_ip, 'hostname' : my_hostname, 'fqdn' : my_fqdn}
mp = {'localipv4' : my_ip, 'hostname' : my_hostname, 'fqdn' : my_fqdn}
t = Template(file="/usr/local/etc/bind/templates/hosts.tmpl", searchList=[mp])
t = Template(file="/usr/local/etc/bind/templates/hosts.tmpl", searchList=[mp])
Line 141: Line 139:
ec2-set-dns-zone
ec2-set-dns-zone
(内部 DNS 設定用)(aptitude install python-ipy で IPy 導入前提)
(内部 DNS 設定用)(aptitude install python-ipy で IPy 導入前提)
<syntaxhighlight lang="python">
<syntaxhighlight lang="python" enclose="div">
#!/usr/bin/python
#!/usr/bin/python
#
#
Line 296: Line 294:
mod_sed の書き換えルールはこんな感じかな
mod_sed の書き換えルールはこんな感じかな
<pre>
<pre>
     <IfModule mod_sed.c>                                                                                                  
     <IfModule mod_sed.c>
       AddOutputFilter Sed html                                                                                          
       AddOutputFilter Sed html
       OutputSed "s/www\.example\.com/test.example.com/g"                                                                      
       OutputSed "s/www\.example\.com/test.example.com/g"
     </IfModule>                                                                                                          
     </IfModule>
</pre>
</pre>


Line 402: Line 400:
#
#
net.core.netdev_max_backlog=30000
net.core.netdev_max_backlog=30000
net.core.somaxconn=262144
net.core.somaxconn=65535
net.ipv4.tcp_max_orphans=262144
net.ipv4.tcp_max_orphans=262144
net.ipv4.tcp_max_syn_backlog=262144
net.ipv4.tcp_max_syn_backlog=65535
net.ipv4.tcp_fin_timeout=3
net.ipv4.tcp_fin_timeout=3
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_no_metrics_save=1
Line 479: Line 477:
== apparmor ==
== apparmor ==
普通じゃない設定をしたら、整合性を合わせないといけない
普通じゃない設定をしたら、整合性を合わせないといけない
<syntaxhighlight>
<syntaxhighlight lang="text" enclose="div">
   /ebs/var/lib/mysql/ r,
   /ebs/var/lib/mysql/ r,
   /ebs/var/lib/mysql/** rwk,
   /ebs/var/lib/mysql/** rwk,
Line 489: Line 487:
== 定番パッケージ ==
== 定番パッケージ ==
=== cron-apt / unattended-upgrades ===
=== cron-apt / unattended-upgrades ===
<syntaxhighlight>
<syntaxhighlight lang="text" enclose="div">
sudo aptitude install cron-apt
sudo aptitude install cron-apt
  edit .....
  edit .....
Line 499: Line 497:
cron-apt から unattended-upgrades に換えましたが、やっぱり微妙に使い勝手が悪いので、また cron-apt を使うことにしました。
cron-apt から unattended-upgrades に換えましたが、やっぱり微妙に使い勝手が悪いので、また cron-apt を使うことにしました。


<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude install postfix
sudo aptitude install postfix
sudo aptitude install mailx
sudo aptitude install mailx
Line 539: Line 537:


=== いろいろ ===
=== いろいろ ===
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude install php-pear
sudo aptitude install php-pear
sudo aptitude install apache2-prefork-dev
sudo aptitude install apache2-prefork-dev
Line 550: Line 548:
== Zimbra 系メモ ==
== Zimbra 系メモ ==
Sending Mail from Terminal (optional)
Sending Mail from Terminal (optional)
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
wget http://ubuntu.lnix.net/misc/mta-dummy/mta-dummy_1.0_all.deb  
wget http://ubuntu.lnix.net/misc/mta-dummy/mta-dummy_1.0_all.deb  
dpkg -i mta-dummy_1.0_all.deb
dpkg -i mta-dummy_1.0_all.deb
Line 560: Line 558:
== WordPress 系メモ ==
== WordPress 系メモ ==
とりあえずパッケージでいれて設定だけいただく
とりあえずパッケージでいれて設定だけいただく
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude -y install wordpress
sudo aptitude -y install wordpress
sudo /bin/bash /usr/share/doc/wordpress/examples/setup-mysql -n WORDPRESSDBNAME HOSTNAME
sudo /bin/bash /usr/share/doc/wordpress/examples/setup-mysql -n WORDPRESSDBNAME HOSTNAME
Line 572: Line 570:


node
node
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude install munin-node
sudo aptitude install munin-node
sudo aptitude install munin-plugins-extra
sudo aptitude install munin-plugins-extra
Line 579: Line 577:
sudo aptitude install libtext-csv-xs-perl
sudo aptitude install libtext-csv-xs-perl
</syntaxhighlight>
</syntaxhighlight>
(2012/11/06 の security patch で)
/var/lib/munin から /var/lib/munin-node に変わった


server
server
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude install munin
sudo aptitude install munin
</syntaxhighlight>
</syntaxhighlight>


お手軽 サービス・死活監視
お手軽 サービス・死活監視
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo aptitude install monit
sudo aptitude install monit
</syntaxhighlight>
</syntaxhighlight>
Line 636: Line 637:
Host *
Host *
   #ForwardAgent yes
   #ForwardAgent yes
   TCPKeepAlive yes
   TCPKeepAlive no
   ServerAliveInterval 15
   ServerAliveInterval 60
   ServerAliveCountMax 60
   ServerAliveCountMax 15
</pre>
</pre>


Line 645: Line 646:
  [http://www.varnish-cache.org/installation/ubuntu Installation on Ubuntu]
  [http://www.varnish-cache.org/installation/ubuntu Installation on Ubuntu]


<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
echo "deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-2.1" | sudo tee /etc/apt/sources.list.d/varnish.list
echo "deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-2.1" | sudo tee /etc/apt/sources.list.d/varnish.list
wget -qO - http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
wget -qO - http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
Line 654: Line 655:


あんちょくな daily backup script
あんちょくな daily backup script
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
#!/bin/sh
#!/bin/sh


Line 712: Line 713:
         "ec2:DescribeSnapshotAttribute",
         "ec2:DescribeSnapshotAttribute",
         "ec2:DescribeSnapshots",
         "ec2:DescribeSnapshots",
        "ec2:ModifySnapshotAttribute",
        "ec2:ResetSnapshotAttribute"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
</pre>
ubuntu 12.04 Precise では boto が 2.2.2 になっていた。tag 系の処理が追加されていて、嬉しいのだけど、すこしはまった。
上記の Policy に tag 系を追加する事
<pre>
{
  "Statement": [
    {
      "Action": [
        "ec2:CreateSnapshot",
        "ec2:DeleteSnapshot",
        "ec2:DescribeRegions",
        "ec2:DescribeSnapshotAttribute",
        "ec2:DescribeSnapshots",
        "ec2:DescribeVolumes",
        "ec2:DescribeTags",
        "ec2:CreateTags",
         "ec2:ModifySnapshotAttribute",
         "ec2:ModifySnapshotAttribute",
         "ec2:ResetSnapshotAttribute"
         "ec2:ResetSnapshotAttribute"
Line 724: Line 752:


MySQL を noninteractive でインストール。(対話型でパスワードを聞かれるのを自動設定する)
MySQL を noninteractive でインストール。(対話型でパスワードを聞かれるのを自動設定する)
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
echo 'mysql-server-5.1 mysql-server/root_password password PASSWORD' | sudo debconf-set-selections
echo 'mysql-server-5.1 mysql-server/root_password password PASSWORD' | sudo debconf-set-selections
echo 'mysql-server-5.1 mysql-server/root_password seen true' | sudo debconf-set-selections
echo 'mysql-server-5.1 mysql-server/root_password seen true' | sudo debconf-set-selections
Line 745: Line 773:
'''☆環境により boot しない場合有り 注意☆'''
'''☆環境により boot しない場合有り 注意☆'''


<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo e2label /dev/sda1
sudo e2label /dev/sda1
ls -al /dev/disk/by-label
ls -al /dev/disk/by-label
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
sudo e2label /dev/sda1 cloudimg-rootfs
sudo e2label /dev/sda1 cloudimg-rootfs
sudo e2label /dev/sdp copy-of-cloudimg-rootfs
sudo e2label /dev/sdp no-rootfs
</syntaxhighlight>
</syntaxhighlight>
という手もあるんだが... root device = boot device = /dev/sda1 に単純化したほうが事故が少ないと思う。
という手もあるんだが... root device = boot device = /dev/sda1 に単純化したほうが事故が少ないと思う。
Line 782: Line 810:
/etc/security/limits.d/mylimits.conf
/etc/security/limits.d/mylimits.conf
<pre>
<pre>
* - stack -1
* soft core 0
root - nofile 524288
* hard core 0
root soft core 0
root hard core 0
* soft nofile 524288
* hard nofile 524288
root soft nofile 524288
root hard nofile 524288
* soft nproc unlimited
* hard nproc unlimited
root soft nproc unlimited
root hard nproc unlimited
* soft stack unlimited
* hard stack unlimited
root soft stack unlimited
root hard stack unlimited
* soft memlock unlimited
* hard memlock unlimited
root soft memlock unlimited
root hard memlock unlimited
* soft as unlimited
* hard as unlimited
root soft as unlimited
root hard as unlimited
</pre>
</pre>


== 12.04 LTS ==
== 12.04 LTS ==
メモ
メモ
[http://uec-images.ubuntu.com/releases/precise/release/ Ubuntu 12.04 (Precise Pangolin) LTS]


<pre>
<pre>
Line 806: Line 858:
  [https://help.ubuntu.com/community/UpgradeNotes UpgradeNotes - Community Ubuntu Documentation]
  [https://help.ubuntu.com/community/UpgradeNotes UpgradeNotes - Community Ubuntu Documentation]
  [https://help.ubuntu.com/community/PreciseUpgrades PreciseUpgrades - Community Ubuntu Documentation]
  [https://help.ubuntu.com/community/PreciseUpgrades PreciseUpgrades - Community Ubuntu Documentation]
  [https://wiki.ubuntu.com/PrecisePangolin/ReleaseNotes/UbuntuDesktop#Upgrading_from_Ubuntu_10.04_LTS_to_Ubuntu_12.04_LTS PrecisePangolin/ReleaseNotes/UbuntuDesktop - Ubuntu Wiki]
  [https://wiki.ubuntu.com/PrecisePangolin/ReleaseNotes/UbuntuServer#From_10.04_to_12.04 PrecisePangolin/ReleaseNotes/UbuntuServer - Ubuntu Wiki]
  [http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/ DNS in Ubuntu 12.04 | Stéphane Graber's website]
  [http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/ DNS in Ubuntu 12.04 | Stéphane Graber's website]


Line 827: Line 879:
(backport は変わってくれない)
(backport は変わってくれない)
(sudo dpkg-reconfigure mysql-server-5.5)
(sudo dpkg-reconfigure mysql-server-5.5)
(sudo dpkg-reconfigure phpmyadmin)
</pre>
</pre>


Line 838: Line 891:


<pre>
<pre>
/etc/network/interfaces の IFACE OPTIONS を削除する。
/etc/network/interfaces の IFACE OPTIONS を見直する。
post-up とかで独自の処理入れている場合にこける
post-up とかで独自の処理入れていて、何らかの理由で正常終了していない場合にこけるようだ。
</pre>
</pre>


Line 846: Line 899:
デフォ ext4
デフォ ext4
/etc/ec2_version を書き換え "Ubuntu 12.04 (Precise Pangolin)"
/etc/ec2_version を書き換え "Ubuntu 12.04 (Precise Pangolin)"
/etc/debian_version は wheezy/sid
fstab から proc の記述を削除
fstab から proc の記述を削除
fstab /dev/xvda1 へ
fstab ext4 にしておく
menu.lst から xencons=hvc0 を削除
menu.lst から xencons=hvc0 を削除
aptitude remove dhcp3-client dhcp3-common
aptitude remove dhcp3-client dhcp3-common
dpkg --purge dhcp3-client
dpkg --purge dhcp3-client
rm -rf dhcp3
rm -rf dhcp3
aptitude remove lzma
dhclient.conf に IPv6 関連の設定が追加
dhclient.conf に IPv6 関連の設定が追加
aptitude install cloud-initramfs-growroot cloud-initramfs-rescuevol
aptitude install cloud-initramfs-growroot cloud-initramfs-rescuevol
/etc/init/cloud-run-user-script.conf を削除
/etc/init/cloud-run-user-script.conf を削除
IPv6 系はおとなしく生かせておくのがよさそう
IPv6 系はおとなしく生かせておく
dpkg -l|grep ^rc|awk '{printf("aptitude -y purge %s\n", $2)}'
/var/www が /srv/www へ (^^;;;
</pre>
 
 
チェックする事
<pre>
/etc/fstab チェック
find . -name "*.dpkg*" -ls  でコンフィグチェック
/etc/apt/apt.conf.d/01ubuntu.dpkg-remove 削除
/etc/apt/apt.conf.d/50unattended-upgrades.dpkg-old 削除
/etc/init/ureadahead.conf.dpkg-new 削除
(aptitude install acpid) HVMでないなら不要
(aptitude install whoopsie) 不要!
aptitude install fonts-ubuntu-font-family-console
aptitude install linux-image-extra-virtual
/etc/apt/preferences.d/backports 編集 (Pin: release a=precise-backports)
/etc/munin/plugins の ディスク名替える
(qw(aaa bbb)) 替える
/etc/default/whoopsie で false
</pre>
 
お掃除
<pre>
aptitude purge whoopsie
aptitude purge apport apport-symptoms python-apport
aptitude remove update-motd
aptitude remove radeontool
aptitude remove hal
aptitude remove hal-info
aptitude remove gcc-4.4-base
aptitude remove ecryptfs-utils
aptitude remove cryptsetup
aptitude remove cryptsetup-bin
aptitude remove cpu-checker
aptitude remove consolekit
aptitude remove iputils-arping
aptitude remove libck-connector0
aptitude remove libcryptsetup4
aptitude remove libecryptfs0
aptitude remove vbetool
aptitude remove smartdimmer
aptitude remove pm-utils
aptitude remove libx86-1
aptitude remove libhal1
 
aptitude remove fuse-utils
aptitude remove cpp-4.6
aptitude remove apparmor-utils
aptitude remove libapparmor-perl
aptitude remove libapparmor1
aptitude remove libgmp3c2
</pre>
</pre>
MySQL-5.5 で InnoDB が...
<pre>
skip-innodb
default-storage-engine=MyISAM
</pre>
のパターンか
<pre>
$ sudo service mysql stop
$ sudo mv /var/lib/mysql/ib_logfile* /some/safe/location/
$ sudo service mysql start
</pre>
 [http://www.icoro.com/201109206113.html icoro : MySQLを5.5にアップデートしたら動かなくなったという話]
わかってるって
*** /dev/xvda1 will be checked for errors at next reboot ***
解消方法
<pre>
rm /var/lib/update-notifier/fsck-at-reboot
cd /usr/lib/update-notifier/
./update-motd-fsck-at-reboot
</pre>
ubuntu 決め打ちなら
lsb_release -cs
とかで、条件分岐して cookbook 変える


  [http://www.pochi.cc/~sasaki/chalow/2012-05-07-3.html Ubuntu 10.04 LTS から Ubuntu 12.04 LTS へのアップグレード]
  [http://www.pochi.cc/~sasaki/chalow/2012-05-07-3.html Ubuntu 10.04 LTS から Ubuntu 12.04 LTS へのアップグレード]
Line 890: Line 1,028:


== Opscode chef recipes ==
== Opscode chef recipes ==
<syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
echo 'deb http://apt.opscode.com/ lucid-0.10 main' | sudo tee /etc/apt/sources.list.d/opscode.list
echo 'deb http://apt.opscode.com/ lucid-0.10 main' | sudo tee /etc/apt/sources.list.d/opscode.list
wget -qO - http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -
wget -qO - http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -