2015年12月13日日曜日

dnsサーバー_bind起動に失敗_centos6

http://kajuhome.com/bind.shtml#n09-01
を参考にcentos6環境で、DNSサーバーを構築
しかし、bind起動時にエラー
-----
# /etc/rc.d/init.d/named start
Generating /etc/rndc.key:[  OK  ]
named を起動中:
Error in named configuration:
/etc/named.conf:35: unknown option 'error'
[失敗]
#
------
となりエラー
/etc/named.confの35,36行目に以下のパラメータを設定していたので削除。
削除後は起動成功
------
            error (unexpected RCODE SERVFAIL) resolving
            error (network unreachable) resolving
------

2015年12月12日土曜日

DiceでIPアドレス自動検出ができない_centos6

http://centossrv.com/domain-ieserver.shtml
を参考にDiCEの設定を実施

-----
# setarch `uname -m` /usr/local/bin/DiCE/diced
=-=-=- DiCE DynamicDNS Client -=-=-=
Version 0.19 for Japanese
Copyright(c) 2001 sarad
:setup
IPアドレスの検出方法を指定してください
(0) 自動検出
(1) ローカルのネットワークアダプタから検出
(2) 外部のスクリプトから検出
<現在:0>
(N)変更しない  (P)戻る
>n
-------------------------------------------------
プライベートIPアドレスも検出対象ですか? (Y/N)
<現在:いいえ>
(P)戻る
>n
-------------------------------------------------
IPアドレスの検出をテストしますか? (Y/N)
(P)戻る
>y

-----
1時間以上、画面がすすまないためCtrl+Cでキャンセル。
対策を探すと以下のサイトを発見

http://blog.aburami.net/archives/53915071.html

