ติดตั้ง Disk Serve Manager

จาก NakhonNet
ข้ามไปยัง: นำทาง, ค้นหา

โปรแกรม Disk Serve Manager ใช้ควบคุมการทำงานของระบบ Diskless โดยจะควบคุม ietd, dhcpd และการจัดการไฟล์ CoW

เตรียมไดเรกทอรี

การติดตั้งโปรแกรมจะทำในไดเรกทอรี /www/diskserv/app ซึ่งเมื่อติดตั้ง CakePHP จะมีไดเรกทอรีนี้ และมีไฟล์อยู่แล้ว จึงต้องเปลี่ยนชื่อไดเรกทอรีนี้ก่อน ดังนี้

cd /www/diskserv
mv app original_app

นอกจากนี้ จะต้องสร้างไดเรกทอรีเพิ่มเติมสำหรับการใช้งานหลายเซิร์ฟเวอร์ ดังนี้

cd /image
mkdir merge_export merge_import
chown apache:apache merge_export merge_import

ดาวน์โหลด

การดาวน์โหลดโปรแกรมรุ่นล่าสุด สามารถทำได้ 2 วิธี คือ 1) ดาวน์โหลดไฟล์ และ 2) ใช้ git เพื่อดึงโปรแกรมรุ่นล่าสุด

ในที่นี้แนะนำให้ใช้ git เพราะจะทำให้สามารถอัปเกรดโปรแกรมได้ง่าย แต่หากมีเหตุจำเป็นทำให้ไม่สามารถใช้ git ได้ ก็สามารถใช้วิธีดาวน์โหลดไฟลืได้เช่นกัน

ดาวน์โหลดไฟล์

การดาวน์โหลดไฟล์มีขั้นตอนดังนี้

  • เปิดเว็บ https://github.com/atsawin/diskserve/downloads
  • คลิกปุ่ม Download as tar.gz
  • จะได้ไฟล์ atsawin-diskserve-0123456.tar.gz
  • แตกไฟล์นี้ลงในไดเรกทอรี /www/diskserv ดังนี้
cd /www/diskserv
tar zxf <atsawin-diskserve-0123456.tar.gz>

โดยที่ <atsawin-diskserve-0123456.tar.gz> คือไฟล์ที่ดาวน์โหลดมา

จะได้ไดเรกทอรีที่มีชื่อด้านท้ายเป็นเลขสุ่มเช่นเดียวกับชื่อไฟล์ ให้เปลี่ยนชื่อไดเรกทอรีดังกล่าวเป็น app ดังนี้

mv <atsawin-diskserve-0123456> app

โดยที่ <atsawin-diskserve-0123456> คือไดเรกทอรีที่ได้จากการแตกไฟล์

ใช้ git

การดาวน์โหลดโดยใช้ git มีขั้นตอนดังนี้

cd /www/diskserv
git clone git://github.com/atsawin/diskserve.git app

จะได้ไดเรกทอรี app ที่มีโปรแกรมเรียบร้อย

ในอนาคตจะสามารถอัปเกรดโปรแกรมเป็นรุ่นล่าสุดได้โดยใช้คำสั่งดังนี้

cd /www/diskserv/app
git pull

ติดตั้ง

เมื่อดาวน์โหลดโปรแกรมมาเรียบร้อยแล้ว จะต้องสร้างได้เรกทอรีชั่วคราว และเปลี่ยนเจ้าของให้เป็นของเว็บเซิร์ฟเวอร์ เพื่อที่จะให้โปรแกรมสามารถเขียนไฟล์ได้ ดังนี้

cd /www/diskserv/app
cp -a ../original_app/tmp .
mkdir script/config
chown -R apache:apache tmp script/config

Database

สร้าง database ใน MySQL ซึ่งแนะนำให้ใช้ชื่อว่า diskless และใช้ user ชื่อ diskless เช่นกัน ส่วน password ให้ตั้งตามต้องการ ดังนี้

root@diskserv:~# mysql -p
Enter password: mypassbyte
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 209
Server version: 5.1.56-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database diskless default character set utf8;
Query OK, 1 row affected (0.20 sec)

mysql> grant all on diskless.* to diskless@localhost identified by 'new_password';
Query OK, 0 rows affected (0.11 sec)

mysql> exit
Bye
root@diskserv:~#

โดยที่

  • mypassbyte คือรหัสผ่านของ root ของ MySQL ซึ่งได้กำหนดในขั้นตอนการติดตั้ง MySQL
  • new_password คือ password ที่ต้องการ (จะต้องไปกำหนดค่า password ในโปรแกรม Disk Serve manager ให้ตรงกันด้วย)

คำเตือน อย่าใช้ password เป็น new_password ให้ใช้คำอื่น

จากนั้นสร้างตารางในฐานข้อมูล โดยใช้คำสั่งสร้างตารางจาก /www/diskserv/app/Config/Schema/schema.sql ดังนี้

