Zimbra on EC2 tips: Difference between revisions

No edit summary
 
Line 93: Line 93:


(古い ubuntu ec2-init パッケージから流用しました)
(古い ubuntu ec2-init パッケージから流用しました)
 
'''ubuntu の流儀で hostname を一旦正しく設定します'''
 
/etc/hostname に host名 (この場合は aws) を設定します。
<syntaxhighlight>
echo "aws" | sudo tee /etc/hostname
sudo /bin/hostname -F /etc/hostname
</syntaxhighlight>
 
/etc/hosts に、このインスタンスのプライベート IP address, host名, fqdn を設定します。
<syntaxhighlight>
127.0.0.1 localhost
IPADDRESS aws.example.com aws
 
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
</syntaxhighlight>
 
正しく host名と fqdn 設定されているかを確認します。
<syntaxhighlight>
/bin/hostname
(host名が返る)
/bin/hostname -f
(fqdnが返る)
/bin/hostname -d
(ドメイン名が返る)
</syntaxhighlight>
 
正常に動作したら自動化スクリプトを仕込みます。
 
/usr/local/etc/init に配置、実行権限を付与します。
/usr/local/etc/init に配置、実行権限を付与します。


Line 126: Line 160:


base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
my_hostname = urllib.urlopen('%s/local-hostname/' % base_url).read()
my_ip = urllib.urlopen('%s/local-ipv4/' % base_url).read()
my_ip = urllib.urlopen('%s/local-ipv4/' % base_url).read()
my_fqdn = os.popen("/bin/cat /etc/hostname").read().rstrip()
my_fqdn = os.popen("/bin/hostname -f").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 147: Line 181:
/usr/local/etc/bind/templates/hosts.tmpl
/usr/local/etc/bind/templates/hosts.tmpl
  127.0.0.1 localhost
  127.0.0.1 localhost
#127.0.1.1 $hostname
  $localipv4 $fqdn $hostname
  $localipv4 $fqdn  
   
   
  # The following lines are desirable for IPv6 capable hosts
  # The following lines are desirable for IPv6 capable hosts
Line 193: Line 226:
base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
my_ip = urllib.urlopen('%s/local-ipv4/' % base_url).read()
my_ip = urllib.urlopen('%s/local-ipv4/' % base_url).read()
my_fqdn = os.popen("/bin/cat /etc/hostname").read().rstrip()
my_fqdn = os.popen("/bin/hostname -f").read().rstrip()
ip = IP(my_ip)
ip = IP(my_ip)
my_arpa = ip.reverseName().rstrip('.')
my_arpa = ip.reverseName().rstrip('.')
Line 295: Line 328:
  supersede domain-name "example.com";
  supersede domain-name "example.com";


/etc/hostname に fqdn (この場合は aws.example.com) を設定します。
<syntaxhighlight>
echo "aws.example.com" | sudo tee /etc/hostname
sudo /bin/hostname -F /etc/hostname
</syntaxhighlight>


ここで一度この script を起動して動作確認します。
ここで一度この script を起動して動作確認します。