以下のオペレーションで現象改善。
------
# cat /usr/local/bin/DiCE/ipcheck.dat
http://www.hi-ho.ne.jp/cgi-bin/user/yoshihiro_e/ip_chk.cgi
http://hpcgi3.nifty.com/sarad/ip_check.cgi
http://checkip.dyndns.org/
# GET http://www.hi-ho.ne.jp/cgi-bin/user/yoshihiro_e/ip_chk.cgi
Error!!#
# GET http://hpcgi3.nifty.com/sarad/ip_check.cgi
Error!!#
# GET http://checkip.dyndns.org/
Current IP CheckCurrent IP Address: 1
xxx.xxx.xxx.xxx
/***唯一IPアドレスが表示***/
# setarch `uname -m` /usr/local/bin/DiCE/diced
=-=-=- DiCE DynamicDNS Client -=-=-=
Version 0.19 for Japanese
Copyright(c) 2001 sarad:setup
IPアドレスの検出方法を指定してください
(0) 自動検出
(1) ローカルのネットワークアダプタから検出
(2) 外部のスクリプトから検出
<現在:0>
(N)変更しない  (P)戻る
>2      /***0ではなく、2を設定***/
-------------------------------------------------
スクリプトのURLを入力してください
<現在:>
(N)変更しない  (P)戻る
>http://checkip.dyndns.org/   /***IPアドレスが表示されたcheckipのアドレスを設定する***/
-------------------------------------------------
プライベートIPアドレスも検出対象ですか? (Y/N)
<現在:いいえ>
(P)戻る
>n
-------------------------------------------------
IPアドレスの検出をテストしますか? (Y/N)
(P)戻る
>y
検出IPアドレス>xxx.xxx.xxx.xxx /***IPアドレスが表示****
-----
その後の設定は
http://centossrv.com/domain-ieserver.shtml
の内容と同様。

centos6環境で、DiCEのダウンロードしたファイルの解凍失敗

http://centossrv.com/domain-ieserver.shtml
を参考にDiceをダウンロード
しかし、ファイル名が
download.cgi?p=diced019
となり、gzファイルの形式ではない。
------
#cd /usr/local/bin/
# wget http://www.hi-ho.ne.jp/cgi-bin/user/yoshihiro_e/download.cgi?p=diced019
--2015-12-12 19:42:03--  http://www.hi-ho.ne.jp/cgi-bin/user/yoshihiro_e/download.cgi?p=diced019
www.hi-ho.ne.jp をDNSに問いあわせています... 202.224.157.11
www.hi-ho.ne.jp|202.224.157.11|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 302 Found
場所: http://homepage3.nifty.com/sarad/diced01914.tar.gz [続く]
--2015-12-12 19:42:03--  http://homepage3.nifty.com/sarad/diced01914.tar.gz
homepage3.nifty.com をDNSに問いあわせています... 2001:258:8600:100:202:248:88:144, 202.248.88.142
homepage3.nifty.com|2001:258:8600:100:202:248:88:144|:80 に接続しています... 接 続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 1094082 (1.0M) [application/x-gzip]
`download.cgi?p=diced019' に保存中
100%[======================================>] 1,094,082   1.05M/s 時間 1.0s
2015-12-12 19:42:04 (1.05 MB/s) - `download.cgi?p=diced019' へ保存完了 [1094082/1094082]
# ls
download.cgi?p=diced019
------

以下のサイトでwgetコマンドを実施することで、解凍成功
------
# wget http://homepage3.nifty.com/sarad/diced01914.tar.gz
--2015-12-12 19:49:09--  http://homepage3.nifty.com/sarad/diced01914.tar.gz
homepage3.nifty.com をDNSに問いあわせています... 2001:258:8600:100:202:248:88:144, 202.248.88.142
homepage3.nifty.com|2001:258:8600:100:202:248:88:144|:80 に接続しています... 接 続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 1094082 (1.0M) [application/x-gzip]
`diced01914.tar.gz' に保存中
100%[======================================>] 1,094,082   1.04M/s 時間 1.0s
2015-12-12 19:49:10 (1.04 MB/s) - `diced01914.tar.gz' へ保存完了 [1094082/1094082]
# ls
diced01914.tar.gz  download.cgi?p=diced019  download.cgi?p=diced019.1
------

参考
http://centossrv.com/patio/centossrv.cgi?read=2852&ukey=0

2015年12月7日月曜日

centos6環境にkvmをインストール

構成
windows7+teraterm------>centos6
へリモートから操作
http://www.server-world.info/query?os=CentOS_6&p=kvm&f=1
を参考にインストール

# yum -y install qemu-kvm libvirt python-virtinst bridge-utils
# モジュールが読み込まれているか確認
# lsmod | grep kvm
kvm_intel     46589 0
kvm     292815 1 kvm_intel
# /etc/rc.d/init.d/libvirtd start
Starting libvirtd daemon:     [ OK ]
# /etc/rc.d/init.d/messagebus start
Starting system message bus:     [ OK ]
# chkconfig libvirtd on
# chkconfig messagebus on

#####ここまでは上記のリンクのとおり####
# 続いてブリッジネットワークbr0を作成
# mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br0
# vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
####ここでリモートアクセスができなくなる####
####centos6に直接ログオンして、eth0を再構築する####
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# 新規作成
DEVICE=eth0
 TYPE=Ethernet
 ONBOOT=yes
 BRIDGE=br0
# /etc/rc.d/init.d/network restart
####ここで再度リモートからアクセスが可能。

インターフェース br0 を活性化中: エラー: 接続のアクティベーションに失敗_kvmインストール中

centos6環境でKVMインストール時実施。
http://www.server-world.info/query?os=CentOS_6&p=kvm
を参考に構成実施。

構成中に
接続のアクティベーションに失敗
エラー発生。

結果として、以下のコマンドでNetworkManagerをオフにしたら現象改善。
chkconfig networkManager off
/etc/rc.d/init.d/network restart
------
[root@centos6 ~]# /etc/rc.d/init.d/network restart
インターフェース eth0 を終了中:                            [  OK  ]
インターフェース eth1 を終了中:                            [  OK  ]
ループバックインターフェースを終了中                       [  OK  ]
ループバックインターフェイスを呼び込み中                   [  OK  ]
インターフェース eth0 を活性化中:  device eth0 is already a member of a bridge; can't enslave it to bridge br0.
                                                           [  OK  ]
インターフェース br0 を活性化中:  エラー: 接続のアクティベーションに失敗: Failed to determine connection's virtual interface name
                                                           [失敗]
[root@centos6 ~]# service NetworkManager stop
NetworkManager デーモンを停止中:                           [  OK  ]
[root@centos6 ~]# chkconfig networkManager off
サービス networkManager に関する情報の読み込み中にエラーが発生しました: そのようなファイルやディレクトリはありません
[root@centos6 ~]# chkconfig NetworkManager off
[root@centos6 ~]# /etc/rc.d/init.d/network restart
ループバックインターフェースを終了中                       [  OK  ]
ループバックインターフェイスを呼び込み中                   [  OK  ]
インターフェース eth0 を活性化中:  device eth0 is already a member of a bridge; can't enslave it to bridge br0.
                                                           [  OK  ]
インターフェース br0 を活性化中:  Determining if ip address 192.168.0.5 is already in use for device br0...
                                                           [  OK  ]

------

2015年10月13日火曜日

サーバー起動時CLIENT MAC ADDRのメッセージ表示

ESXi導入環境のサーバーの電源を入れてしばらくすると

CLIENT MAC ADDR
DHCP・・・・・
というメッセージをずっと繰り返したままになる。


BIOSでブートはHDDを最優先にしていて状況は変わらず。


似たような事例を探すと以下のリンクをみつけた。


CLIENT MAC ADDR・・・DHCP というエラー表示

対処方法としては
物理的に、ハードディスクに繋がっているコネクタケーブルが外れているとか、断線している
  • そもそもハードディスクが壊れている(回転しないとか、認識できないほどディスクが破損しているとか)
  • ハードディスクからつながっているマザーボード自体に、何らかのエラーがある
  • だそうだ。

    これから切り分け予定だが、下手するとHDDの再購入が必要かも。

    予定
    サーバーをあけて様子を見る。HDDの再接続後、電源ONして動作確認。

    2015年10月3日土曜日

    mkfs.ext4コマンド実行時に、"読み込み専用ファイルシステムです"エラー _HAクラスタ検証中

    参考URL
    http://enakai00.hatenablog.com/entry/20110804/1312437111
    を参考
    host#virsh console guest1

    guest1#mkfs.ext4 /dev/sdb
    mke2fs 1.41.12 (17-May-2010)
    /dev/sdb is entire device, not just one partition!
    Proceed anyway? (y,n) y
    /dev/sdb: 読み込み専用ファイルシステムです while setting up superblock


    /***dmesgの結果を調べる***/
    # dmesg | grep sdb
    sd 2:0:0:2: [sdb] 2048000 512-byte logical blocks: (1.04 GB/1000 MiB)
    sd 2:0:0:2: [sdb] Write Protect is on
    sd 2:0:0:2: [sdb] Mode Sense: 49 00 80 08
    sd 2:0:0:2: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
     sdb: unknown partition table
    sd 2:0:0:2: [sdb] Attached SCSI disk

    # dmesg | grep error
    # dmesg | grep readonly
    EXT4-fs (dm-0): INFO: recovery required on readonly filesystem
    EXT4-fs (dm-0): orphan cleanup on readonly fs
    # dmesg | grep read-only
    Write protecting the kernel read-only data: 10240k

    /***fdiskでは認識されている***/

    # fdisk -l /dev/sda /dev/sdb
    ディスク /dev/sda: 104 MB, 104857600 バイト
    ヘッド 4, セクタ 50, シリンダ 1024
    Units = シリンダ数 of 200 * 512 = 102400 バイト
    セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    ディスク識別子: 0x00000000

    ディスク /dev/sdb: 1048 MB, 1048576000 バイト
    ヘッド 33, セクタ 61, シリンダ 1017
    Units = シリンダ数 of 2013 * 512 = 1030656 バイト
    セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    ディスク識別子: 0x00000000

    /***fsckコマンドの失敗***/
    # fsck /dev/sdb
    fsck from util-linux-ng 2.17.2
    e2fsck 1.41.12 (17-May-2010)
    fsck.ext2: 読み込み専用ファイルシステムです while trying to open /dev/sdb
    Disk write-protected; use the -n option to do a read-only
    check of the device.


    今後の予定
    もう少しエラーを回避する手段を調べる。

    2015年8月8日土曜日

    centos7環境にKVM導入中virshコマンドで"インターフェース 'eth0' を取得できませんでした"エラー

    KVMの導入にチャレンジ
    構成
    ホストOS centos7
    ゲストOS  centos6

    以下のページを参照して導入実行
    http://centossrv.com/kvm.shtml

    ただしvirshコマンドでエラー発生
    [root@centos7 ~]# virsh iface-bridge eth0 br0
    エラー: インターフェース 'eth0' を取得できませんでした
    エラー: インターフェースが見つかりません: 'eth0' という名前のインターフェースを見つけられませんでした
    ifconfigでデバイスを確認
    [root@centos7 ~]# ifconfig
    eno1: flags=4163  mtu 1500
            inet 192.168.0.24  netmask 255.255.255.0  broadcast 192.168.0.255
            inet6 fe80::29c:2ff:fe9d:fe8d  prefixlen 64  scopeid 0x20
            inet6 240f:a:1b03:1:29c:2ff:fe9d:fe8d  prefixlen 64  scopeid 0x0
            ether 00:9c:02:9d:fe:8d  txqueuelen 1000  (Ethernet)
            RX packets 21172  bytes 27236891 (25.9 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 15385  bytes 1662502 (1.5 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
            device interrupt 17  memory 0xfbfe0000-fc000000 

    lo: flags=73  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10
            loop  txqueuelen 0  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    virbr0: flags=4099  mtu 1500
            inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
            ether 52:54:00:61:6d:97  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


    eth0がないからeno1と置き換えてコマンドを実行する必要がある。
    http://centossrv.com/kvm.shtml
    にあるeth0の部分をeno1とおきかえてると以下のエラーが発生
    [root@centos7 ~]# virsh iface-bridge eno1 br0
    エラー: ネットワークデバイス br0 がすでに存在します

    なぜかbr0は作られている・・・。
    任意の名前br1を設定することでコマンド成功
    [root@centos7 n~]# virsh iface-bridge eno1 br1
    ブリッジ br1 を作成して、デバイス eno1 に接続しました
    ブリッジインターフェース br1 が起動しました

    2015年6月3日水曜日

    配列の各要素にN人分の名前と点数を入力するプログラム

    参考 Javaバイブルシリーズ Java入門 Java 7版

    P164 確認問題6.5 問題3

    ------
    import java.io.*;
    public class Toi6_5_3 {
     public static void main(String[] args) throws IOException {

      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));

      final int N = 5;
      String[] arrayName = new String[N];
      int[] arrayTensu = new int[N];

      for (int i = 0; i < arrayName.length; i++) {
       System.out.print((i + 1) + "人目の名前を入力>");
       arrayName[i] = br.readLine();
       System.out.print((i + 1) + "人目の点数を入力>");
     
       arrayTensu[i] = Integer.parseInt(br.readLine());
      }

      for (int i = 0; i < arrayName.length; i++) {
       System.out.print(arrayName[i] + "さん");
       System.out.println(arrayTensu[i] + "点");
      }
     }
    }
    ------
    実行結果
    ------
    >java Toi6_5_3
    1人目の名前を入力>Ryu
    1人目の点数を入力>80
    2人目の名前を入力>Masa
    2人目の点数を入力>50
    3人目の名前を入力>Mari
    3人目の点数を入力>55
    4人目の名前を入力>Yuki
    4人目の点数を入力>94
    5人目の名前を入力>Ichi
    5人目の点数を入力>51
    Ryuさん80点
    Masaさん50点
    Mariさん55点
    Yukiさん94点
    Ichiさん51点
     -- Press any key to exit (Input "c" to continue) --
    ------

    配列の全要素の添え字より1大きい値を設定するプログラム

    参考 Javaバイブルシリーズ Java入門 Java 7版

    P163 確認問題6.5 問題2

    ------
    public class Toi6_5_2 {
     public static void main(String[] args) {
      int[] arrayNo = new int[10];
     
      for (int i = 0; i < 10; i++) {
       arrayNo[i] = i + 1;
      }
     
      for (int i = 0; i < arrayNo.length; i++) {
       System.out.print(arrayNo[i] + " ");
      }
      System.out.println();
     }
    }
    ------
    実行結果
    ------
    >java Toi6_5_2
    1 2 3 4 5 6 7 8 9 10
    ------

    配列の全要素に1を設定するプログラム

    参考Javaバイブルシリーズ Java入門 Java 7版
    P162 確認問題6.5 1
    ------
    public class Toi6_5_1 {
     public static void main(String[] args) {
      int[] arraySeikai = new int[10];
     
      for (int i = 0; i < 10; i++) {
       arraySeikai[i] = 1;
      }
     
      for (int i = 0; i < arraySeikai.length; i++) {
       System.out.print(arraySeikai[i] + " ");
      }
      System.out.println();
     }
    }
    ------
    実行結果
    ------
    >java Toi6_5_1
    1 1 1 1 1 1 1 1 1 1
    ------

    午前と午後の点数の合計を表示するプログラム

    ある試験の点数は午前と午後で対になっている。
    午前と午後の点数の合計を求めるプログラムをつくる。

    参考Javaバイブルシリーズ Java入門 Java 7版
    P160 確認問題6.4

    ------
    public class Toi6_4_1 {
     public static void main(String[] args) {
      int[] arrayAmTen = { 70,85,60,65,75 };
      int[] arrayPmTen = { 80,60,70,65,70 };
      int[] arrayTotalTen = new int[5];
     
      for (int i = 0; i < arrayTotalTen.length; i++) {
       arrayTotalTen[i] = arrayAmTen[i] + arrayPmTen[i];
       System.out.println((i + 1) + "人目の合計は" + arrayTotalTen[i]);
      }
     }
    }
    ------

    ------
    >java Toi6_4_1
    1人目の合計は150
    2人目の合計は145
    3人目の合計は130
    4人目の合計は130
    5人目の合計は145
     -- Press any key to exit (Input "c" to continue) --
    ------

    2015年4月16日木曜日

    3つの整数を入力して最小値を表示するjavaプログラム

    Javaバイブルシリーズ Java入門 P143応用課題5.3.2

    ------
    import java.io.*;
    public class Minimum {
     public static void main(String[] args) throws IOException {
     
      final String MIN_MESSAGE = "最大値は";
      String max = "";
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
     
     
      System.out.print("xを入力>");
      int x = Integer.parseInt(br.readLine());
      System.out.print("yを入力>");
      int y = Integer.parseInt(br.readLine());
      System.out.print("zを入力>");
      int z = Integer.parseInt(br.readLine());
     
      int minValue = x;
      if (y < x) {
       minValue = y;
         }
      if (z < y && z < x) {
       minValue = z;
      }
      System.out.println(MIN_MESSAGE + minValue);


     }
    }
    ------

    実行結果
    ------
    >java Minimum
    xを入力>4
    yを入力>5
    zを入力>3
    最大値は3
     -- Press any key to exit (Input "c" to continue) --
    ------

    3つの整数を入力して最大値を表示するjavaプログラムパターン2

    Javaバイブルシリーズ Java入門 P143 応用課題5.3.1


    ------
    import java.io.*;
    public class Maximum1 {
     public static void main(String[] args) throws IOException {
     
      final String MAX_MESSAGE = "最大値は";
      String max = "";
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
     
     
      System.out.print("xを入力>");
      int x = Integer.parseInt(br.readLine());
      System.out.print("yを入力>");
      int y = Integer.parseInt(br.readLine());
      System.out.print("zを入力>");
      int z = Integer.parseInt(br.readLine());
     
      int maxValue = x;
      if (y > x) {
       maxValue = y;
         }
      if (z > y && z > x) {
       maxValue = z;
      }
      System.out.println(MAX_MESSAGE + maxValue);


     }
    }
    ------

    実行結果
    ------
    >java Maximum1
    xを入力>4
    yを入力>3
    zを入力>5
    最大値は5
     -- Press any key to exit (Input "c" to continue) --
    ------

    3つの整数を入力して最大値を表示するjavaプログラムパターン1

    Javaバイブルシリーズ Java入門 P142演習問題5.3

    ------
    import java.io.*;
    public class Maximum {
     public static void main(String[] args) throws IOException {
     
      final String MAX_MESSAGE = "最大値は";
      String max = "";
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
     
     
      System.out.print("xを入力>");
      int x = Integer.parseInt(br.readLine());
      System.out.print("yを入力>");
      int y = Integer.parseInt(br.readLine());
      System.out.print("zを入力>");
      int z = Integer.parseInt(br.readLine());
     
      if(y > x || z > x) {
       if(z > y) {
        max = MAX_MESSAGE + z;
       } else {
        max = MAX_MESSAGE + y;
       }
         } else {
       if (z > x) {
        max = MAX_MESSAGE + z;
       } else {
        max = MAX_MESSAGE + x;
       }
      }
      System.out.println(max);


     }
    }
    ------

    実行結果
    ------
    >java Maximum
    xを入力>3
    yを入力>4
    zを入力>5
    最大値は5
     -- Press any key to exit (Input "c" to continue) --
    ------

    50点以上のときは合格と表示,50点未満ならあと何点で合格ですと表示するjavaプログラム

    Javaバイブルシリーズ Java入門 P140 演習問題5.2

    ------
    import java.io.*;
    public class PassJudge {
     public static void main(String[] args) throws IOException {
      final int GOKAKU_TEN = 50;
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
      String buf;
     
      System.out.println("終了は[Enter]だけを入力");
      System.out.print("点数入力>");
      while (!(buf = br.readLine()) .equals("")) {
      
       int ten = Integer.parseInt(buf);
       String message = "";
      
       if(ten < 50){
        int fusoku = -1 * (ten - 50);
        message = "あと" + fusoku + "点で合格です";
       } else {
        message = "合格です";
       }
           System.out.println(message);
           System.out.print("整数入力>");
          }
     }
    }
    ------

    実行結果
    ------
    >java PassJudge
    終了は[Enter]だけを入力
    点数入力>51
    合格です
    整数入力>40
    あと10点で合格です
    整数入力>
     -- Press any key to exit (Input "c" to continue) --
    ------

    入力された整数があらかじめ指定された整数の倍数かどうかを判定するjavaプログラム

    Javaバイブルシリーズ Java入門 P140応用課題5.1.1

    下記の例は3の倍数かどうかを判定するプログラム
    ------
    import java.io.*;
    public class MultipleOfX {
     public static void main(String[] args) throws IOException {
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
      String buf;
     
      System.out.println("終了は[Enter]だけを入力");
      System.out.print("整数入力>");
      while (!(buf = br.readLine()) .equals("")) {
      
       int num = Integer.parseInt(buf);
       int x = 3;
      
       if(num % x == 0){
        System.out.println(num + "は" + x + "の倍数です");
       } else {
        System.out.println(num + "は" + x + "の倍数ではありません");
       }
           System.out.print("整数入力>");
          }
     }
    }
    ------

    実行結果
    ------
    >java MultipleOfX
    終了は[Enter]だけを入力
    整数入力>3
    3は3の倍数です
    整数入力>4
    4は3の倍数ではありません
    整数入力>5
    5は3の倍数ではありません
    整数入力>
     -- Press any key to exit (Input "c" to continue) --
    ------

    入力された整数が奇数か偶数かをチェックするjavaプログラム

    参考
    Javaバイブルシリーズ Java入門 P139演習5.1

    ------
    import java.io.*;
    public class OddEvenJudge {
     public static void main(String[] args) throws IOException {
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
      String buf;
     
      System.out.println("終了は[Enter]だけを入力");
      System.out.print("整数入力>");
      while (!(buf = br.readLine()) .equals("")) {
      
       int num = Integer.parseInt(buf);
      
       if(num % 2 == 0){
        System.out.println(num + "は偶数です");
       } else {
        System.out.println(num + "は奇数です");
       }
           System.out.print("整数入力>");
          }
     }
    }
    ------

    実行結果
    ------
    >java OddEvenJudge
    終了は[Enter]だけを入力
    整数入力>6
    6は偶数です
    整数入力>5
    5は奇数です
    整数入力>
     -- Press any key to exit (Input "c" to continue) --
    ------

    2015年4月12日日曜日

    BINDの起動に失敗cetnos6.6

    http://centossrv.com/bind.shtml
    を参考にBINDを構築中。


    しかし




    BINDの起動に失敗


    ホスト名は
    centos.com
    とする
    ------
    [root@centos etc]# /etc/rc.d/init.d/named start
    named を起動中:
    Error in named configuration:
    zone localhost.localdomain/IN: loaded serial 0
    zone localhost/IN: loaded serial 0
    zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
    zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
    zone 0.in-addr.arpa/IN: loaded serial 0
    zone centos.com/IN: loaded serial 2011062001
    zone 0.168.192.in-addr.arpa/IN: loaded serial 2011062001
    zone centos.com/IN: loading from master file centos.com.db.wan failed: file not found
    zone centos.com/IN: not loaded due to errors.
    external/centos.com/IN: file not found
                                                               [失敗]
    [root@centos etc]#
    ------




    現在原因を調査中。

    2015年3月21日土曜日

    centos 6でDiCE設定実施時setarchコマンドでエラー

    http://centossrv.com/domain-ieserver.shtml
    を参照してDiCE設定を実施。
    しかしエラー発生


    -----
    # setarch `uname -m` /usr/local/bin/DiCE/diced
    setarch: /usr/local/bin/DiCE/diced: 縺昴・繧医≧縺ェ繝輔ぃ繧、繝ォ繧・ョ繧」繝ャ繧ッ繝医Μ縺ッ縺ゅj縺セ縺帙s
    ------
    調べると以下のコマンドを実行するとよいとのこと


    ------
    # yum install ld-linux.so.2
    ------
    参照元
    http://centossrv.com/bbshtml/webpatio/2332.shtml
    その後再度setarchコマンドを実行すると成功。


    ------
    # setarch `uname -m` /usr/local/bin/DiCE/diced
    =-=-=- DiCE DynamicDNS Client -=-=-=
    Version 0.19 for Japanese
    Copyright(c) 2001 sarad
    :
    ------

    2015年2月22日日曜日

    文字列をアルファベット順(辞書式)に比較して先に現れる文字列を表示するプログラム

    参考 Javaバイブルシリーズ Java入門 Java 7版
    P128 確認問題 5.5
    ------
    import java.io.*;
    public class DictionaryComp {
     public static void main(String[] args) throws IOException {

      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));


      String appear = "先に現れる文字列:";

      System.out.print("文字列1>");
      String str1 = br.readLine();

      System.out.print("文字列2>");
      String str2 = br.readLine();

      if (str1.compareTo(str2) < 0) {
       appear += str1;
      } else if (str1.compareTo(str2) > 0) {
       appear += str2;
      } else {
       appear = "一致:" + str1 + "と" + str2;
      }

      System.out.println(appear);
     }
    }
    ------

    実行結果
    ------
    >java DictionaryComp
    文字列1>baseboll
    文字列2>bus
    先に現れる文字列:baseboll
     -- Press any key to exit (Input "c" to continue) --
    ------

    2015年2月11日水曜日

    入力点数が70点以上なら"合格",70点未満なら"不合格"と表示するプログラム

    参考 Javaバイブルシリーズ Java入門 Java 7版
    P121 確認問題 5.3

    ------
    import java.io.*;
    public class PassJudge02 {
     public static void main(String[] args) throws IOException {

      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));

      System.out.print("点数を入力>");
      int ten = Integer.parseInt(br.readLine());

      if (ten < 70) {
       System.out.println("不合格です");
      } else {
          System.out.println("合格です");
      }
     }
    }
    -----

    結果は以下
    パターン1
    -----
    >java PassJudge02
    点数を入力>70
    合格です
     -- Press any key to exit (Input "c" to continue) --
    -----
    パターン2
    -----
    >java PassJudge02
    点数を入力>69
    不合格です
     -- Press any key to exit (Input "c" to continue) --
    -----

    2015年2月10日火曜日

    70以上を入力したら「合格です」と表示するプログラム

    参考
    Javaバイブルシリーズ Java入門 Java 7版 P116 確認問題5.2

    -------
    import java.io.*;
    public class PassJudge01 {
     public static void main(String[] args) throws IOException {
     
      BufferedReader br =
              new BufferedReader(new InputStreamReader(System.in));
     
      System.out.print("点数を入力>");
      int ten = Integer.parseInt(br.readLine());
     
      if (ten >= 70) {
       System.out.println("合格です");
      }
     }
    }
    -------
    コンパイルと実行結果

    パターン1
    ------
    >java PassJudge01
    点数を入力>70
    合格です
     -- Press any key to exit (Input "c" to continue) --
    ------
    パターン2
    ------
    >java PassJudge01
    点数を入力>64
     -- Press any key to exit (Input "c" to continue) --
    ------リーズ Java入門 Java 7

    2015年1月26日月曜日

    掛け算の九九を表示するプログラム

    参考
    javaバイブルシリーズ Java入門
    P109 演習問題4.5より
    以下のような九九表を表示させるプログラムをfor文とwhile文のプログラムで作成しろという問題にチャレンジ
    ***********
    >java Kuku??
     1 2 3 4 5 6 7 8 9
     2 4 6 8 10 12 14 16 18
     3 6 9 12 15 18 21 24 27
     4 8 12 16 20 24 28 32 36
     5 10 15 20 25 30 35 40 45
     6 12 18 24 30 36 42 48 54
     7 14 21 28 35 42 49 56 63
     8 16 24 32 40 48 56 64 72
     9 18 27 36 45 54 63 72 81
    ***********
    P102 確認問題4.2より
    こんなプログラムがあった。
    ------
    public class Trace3 {
     public static void main(String[] args) {

      for (int i = 1; i < 4; i++) {
       for (int j = 1; j <= i; j++) {
        System.out.print(" " + (i * j));
       }
       System.out.println();
      }
     }
    }
    ------
    実行結果は以下

    ******
    >java Trace3
     1
     2 4
     3 6 9
    ******
    Trace3.javaを編集すれば、九九表がとけそうだ。
    そして編集して何度かトライアンドエラーを実施してfor文のパターンは完成
    ------
    public class Kuku2 {
     public static void main(String[] args) {

      for (int i = 1; i < 10; i++) {
       for (int j = 1; j < 10; j++) {
        System.out.print(" " + (i * j));
       }
       System.out.println();
      }
     }
    }
    ------
    実行結果
    ******
    >java Kuku2
     1 2 3 4 5 6 7 8 9
     2 4 6 8 10 12 14 16 18
     3 6 9 12 15 18 21 24 27
     4 8 12 16 20 24 28 32 36
     5 10 15 20 25 30 35 40 45
     6 12 18 24 30 36 42 48 54
     7 14 21 28 35 42 49 56 63
     8 16 24 32 40 48 56 64 72
     9 18 27 36 45 54 63 72 81
    ******
    続いてwhile文で作成
    P88よりfor文とwhile文の相違点をチェック

    whileの場合
    ---------------------
            i = 1;                      // ④ iを1に初期化
            while (i <= 10) {           // ⑤ iが10以下のとき繰り返す
                sum += i;               // ⑥ 累計エリアにiを加算
                i++;                    // ⑦ iをカウントアップ
            }
    ---------------------
    forの場合
    ---------------------
            for (i = 1; i <= 10; i++) { // ④、⑤、⑦
                sum += i;               // ⑥ 累計エリアにiを加算
            }
    ---------------------

    何度かトライアンドエラーを繰り返し、while文のパターンも完成。
    ポイントは上記④のように初期化の宣言を追記したこと。ついきしないとコンパイルでエラー。

    ------
    public class Kuku1 {
     public static void main(String[] args) {
      int i;
      int j;
     
      i = 1;
      while (i < 10) {
                            j = 0;                       
       while (j < 9) {
                                    j++;
        System.out.print(" " + (i * j));
       }
                            i++;
       System.out.println();
      }
     }
    }
    ------
    実行結果

    ******
    >java Kuku1
     1 2 3 4 5 6 7 8 9
     2 4 6 8 10 12 14 16 18
     3 6 9 12 15 18 21 24 27
     4 8 12 16 20 24 28 32 36
     5 10 15 20 25 30 35 40 45
     6 12 18 24 30 36 42 48 54
     7 14 21 28 35 42 49 56 63
     8 16 24 32 40 48 56 64 72
     9 18 27 36 45 54 63 72 81
    ******