root@diskserv:~# mysql -u diskless -p diskless < /www/diskserv/app/Config/Schema/schema.sql
Enter password: new_password
root@diskserv:~#

โดยที่

  • new_password คือ password ที่กำหนดในขั้นตอนการสร้างตารางข้างต้น

Config Files

แก้ไขไฟล์กำหนดค่า เพื่อให้ตรงกับการใช้งาน

core.php

แก้ config ในส่วนของระบบรักษาความปลอดภัย โดยเปลี่ยนค่าสุ่ม เพื่อให้การทำงานมีความปลอดภัยมากขึ้น โดยแก้ในไฟล์ /www/diskserv/app/Config/core.php บริเวณบรรทัดที่ 187 และ 192 ดังนี้

/**
 * A random string used in security hashing methods.
 */
        Configure::write('Security.salt', 'mY3G64b0jyJFyI7sp2uQopZGWw73p0246FgzC4M9');

/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
        Configure::write('Security.cipherSeed', '16893747697265602896364610243');

โดยแก้ค่า Security.salt เป็นข้อความปนตัวเลขอะไรก็ได้ให้ไม่เหมือนเดิม และแก้ค่า Security.cipherSeed เป็นค่าตัวเลขอะไรก็ได้ให้ไม่เหมือนเดิม

ค่าเหล่านี้เมื่อใช้งานไปแล้วจะเปลี่ยนไม่ได้ นอกจากจะล้างข้อมูลเกี่ยวกับระบบรักษาความปลอดภัยใหม่

database.php

แก้ config ในส่วนของ database ของโปรแกรมให้ตรงกับของ MySQL โดยแก้ไขไฟล์ /www/diskserv/app/Config/database.php ด้านล่างของไฟล์ ดังนี้

class DATABASE_CONFIG {

	public $default = array(
		'datasource' => 'Database/Mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'diskless',
		'password' => 'new_password',
		'database' => 'diskless',
		'prefix' => ,
		'encoding' => 'utf8',
	);

	public $test = array(
		'datasource' => 'Database/Mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'user',
		'password' => 'password',
		'database' => 'test_database_name',
		'prefix' => ,
		'encoding' => 'utf8',
	);
}

โดยที่

  • new_password คือ password ที่กำหนดในขั้นตอนการสร้างตารางข้างต้น

เมื่อแก้ไขไฟล์กำหนดต่าต่างๆ เรียบร้อยแล้ว ให้ลองเปิดบราวเซอร์ที่เครื่องลูกไปที่ http://diskserv.localnet/ ก็จะได้หน้าจอล็อกอินเพื่อเข้าโปรแกรม

sudoers

เนื่องจากโปรแกรมจะต้องแก้ไขไฟล์ config ของเซอร์วิสต่างๆ (เช่น ietd, dhcpd เป็นต้น) ในบางส่วนโปรแกรมจึงต้องทำงานด้วยสิทธิ์ของ root ซึ่งจะต้องมีการอนุญาตให้ใช้สิทธิ์ได้ โดยกำหนดที่ไฟล์ /etc/sudoers บริเวณท้ายไฟล์ ดังนี้

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

