1.yum update -y
2.rpm -ivH http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
3.yum install -y make wget httpd mysql mysql-server php php-gd php-mysql php-mbstring mod_perl perl-XML-Simple perl-Net-IP perl-SOAP-Lite perl-DBI perl-DBD-MySQL
4.yum install -y --enablerepo=epel perl-Apache-DBI perl-Apache2-SOAP perl-XML-Entities
5.mysql_install_db
6.chkconfig --level 345 mysqld on
7.service mysqld start
8.mysql_secure_installation
9.mysql -u root -p
10.CREATE DATABASE ocs;
11.GRANT ALL PRIVILEGES ON ocs.* to ocs@localhost IDENTIFIED BY '<somepassword>';
12.FLUSH PRIVILEGES;
13.QUIT
14.cd /root/
15.wget https://launchpadlibrarian.net/165057074/OCSNG_UNIX_SERVER-2.1.tar.gz
16.tar -xvzf OCSNG_UNIX_SERVER*.tar.gz
17.cd OCSNG_UNIX_SERVER*
18.sh ./setup.sh
19.vi /etc/httpd/conf.d/z-ocsinventory-server.conf
Change line 26 (OCS_DB_NAME) from 'ocsweb' to 'ocs'
Change line 27 (OCS_DB_LOCAL) from 'ocsweb' to 'ocs'
Change line 31 (OCS_DB_PWD) from 'ocs' to whatever you chose for your MySQL 'ocs' user password
20.vi /etc/sysconfig/iptables
21.-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
22.service iptables restart
23.chkconfig --level 345 httpd on
24.service httpd start
25.vi /etc/selinux/config
SELINUX=disabled
26.reboot
27.http://yourserver/ocsreports
Database: ocs
Username: ocs
Password: <somepassword>
Hostname: localhost
28.rm -f /usr/share/ocsinventory-reports/ocsreports/install.php
29. http://yourserver/ocsreports
Username: admin
Password: admin
วันอาทิตย์ที่ 13 เมษายน พ.ศ. 2557
วันจันทร์ที่ 23 ธันวาคม พ.ศ. 2556
วันพฤหัสบดีที่ 19 ธันวาคม พ.ศ. 2556
iSCSI Client and LVM Extend Size + Add disk on network ; Local
ADD Disk ON Network
------------------ iSCSI Client Install and Config ------------------
yum install iscsi-initiator-utils
vi /etc/iscsi/iscsid.conf
################
# iSNS settings
################
# Address of iSNS server
isns.address = 192.168.1.100
isns.port = 3260
# *************
# CHAP Settings
# *************
# To enable CHAP authentication set node.session.auth.authmethod
# to CHAP. The default is None.
node.session.auth.authmethod = CHAP
# To set a CHAP username and password for initiator
# authentication by the target(s), uncomment the following lines:
node.session.auth.username = userchapexample
node.session.auth.password = passchapexample
# To enable CHAP authentication for a discovery session to the target
# set discovery.sendtargets.auth.authmethod to CHAP. The default is None.
discovery.sendtargets.auth.authmethod = CHAP
# To set a discovery session CHAP username and password for the initiator
# authentication by the target(s), uncomment the following lines:
discovery.sendtargets.auth.username = userchapexample
discovery.sendtargets.auth.password = passchapexample
/etc/init.d/iscsi start
iscsiadm -m discovery -t sendtargets -p 192.168.1.100
/etc/init.d/iscsi restart
------------------ iSCSI Client Install and Config ------------------
------------------ Config New HardDisk------------------
fdisk /dev/sdb
p --print ตรวจสอบ partition
n --create partition (primary 4)
p --create partition primary
1 --partition first
enter
+100G --partition 1 กำหนดขนาดไซด์ให้เป็น 100 GB
t --เพื่อทำการเปลี่ยน type ของ partition
L --ทำการตรวจสอบ type ของ partition ทั้งหมดว่ามีอะไรบ้าง
8e --ทำการเปลี่ยน type เป็น LVM
w --บันทึกค่าทั้งหมดที่ทำการ set partition มา
------------------ Config New HardDisk------------------
------------------ Config PV ------------------
pvcreate /dev/sdb1
pvs
------------------ Config PV ------------------
------------------ Config VG ------------------
vgextend vg_cloud /dev/sdb1 ** จะเป็นการเพิ่ม physical เข้าไปยัง volumgroup
vgs
------------------ Config VG ------------------
------------------ Config LV ------------------
lvextend -L 277G /dev/vg_cloud/LogVol05
resize2fs -p /dev/vg_cloud/LogVol05
df -h
------------------ Config LV ------------------
ADD Disk ON Local
เพิ่ม hdd บน vm esx ของ guest ที่ต้องการ **เพิ่ม disk ใหม่อีก 100 gb
restart guest 1 ครั้ง
------------------ Config New HardDisk------------------
fdisk /dev/sdc
p --print ตรวจสอบ partition
n --create partition (primary 4)
p --create partition primary
1 --partition first
enter
+100G --partition 1 กำหนดขนาดไซด์ให้เป็น 100 GB
t --เพื่อทำการเปลี่ยน type ของ partition
L --ทำการตรวจสอบ type ของ partition ทั้งหมดว่ามีอะไรบ้าง
8e --ทำการเปลี่ยน type เป็น LVM
w --บันทึกค่าทั้งหมดที่ทำการ set partition มา
------------------ Config New HardDisk------------------
------------------ Config PV ------------------
pvcreate /dev/sdb1
pvs
------------------ Config PV ------------------
------------------ Config VG ------------------
vgextend vg_cloud /dev/sdb1 ** จะเป็นการเพิ่ม physical เข้าไปยัง volumgroup
vgs
------------------ Config VG ------------------
------------------ Config LV ------------------
lvextend -L 277G /dev/vg_cloud/LogVol05
resize2fs -p /dev/vg_cloud/LogVol05
df -h
------------------ Config LV ------------------
fdisk /dev/sdc
p --print ตรวจสอบ partition
n --create partition (primary 4)
p --create partition primary
1 --partition first
enter
+100G --partition 1 กำหนดขนาดไซด์ให้เป็น 100 GB
t --เพื่อทำการเปลี่ยน type ของ partition
L --ทำการตรวจสอบ type ของ partition ทั้งหมดว่ามีอะไรบ้าง
8e --ทำการเปลี่ยน type เป็น LVM
w --บันทึกค่าทั้งหมดที่ทำการ set partition มา
------------------ Config New HardDisk------------------
------------------ Config PV ------------------
pvcreate /dev/sdb1
pvs
------------------ Config PV ------------------
------------------ Config VG ------------------
vgextend vg_cloud /dev/sdb1 ** จะเป็นการเพิ่ม physical เข้าไปยัง volumgroup
vgs
------------------ Config VG ------------------
------------------ Config LV ------------------
lvextend -L 277G /dev/vg_cloud/LogVol05
resize2fs -p /dev/vg_cloud/LogVol05
df -h
------------------ Config LV ------------------
วันอังคารที่ 17 ธันวาคม พ.ศ. 2556
User On Linux
useradd .... ** ตามด้วยชื่อ user (เพิ่ม user)
useradd user1
userdel .... ** ตามด้วยชื่อ user (ลบ user) ลบแค่ user ไฟล์ข้อมูลของ user ยังอยู่ใน /home
userdel user1
userdel -r ... ** ตามด้วยชื่อ user (ลบ user) ลบทั้ง user และไฟล์ข้อมูลของ user
userdel -r user1
id ... ** ตามด้วยชื่อ user (ดูข้อมูลของ user)
id user1
uid=500(user1) gid=500(user1) groups=500(user1)
vi /etc/login.defs **สามารถแก้ไขการตั้งค่าต่างๆของ user... เช่น อายุการใช้งานของ user
usermod -aG ตามด้วยชื่อgroup ตามด้วยชื่อuser
usermod -aG test1 user1
-a จะเป็นการเพิ่มค่าต่อจากค่าเดิมที่เคยมีอยู่
ถ้าไม่ใส่จะลบ group ก่อนหน้าด้วย
usermod -s /sbin/nologin user1
user1 ไม่สามารถ login เข้าสู่ระบบได้
cat /etc/group
ดู list group ว่ามีอะไรบ้าง
useradd user1
userdel .... ** ตามด้วยชื่อ user (ลบ user) ลบแค่ user ไฟล์ข้อมูลของ user ยังอยู่ใน /home
userdel user1
userdel -r ... ** ตามด้วยชื่อ user (ลบ user) ลบทั้ง user และไฟล์ข้อมูลของ user
userdel -r user1
id ... ** ตามด้วยชื่อ user (ดูข้อมูลของ user)
id user1
uid=500(user1) gid=500(user1) groups=500(user1)
usermod -aG ตามด้วยชื่อgroup ตามด้วยชื่อuser
usermod -aG test1 user1
-a จะเป็นการเพิ่มค่าต่อจากค่าเดิมที่เคยมีอยู่
ถ้าไม่ใส่จะลบ group ก่อนหน้าด้วย
usermod -s /sbin/nologin user1
user1 ไม่สามารถ login เข้าสู่ระบบได้
cat /etc/group
ดู list group ว่ามีอะไรบ้าง
Access Control Lists
Access Control Lists เป็นการ Set เพื่อให้ Folder หรือ File นั้นมีสิทธิ์มากกว่า 1 สิทธิ์ในการใช้งาน
เนื่องจาก การ
chgrp
chown
กำหนดได้แค่ 1 user หรือ 1 group เท่านั้นในการจัดการไฟล์
แต่ถ้า Folder หรือ File ที่ต้องมีสิทธิ์ใช้งานมากกว่า 1 จะไม่สามารถจัดการได้
ดังนั้นจึงต้องมีการนำ Access Control Lists เข้ามาช่วย
เช่นถ้า Folder xxx ต้องการให้ group sale,manager,it,account เข้ามาใช้งาน
หรือ ไฟล์ sss ต้องการให้ user a,b,c,d,e เข้ามาใช้งานไฟล์นอกนั้นไม่สามารถใช้งานไฟล์ได้ ก็จะกำหนดไม่ได้จาก chown
เช็ค Package ACL
rpm -q acl
ถ้าไม่มี Package ให้ทำการติดตั้ง
yum install -y acl
โดยหลักๆ ACL จะมีในส่วนของการตั้งค่า และการดูค่า
setfacl -เซตตามเงื่อนไขที่ต้องการ ตามด้วยสิทธิ์หรือuser group other ตามด้วยชื่อไฟล์หรือโฟลเดอร์
getfacl -เงื่อนไขที่่ต้องการ ตามด้วยชื่อไฟล์หรือโฟลเดอร์
Ex.
groupadd test1
groupadd test2
useradd user1
useradd user2
mkdir /opt/folder
mkdir /opt/folder/f1
touch /opt/folder/file
getfacl /opt/folder/
# file: opt/folder/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
getfacl /opt/folder/file
# file: opt/folder/file
# owner: root
# group: root
user::rw-
group::r--
other::r--
setfacl -m g:test1:rw /opt/folder
getfacl /opt/folder/
เนื่องจาก การ
chgrp
chown
กำหนดได้แค่ 1 user หรือ 1 group เท่านั้นในการจัดการไฟล์
แต่ถ้า Folder หรือ File ที่ต้องมีสิทธิ์ใช้งานมากกว่า 1 จะไม่สามารถจัดการได้
ดังนั้นจึงต้องมีการนำ Access Control Lists เข้ามาช่วย
เช่นถ้า Folder xxx ต้องการให้ group sale,manager,it,account เข้ามาใช้งาน
หรือ ไฟล์ sss ต้องการให้ user a,b,c,d,e เข้ามาใช้งานไฟล์นอกนั้นไม่สามารถใช้งานไฟล์ได้ ก็จะกำหนดไม่ได้จาก chown
เช็ค Package ACL
rpm -q acl
ถ้าไม่มี Package ให้ทำการติดตั้ง
yum install -y acl
โดยหลักๆ ACL จะมีในส่วนของการตั้งค่า และการดูค่า
setfacl -เซตตามเงื่อนไขที่ต้องการ ตามด้วยสิทธิ์หรือuser group other ตามด้วยชื่อไฟล์หรือโฟลเดอร์
getfacl -เงื่อนไขที่่ต้องการ ตามด้วยชื่อไฟล์หรือโฟลเดอร์
Ex.
groupadd test1
groupadd test2
useradd user1
useradd user2
mkdir /opt/folder
mkdir /opt/folder/f1
touch /opt/folder/file
getfacl /opt/folder/
# file: opt/folder/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
getfacl /opt/folder/file
# file: opt/folder/file
# owner: root
# group: root
user::rw-
group::r--
other::r--
getfacl /opt/folder/
# file: opt/folder/
# owner: root
# group: root
user::rwx
group::r-x
group:test1:rw- **เพิ่มขึ้นมา
mask::rwx
other::r-x
ดังนั้น โฟลเดอร์
/opt/folder จะมีสิทธิ์ คือ
owner root rwx
group root r-x
group test1 rw-
ได้
setfacl -dm u:user1:rx /opt/folder
getfacl /opt/folder/
# file: /opt/folder/
# owner: root
# group: root
user::rwx
user:user1:r-x **owner
group::r-x **group
mask::r-x
other::r-x **other
default:user::rwx **owner:root
default:user:user1:r-x **owner:user1
default:group::r-x
default:mask::r-x
default:other::r-x
getfacl /opt/folder/
# file: /opt/folder/
# owner: root
# group: root
user::rwx
user:user1:r-x **owner
group::r-x **group
mask::r-x
other::r-x **other
default:user::rwx **owner:root
default:user:user1:r-x **owner:user1
default:group::r-x
default:mask::r-x
default:other::r-x
getfacl /opt/folder/f1 ** เป็นกรณีสร้าง Folder f1 หลังจาก setfacl -dm u:user1:rx /opt/folder ไปแล้ว
# file: /opt/folder/f1
# owner: root
# group: root
user::rwx **owner
group::r-x **group
mask::r-x
other::r-x **other
default:user::rwx **owner:root
default:user:user1:r-x **owner:user1
default:group::r-x
default:mask::r-x
default:other::r-x
# owner: root
# group: root
user::rwx **owner
group::r-x **group
mask::r-x
other::r-x **other
default:user::rwx **owner:root
default:user:user1:r-x **owner:user1
default:group::r-x
default:mask::r-x
default:other::r-x
วันจันทร์ที่ 16 ธันวาคม พ.ศ. 2556
NTP Client
1. yum install -y ntp
2. service ntpd start
3. vi /etc/ntp.conf
4. server 192.168.x.x **เพิ่มค่า
5 .กด esc ตามด้วย wq เพราะเซฟค่าและออกจาก vi
6. service ntpd restart
7. chkconfig ntpd on
8. ntpq -p **เพื่อเช็คดูว่า sync time ให้แล้วหรือยัง
9. ntpdate -u 192.168.x.x **ถ้ายังสามารถ บังคับให้ sync ได้
2. service ntpd start
3. vi /etc/ntp.conf
4. server 192.168.x.x **เพิ่มค่า
5 .กด esc ตามด้วย wq เพราะเซฟค่าและออกจาก vi
6. service ntpd restart
7. chkconfig ntpd on
8. ntpq -p **เพื่อเช็คดูว่า sync time ให้แล้วหรือยัง
9. ntpdate -u 192.168.x.x **ถ้ายังสามารถ บังคับให้ sync ได้
Config Vlan
Config vlan 1 port 1-22
>enable
#configure terminal
(config)#interface range gigabitEthernet 1/0/1-22
(config-if-range)#switchport access vlan 1
(config-if-range)#no shutdown
(config-if-range)#end
#write memory
Config vlan 15
>enable
#configure terminal
(config)#interface gigabitEthernet 1/0/15
(config-if-range)#switchport access vlan 1
(config-if-range)#no shutdown
(config-if-range)#end
#write memory
>enable
#configure terminal
(config)#interface range gigabitEthernet 1/0/1-22
(config-if-range)#switchport access vlan 1
(config-if-range)#no shutdown
(config-if-range)#end
#write memory
Config vlan 15
>enable
#configure terminal
(config)#interface gigabitEthernet 1/0/15
(config-if-range)#switchport access vlan 1
(config-if-range)#no shutdown
(config-if-range)#end
#write memory
สมัครสมาชิก:
บทความ (Atom)













