X60sとDebianとJava
X60s 上の Debian に Java7 をインストールする。
# 作業ディレクトリの作成 mkdir /tmp/java7-installation-working-dir cd /tmp/java7-installation-working-dir # jdk-7u10-linux-i586.tar.gz のダウンロード wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u10-b18/jdk-7u10-linux-i586.tar.gz" # インストール tar zxvf jdk-7u10-linux-i586.tar.gz mkdir /opt/java mv jdk1.7.0_10 /opt/java/jdk1.7.0_10 ln -f -s /opt/java/jdk1.7.0_10 /opt/java/jdk1.7
設定
パスの設定を行う。以下例:
echo ' # for java7 JAVA_HOME=/opt/java/jdk1.7.0_10 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin JRE_HOME=/opt/java/jdk1.7.0_10/jre PATH=$PATH:$HOME/bin:$JRE_HOME/bin export JAVA_HOME export JRE_HOME export PATH' >> /etc/profile
動作確認
. /etc/profile java -version
後片付け
rm -rf /tmp/java7-installation-working-dir
X60sとDebianとMySQL
X60s 上の Debian に MySQL をインストールする。
32ビットなので MySQL は mysql-5.5.29-linux2.6-i686 を採用する。
参考情報
- 最新のディストリビューションはここからチェック
設定ファイルの配置
/etc/my.cnf を配置する。以下例。
# Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 64M) where MySQL plays # an important part, or systems up to 128M where MySQL is used together with # other programs (such as a web server) # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] basedir = /opt/mysql/mysql-5.5.29-linux2.6-i686 port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 64M max_allowed_packet = 1M table_open_cache = 256 sort_buffer_size = 4M net_buffer_length = 8K read_buffer_size = 1M read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M character-set-server = utf8mb4 skip-character-set-client-handshake default-storage-engine = InnoDB slow_query_log = 1 slow_query_log_file = slow_query.log long_query_time = 0.5 log-queries-not-using-indexes = 1 general-log = 1 general_log_file = query.log # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # #skip-networking # Replication Master Server (default) # binary logging is required for replication #log-bin=mysql-bin # binary logging format - mixed recommended #binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # MASTER_USER=<user>, MASTER_PASSWORD=<password> ; # # where you replace <host>, <user>, <password> by quoted strings and # <port> by the master's port number (3306 by default). # # Example: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR # # 2) Set the variables below. However, in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # change in this file to the variables' values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason, you may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted #server-id = 2 # # The replication master for this slave - required #master-host = <hostname> # # The username the slave will use for authentication when connecting # to the master - required #master-user = <username> # # The password the slave will authenticate with when connecting to # the master - required #master-password = <password> # # The port the master is listening on. # optional - defaults to 3306 #master-port = <port> # # binary logging - not required for slaves, but recommended #log-bin=mysql-bin # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = ibdata innodb_data_file_path = ibdata1:1G #innodb_log_group_home_dir = ibdata # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high innodb_buffer_pool_size = 128M innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 32M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 innodb_file_per_table innodb_file_format=barracuda innodb_strict_mode=1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout
/etc/my.cnf のファイルパーミッションの設定
chown root:mysql /etc/my.cnf chmod 660 /etc/my.cnf
インストール
# 作業ディレクトリの作成 mkdir /tmp/mysql-installation-working-dir cd /tmp/mysql-installation-working-dir # MySQLのダウンロード wget -O mysql-5.5.29-linux2.6-i686.tar.gz http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.29-linux2.6-i686.tar.gz/from/http://cdn.mysql.com/ # shared library のインストール yes | apt-get install libaio1 # MySQLのインストール groupadd mysql useradd -r -g mysql mysql mkdir -p /opt/mysql cd /opt/mysql tar zxvf /tmp/mysql-installation-working-dir/mysql-5.5.29-linux2.6-i686.tar.gz ln -s mysql-5.5.29-linux2.6-i686 mysql cd mysql chown -R mysql:mysql . scripts/mysql_install_db --user=mysql chown -R root . chown -R mysql data cp support-files/mysql.server /etc/init.d/mysql # /usr/local/bin にリンクしておく ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/innochecksum /usr/local/bin/innochecksum ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/msql2mysql /usr/local/bin/msql2mysql ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/myisamchk /usr/local/bin/myisamchk ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/myisam_ftdump /usr/local/bin/myisam_ftdump ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/myisamlog /usr/local/bin/myisamlog ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/myisampack /usr/local/bin/myisampack ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/my_print_defaults /usr/local/bin/my_print_defaults ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql /usr/local/bin/mysql ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlaccess /usr/local/bin/mysqlaccess ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlaccess.conf /usr/local/bin/mysqlaccess.conf ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqladmin /usr/local/bin/mysqladmin ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlbinlog /usr/local/bin/mysqlbinlog ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlbug /usr/local/bin/mysqlbug ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlcheck /usr/local/bin/mysqlcheck ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_client_test /usr/local/bin/mysql_client_test ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_client_test_embedded /usr/local/bin/mysql_client_test_embedded ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_config /usr/local/bin/mysql_config ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_convert_table_format /usr/local/bin/mysql_convert_table_format ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqld /usr/local/bin/mysqld ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqld-debug /usr/local/bin/mysqld-debug ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqld_multi /usr/local/bin/mysqld_multi ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqld_safe /usr/local/bin/mysqld_safe ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqldump /usr/local/bin/mysqldump ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqldumpslow /usr/local/bin/mysqldumpslow ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_embedded /usr/local/bin/mysql_embedded ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_find_rows /usr/local/bin/mysql_find_rows ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_fix_extensions /usr/local/bin/mysql_fix_extensions ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlhotcopy /usr/local/bin/mysqlhotcopy ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlimport /usr/local/bin/mysqlimport ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_plugin /usr/local/bin/mysql_plugin ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_secure_installation /usr/local/bin/mysql_secure_installation ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_setpermission /usr/local/bin/mysql_setpermission ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlshow /usr/local/bin/mysqlshow ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqlslap /usr/local/bin/mysqlslap ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqltest /usr/local/bin/mysqltest ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysqltest_embedded /usr/local/bin/mysqltest_embedded ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_tzinfo_to_sql /usr/local/bin/mysql_tzinfo_to_sql ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_upgrade /usr/local/bin/mysql_upgrade ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_waitpid /usr/local/bin/mysql_waitpid ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_zap /usr/local/bin/mysql_zap ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/perror /usr/local/bin/perror ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/replace /usr/local/bin/replace ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/resolveip /usr/local/bin/resolveip ln -f -s /opt/mysql/mysql-5.5.29-linux2.6-i686/bin/resolve_stack_dump /usr/local/bin/resolve_stack_dump
設定ファイルの修正
/etc/init.d/mysql に環境情報をセットする。
以下例:
vi /etc/init.d/mysql :%s/^basedir=$/basedir=\/opt\/mysql\/mysql-5.5.29-linux2.6-i686 :%s/^datadir=$/datadir=\/opt\/mysql\/mysql-5.5.29-linux2.6-i686\/data
mysqldの起動
/etc/init.d/mysql start
MySQLのルートパスワードの設定等
/opt/mysql/mysql-5.5.29-linux2.6-i686/bin/mysql_secure_installation # パスワードを設定し、以降全部Yで対応。
後片付け
rm -rf /tmp/mysql-installation-working-dir
自動起動設定
update-rc.d mysql defaults
Debianインストール直後
X60sとDebianとDebianとWPA-PSKとwpa_supplicantと固定IPに引き続き、インストール後の設定。
Debianのアップデート
# resynchronize the package index files from their sources apt-get update # install the newest versions of all packages currently installed on the system from the sources apt-get upgrade # remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed apt-get autoremove # clears out the local repository of retrieved package files apt-get clean # updates the package cache and checks for broken dependencies apt-get check
sshの設定
通常はネットワーク経由で作業を行うため、ssh の設定を行い、以降は ssh 経由で作業を行う。
作業者のSSH認証用設定
作業者全員分の公開鍵を設定する。以下例:
USER_NAME="作業者のユーザー名" PUB_KEY="作業者の公開鍵" mkdir /home/$USER_NAME/.ssh chmod 700 /home/$USER_NAME/.ssh echo $PUB_KEY > /home/$USER_NAME/.ssh/authorized_keys chmod 600 /home/$USER_NAME/.ssh/authorized_keys chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/.ssh
sshdの設定
- ポート番号を 22 から別の番号に変更(今回は56789番ポートとする)
- ssh接続時のrootログインを禁止
- パスワード認証を禁止
以下はviで目視確認しながら置換を行う例:
vi /etc/ssh/sshd_config :%s/Port 22/Port 56789/gc :%s/PermitRootLogin yes/PermitRootLogin no/gc :%s/#PasswordAuthentication yes/PasswordAuthentication no/gc
sshdの再起動
/etc/init.d/ssh restart
sshd の再起動後、公開鍵認証でログインできるかを確認する。
iptablesの設定
設定ファイルの作成
以下を実行して設定ファイルを /etc/network/if-pre-up.d/iptables-setup に作成する。*1
echo '#!/bin/sh ### initialize ### /sbin/iptables -F # テーブルを初期化 /sbin/iptables -X # チェーンを削除 ### policies ### /sbin/iptables -P INPUT DROP # 基本的に外部からのパケットは基本的に無視する。 /sbin/iptables -P OUTPUT ACCEPT # 基本的に内部で生成されたパケットは基本的に処理する。 /sbin/iptables -P FORWARD DROP # 基本的にパケットのルーティングは行わない。 ### rules ### /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 80 -j ACCEPT # tomcat /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 443 -j ACCEPT # tomcat(ssl) /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 56789 -j ACCEPT # ssh /sbin/iptables -A INPUT -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT # icmp /sbin/iptables -A INPUT -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT # icmp /sbin/iptables -A INPUT -p ALL -i lo -s 127.0.0.1 -j ACCEPT # ローカルループバックからの入力は許可 /sbin/iptables -A INPUT -p ALL -m state --state ESTABLISHED,RELATED -j ACCEPT # セッション確立後のパケット疎通は許可' > /etc/network/if-pre-up.d/iptables-setup chmod 755 /etc/network/if-pre-up.d/iptables-setup
フィルタリングの手動実行
/etc/network/if-pre-up.d/iptables-setup
ntpの設定
ntpのインストール
yes | apt-get install ntp
設定ファイルの変更
/etc/ntp.conf ファイルの下記の箇所を
server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst
下記の内容に置き換える
server ntp1.jst.mfeed.ad.jp server ntp2.jst.mfeed.ad.jp server ntp3.jst.mfeed.ad.jp
ntpdの再起動
/etc/init.d/ntp restart
その他必要なパッケージのインストール
自分が必要と思うパッケージを思うままに入れる。
vim のインストール
yes | apt-get install vim echo 2 | update-alternatives --config editor update-alternatives --config editor # /usr/bin/vim.basic が選択されていることを確認して CTRL+C
pbzip2 のインストール
apt-get install bzip2
DebianとWPA-PSKとwpa_supplicantと固定IP
前回 X60sとDebian では無線 LAN を WEP で接続した。
その時は出先で作業を行っていたのだが、仕事場に戻ってみたら無線 LAN が WPA-PSK 方式というオチ o...rz
ということで、今回は WPA-PSK 方式で設定してみる。
wpa_supplicant のインストール
今回は wpa_supplicant を利用するのだが、有線接続できず(UTPケーブルを発掘するのがメンドイw) WPA 方式の無線 LAN ルータしかない状態ではネットワークからパッケージをダウンロードできない。
ということで、インストールに使用した DVD-ROM から wpa_supplicant をインストールする。
DVD-ROMのマウント
mount /media/cdrom0
wpa_supplicantパッケージおよび関連パッケージの検索
wpa_supplicantパッケージおよび関連パッケージの位置を確認します。
find /media/cdrom0 -name wpa* find /media/cdrom0 -name libnl* find /media/cdrom0 -name libpcsclite* find /media/cdrom0 -name libdbus-1*
wpa_supplicantパッケージのインストール
上記で位置を確認したwpa_supplicantパッケージをインストールします。
dpkg -i /media/cdrom0/pool/main/d/dbus/libdbus/libdbus-1-3_1.2.24-4+squeeze1_i386.deb dpkg -i /media/cdrom0/pool/main/libn/libnl/libnl1_1.1-6_i386.deb dpkg -i /media/cdrom0/pool/main/p/pcsc-lite/libpcsclite1_1.5.5-4_i386.deb dpkg -i /media/cdrom0/pool/main/w/wpasupplicant/wpasupplicant_0.6.10-2.1_i386.deb
設定
wpa_supplicant.confの作成
ツールを利用して wpa_supplicant.conf ファイルのひな形を作成します。
wpa_passphrase [ ssid ] [ passphrase ] > /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf の書き換え
パスフレーズがそのまま文字として書かれてしまっているので、削除します。
network={ ssid="ssid" #psk="passphrase" ← この行は消しておきましょう。 psk=暗号化された psk }
/etc/network/interface の編集(DHCP版)
以下を追加。
# The primary network interface allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
今回は関係ないけど、バーチャル環境の場合は以下のように TSO(TCP Segmentation Offload)をOFFにする設定も追加しておくのが無難。
post-up /sbin/ethtool -K wlan0 tso off
疎通確認
ひとまず手動で実行して、ネットワークに接続できるかを確認する。
wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf dhclient wlan0 ping www.yahoo.co.jp # check! killall wpa_supplicant
ifup/ifdown経由での動作確認
ifdown と ifup を行った後にインターネット上のサイトにアクセスできればOK!
ifdown wlan0 ifup wlan0 ping www.yahoo.co.jp
wlan0に固定IPを指定
IP アドレスが定まらないサーバというのもかなり微妙なので、/etc/network/interface の wlan0 の設定を以下のように変更。
# The primary network interface allow-hotplug wlan0 iface wlan0 inet wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf address 192.168.11.20 netmask 255.255.255.0 network 192.168.11.1 broadcast 192.168.11.255 gateway 192.168.11.1
インタフェースの再起動
ifdown wlan0 ifup wlan0
X60sとDebian
先日部屋の片づけをしていたところ、ずいぶん長い間放置されていた X60s を発掘した。
メモリは 2.5 GB。ディスクはリカバリ用の工場出荷イメージ領域を除いて 33 GB。
実験用サーバとしてはまだ使えそうだ。
ということで、Debian を入れて実験用サーバにすることにした。
OSイメージの取得
今回は http://www.debian.org/CD/ から DVD の ISO イメージの1枚目のみを torrent でダウンロード。
ThinkPad X60s は Core 2 Duo ではなく Core Duo なので、amd64 ではなく i386 を選択。
Overview - ThinkPad X60s
チェックサムの確認
今回ダウンロードを行った環境は sygwin が入っていない Windows XP だったので、Windows のチェックサム確認ツール fciv を利用してチェック。
(手元のWindows環境にfcivが無い場合はここから落とせます)
C:\tmp>fciv debian-6.0.6-i386-DVD-1.iso -sha1 // // File Checksum Integrity Verifier version 2.05. // 373269dbe08e6ad8650d0156251629ada5fee4eb debian-6.0.6-i386-dvd-1.iso
DVD作成
今回は CDBurnerXP を使用。
焼ければ何でもOK。
商用ファームウェアのダウンロード
Intel Wireless 3945 用のファームウェアが必要になるので、http://packages.debian.org/squeeze/firmware-iwlwifi から firmware-iwlwifi_0.28+squeeze1_all.deb をダウンロードし、展開*1し、以下のファイルを USB メモリに入れておく。
iwlwifi-3945-1.ucode iwlwifi-3945-2.ucode
DVDからのBoot
X60s にファームウェアの入った USB メモリを接続し、USB-DVD ドライブを接続し、USB-DVD ドライブに最初のディスクを入れて起動。
起動直後に F12 キーを押し、Boot Menu から USB CD を選択。*2
インストール
- DVD からブートしたら Install を選択。
- iwlwifi-3945-1.ucode と iwlwifi-3945-2.ucode については 6.4. Loading Missing Firmware にも書かれている通り USB 等からロードできる旨が表示されるのだが、どうもうまく読み込んでくれないようなので、ALT+F2 でコマンドラインに移り、以下のように手動でコピーを行ない、USB メモリを抜き、ALT+F1 でインストーラに戻る。
mount -t vfat /dev/sdb1 /mnt mkdir /lib/firmware cp /mnt/iwlwifi-3945-* /lib/firmware/ umount /mnt
リブート後
- ping でインターネットに出られることを確認。*4