apache ALL = NOPASSWD: /www/diskserv/app/script/*

## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d

บรรทัดสีน้ำเงินคือที่จะต้องเพิ่มเข้าไป

กำหนดค่า

ในการกำหนดค่าเบื้องต้น ให้เรียกคำสั่ง SQL ต่อไปนี้

INSERT INTO `settings` (`id`, `name`, `value`, `description`, `created`, `modified`) VALUES
(1, 'script_path', '/www/diskserv/app/script', 'Directory for script files.', now(), now()),
(2, 'image_path', '/space/diskless/image', 'Directory for image files.', now(), now()),
(3, 'cow_path', '/space/diskless/cow', 'Directory for cow files.', now(), now()),
(4, 'server_ip_address', '192.168.2.254', 'ISCSI address of server', now(), now()),
(5, 'server_iscsi_name', 'iqn.2012-01.localnet.diskserv', 'ISCSI name of server', now(), now()),
(6, 'image_backup_path', '/space/backup/diskless', 'Directory for backup image and merged cow files.', now(), now());

กรณีใช้ command line มีขั้นตอนดังนี้

root@diskserv:~# mysql -u diskless -p diskless
Enter password: new_password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.1.56-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> INSERT INTO `settings` (`id`, `name`, `value`, `description`, `created`, `modified`) VALUES
(1, 'script_path', '/www/diskserv/app/script', 'Directory for script files.', now(), now()),
(2, 'image_path', '/space/diskless/image', 'Directory for image files.', now(), now()),
(3, 'cow_path', '/space/diskless/cow', 'Directory for cow files.', now(), now()),
(4, 'server_ip_address', '192.168.2.254', 'ISCSI address of server', now(), now()),
(5, 'server_iscsi_name', 'iqn.2012-01.localnet.diskserv', 'ISCSI name of server', now(), now()),
(6, 'image_backup_path', '/space/backup/diskless', 'Directory for backup image and merged cow files.', now(), now());
Query OK, 5 row affected (0.15 sec)

mysql> exit
Bye
root@diskserv:~#

จากนั้นให้ทดลองใช้งานโดยเปิดบราวเซอร์ไปที่ http://diskserv.localnet/ จะได้หน้าจอ Login ของโปรแกรม Disk Serve Manager

สร้างผู้ใช้งาน

ในฐานข้อมูลจะยังไม่มีข้อมูลผู้ใช้งาน จึงต้องสร้างขึ้นโดยมีขั้นตอนดังนี้

  • ล็อกอินโดย username และ password ที่ต้องการ
  • สังเกต SQL ใน log ด้านล่าง จะแสดง password ที่เข้ารหัสเอาไว้ โดยจะเป็นเลขฐาน 16 ความยาว 40 หลักดังรูป
111754.png
  • สร้าง user ในตาราง users โดยใช้ username และ password จากขั้นตอนที่แล้ว (โดยการใช้ phpMyAdmin หรือโปรแกรม MySQL Client อื่น)

กรณีใช้ command line มีขั้นตอนดังนี้

root@diskserv:~# mysql -u diskless -p diskless
Enter password: new_password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.1.56-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> insert into users (username, password) values ('admin', '553b9d94088b073380223dbc1a73b6d255cd147c');
Query OK, 1 row affected (0.15 sec)

mysql> exit
Bye
root@diskserv:~#

โดยที่ข้อความสีแดง คือ password ที่เข้ารหัสเอาไว้แล้ว ให้คัดลอกมาจาก SQL ใน log ด้านล่างของหน้าเว็บตามขั้นตอนก่อนหน้า

คำเตือน password ที่เข้ารหัสแล้วของแต่ละเครื่องจะไม่เหมือนกัน อย่าใช้รหัสจากตัวอย่างในเอกสารนี้ ให้ใช้รหัสจากหน้าจอเว็บจริง

  • เมื่อสร้าง user แล้ว ให้ login ใหม่อีกครั้ง ก็จะเข้าไปยังหน้าจอหลักของโปรแกรมได้

ปิดการแสดง Debug

ในการใช้งานปกติ ควรปิดการแสดง Debug คำสั่ง SQL เพื่อความปลอดภัยของระบบ และเพื่อให้หน้าจอไม่รก

การปิดการแสดง Debug สามารถทำได้โดยแก้ไขไฟล์ /www/diskserv/app/Config/core.php โดยแก้บรรทัดที่ 35 ดังนี้

เดิม

Configure::write('debug', 2);

แก้เป็น

Configure::write('debug', 0);

View/Edit Diskless Server
ภาพรวม หลักการทำงาน - Hardware - Software
ติดตั้ง Server ติดตั้ง Slackware64 13.37 บูต - แบ่งพาร์ทิชั่น - เตรียมฮาร์ดดิสก์ - ติดตั้งแพ็กเกจ - ติดตั้ง Lilo - กำหนดค่าเน็ตเวิร์ก - กำหนดรหัสผ่าน - Slackware64 14.0
ปรับแต่ง Slackware Linux การใช้งานเบื้องต้น - คอมไพล์ Kernel - สร้างไดเรกทอรี - ปรับแต่ง Filesystem - ปรับแต่งแพ็กเกจ - เพิ่มการเรียก dhcpd
ปรับแต่ง Network กำหนดชื่อ Device - ทำ Network Bonding - กำหนดค่า Network
RAID สร้างพาร์ทิชั่น - สร้าง RAID - ไม่ใช้ RAID
กำหนดค่า Service NTPD - NAMED - TFTPD
โปรแกรม iSCSI Enterprise Target - iPXE
โปรแกรมจัดการระบบ Apache - MySQL - PhpMyAdmin - CakePHP - Disk Serve Manager (อัปเกรด)
ติดตั้ง Client ติดตั้ง Windows XP - ติดตั้ง iSCSI - ปรับแต่ง Windows XP - คัดลอกดิสก์ไปยังเซิร์ฟเวอร์ - Windows 7 64-bit
การใช้งาน ภาพรวม นิยาม - ไฟล์ Config และ Script
การกำหนดค่า Config - Cluster - Alternative - Computer - ตัวอย่าง
การใช้งาน หน้าจอหลัก - Mode การใช้งาน - ปรับปรุง Image - สำรอง Image - ขยายขนาด Image - ใช้หลาย Server
โปรแกรมเสริม ปรับแต่งเครื่องลูกขณะบูต - ฟอร์แมตไดรฟ์เสริม
การแก้ไขปัญหา FAQ - ไฟล์กำหนดค่า - ไฟล์บันทึกการทำงาน - Secure Erase