ඔනම service එකක් ආරම්භ කරන්න කලින් තියෙන්න ඔන අත්යවශ්යම දේ තමයි static ip එකක්. (මතකනෙ windows server වලදි.) මොකද ඒකෙන්නෙ clients ල service එකට request කරන්නෙ. මෙන්න මෙහෙමයි static ip එකක් දාගන්නෙ
vi /etc/sysconfig/network --> GATEWAY=x.x.x.x
vi /etc/resolv.conf--->DNS1=8.8.8.8
දැන් configure කරගත්ත network interface info ටික දාල network service එක restart කරගනිමු. විවිධ services සදහා start stop scripts තියෙන්නෙ etc/init.d/ කියන directory 1 ඇතුලෙ. ඉතින් අපි network service එක restart කරන්න යන්න ඔනත් ඒක තුලටම තමයි.
ඊට පස්සෙ ifconfig ගහල network interface එකේ වෙනස් කරගත්ත විස්තර බලන්න පුලුවන්.
SWAP
dd if=/dev/zero of=/newswap bs=1024 count=128000 -->131MB (118000=121MB)//change count
mkswap /newswap
swapon /newswap
swapon -s //see summry
vi /etc/fstab //permanently add
/newswap swap swap defaults 0 0 //add this line
chown root:root /newswap
chmod 0600 /newswap
chmod 0600 /newswap
############not necessary###########
Swapiness can be a value from 0 to 100. Swappiness near 100 means that the operating system will swap often and usually, too soon. Although swap provides extra resources, RAM is much faster than swap space. Any time something is moved from RAM to swap, it slows down.
A swappiness value of 0 means that the operating will only rely on swap when it absolutely needs to.
cat /proc/sys/vm/swappiness
//60
sysctl vm.swappiness=10
vm.swappiness=10
cat /proc/sys/vm/swappiness
//10
sudo nano /etc/sysctl.conf //permenentl
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
vm.swappiness=10
New Disk
reboot
fdisk -l
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
fdisk /dev/sdb
m,n,p
1,1,enter, w
In this example we only plan to create one partition which will be partition 1. Next we need to specify where the partition will begin and end. Since this is the first partition we need it to start at cylinder 1 and since we want to use the entire disk we specify the last cylinder as the end. Note that if you wish to create multiple partitions you can specify the size of each partition by cylinders, bytes, kilobytes or megabytes.
(if second disk--------> 2,1,enter, w)
fdisk -l /dev/sdb ->will show sdb1
mkfs -t ext4 /dev/sdb1
mkdir /mnt/block_storage
mount -t ext3 /dev/sdb1 /mnt/block_storage/
df -h
vi /etc/fstab
/dev/sdb1 /mnt/block_storage/ ext4 defaults 0 0
---------------------------------------
LVM
1.) Primary Disk 20 Gb (dev/sda).
2.) Secondary Disk 10 GB (dev/sdb) [Will be used for LVM].
3.) Third Disk 6GB (dev/sdc) [Will be used for LVM].
sudo fdisk -l -> shows above as sda,sdb,sdc
---------------------------------------------------------
STEP1.) Partitioning the 10 Gb drive
sudo fdisk /dev/sdb
n,p,1,enter,enter
You can check the partition information by pressing the p
partition type is LINUX , so we need to make it type LVM.
Now press t
L
8e
w
sudo partprobe /dev/sdb
_________________________________
above step 1 is only for partition,
we can create multiple partition with same /dev/sdb ( dev/sdb1, dev/sdb2..... etc)
if we dont want lvm we can use them as disks, (mkfs.ext4 /dev/sdb1, then mount that )
if we wish to lvm look below,
(Note : dont do above step 1, if dont want multiple physical partitions with same disk [/dev/sdb] , just do pvcreate before that (pvcreate /dev/sdb) )--->entire disk will be one partition. then we can slice that using lvm as follows-Starting with step2 ---------------------------------------------------------
STEP1.1)So lets start again with the new drive :-
sudo fdisk /dev/sdc
Type n for new partition.
Now type p for making it a primary partition.
Now press enter as we are starting from a raw disk
Now on the finishing cylinder type +4G as we need the size 4GB.
Press t and type 8e (LINUX LVM partition code)
Press w to write changes. You can also issue the command
sudo partprobe /dev/sdc
--------------------------------------------------------
STEP2.) Create the Physical Volumes
sudo pvcreate /dev/sdb1 /dev/sdc1
Now Create the Volume Group the name of the volume group is routemybrain
sudo vgcreate routemybrain /dev/sdb1 /dev/sdc1
#You can verify the LOGICAL GROUP using the command vgdisplay
--------------------------------------------------------
STEP3.) Creating the Logical volume
sudo lvcreate routemybrain -L +14G -n akash
routemybrain -> The name of the volume group
-L -> To specify the size of the partition in our case 14GB
-n -> To specify the name of the Logical volume in our case akash.
---------------------------------------------------------
final step just to mount it.
STEP4.) Make a directory for mounting the share
sudo mkdir /home/newtrojan/Lvm-Mount
now format the LVM partition.
sudo mkfs.ext3 /dev/routemybrain/akash
Now mount the partition
sudo mount /dev/routemybrain/akash /home/newtrojan/Lvm_Mount
vi /etc/fstab/dev/routemybrain/akash /home/newtrojan/Lvm_Mount ext4 defaults 0 0
other way to mount,
blkid->find UUID,
vi /etc/fstab/ UUID="2a65e182-5e0e-4190-9e92-fe11c2499dbe" /mount1/ ext4 defaults 0 0
SUMMARY================
summary
lsblk | vgdisplay | lvdisplay |
-------
new-->pvcreate[pvcreate /dev/sdb], vgcreate [vgcreate postg /dev/sdb | vgcreate postg /dev/sdb /dev/sde] (if no vg created, create with crteated pv), lvcreate [ lvcreate postg -L+2G -n log1] (with existing/created vg), mkfs.ext4 [mkfs.ext4 /dev/postg/log1], mount [mount /dev/postg/log1 /mount1/].
.
larging-->pvcrate, vgextend (existing one) [vgextend postgres /dev/sdc1 ],
lvextend(lvextend -l +the no for full orrrrr (lvextend -L+5G ) ,resize2fs /dev/postgres/log1 (or we can extend root's vg,lv and resize2fs )
========================------------------------------------------------------------------------------
add new disk(4th disk) to volgroup and resize (not tested)
------------------------------------------------------------------------------
fdisk /dev/sdd ->n,p, ...t,8e. w
vgextend routemybrain /dev/sdd1
vgs
lvextend /dev/routemybrain/akash -L +1G //or all space of vgroup -> -L 100%VG
#resize2fs /dev/vg1-hasa/lv1-hasa
e2fsck -f /dev/routemybrain/akash
resize2fs /dev/routemybrain/akash
mount /dev/vg1-hasa/lv1-hasa /mnt/raid1-hasa1/
df -h
------------------------------------------------------------------------------
#########################################
extending live root (not tested)
#########################################
365 df -h
366 df -h|grep root
367 pvdisplay
368 lsblk
369 pvcreate /dev/sdb ##new added disk
371 vgextend vg_lb1 /dev/sdb
375 lvextend -L+4G /dev/mapper/vg_lb1-lv_root #df -h|grep root output == df -h|grep root
378 resize2fs /dev/mapper/vg_lb1-lv_root
379 df -h
------------------------------------------------------------------------------
සාමාන්යෙන් list down කරගන්න ක්රම තමයි ls ll -ltrh වගේ commands.
pen drive, CD Rom වගේ external drives mount කරගන්නෙ මෙහෙමයි.
drive එකක් physically සම්බන්ධ කලාම ඒක තියෙන්නෙ /dev/ යටතේ. ඉතින් ඒක අපි මවුන්ට් කරග්නීමක් සිදුකරගන්නව අපි කැමති directory එකකට.
දැක්ක නේද ඒක හරියට mount වෙලා.
linux repos එහෙම නැත්නම් package ගබඩාව කියන අදහස දෙන මේකෙන් අපි linux වලදි yum install <package name> ubuntu වලදි apt-get කියල දුන්නම මෙන්න මේ හරහා තමයි package handle වෙන්නෙ. default එන ropo එක තමයි /etc/yum.repos.d/ වල rhel-source.repo කියල තියෙන්නෙ. ඉතින් ඇත්තටම ඔක ඇතුලෙ තියෙන්නෙ package download/update වෙන urls.
http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 7 64-Bit ##
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
# rpm -ivh epel-release-7-6.noarch.rpm
sudo yum install epel-release (after installing we can use this repo also )
(url එකක් පටන් ගන්නෙ // කියලනෙ, එතනින් එහාට තීන්නෙ පාත් එක. ඒකයි / 3ක් ආවෙ. gpgcheck කියන්නෙ download වෙන package වල signature එක check කරන්නද යන්න සදහන් කිරීම. ඒක 0 දුන්නොත් එහෙම check කරන්නෙ නැ)
yum repolist ගහල බලන්න අපේ repo එක වැඩද කියල. ඒක ධන අගයක් නම් වැඩේ හරි.
එක එක දාන්නෙ නැතුව යම් server එකකට උවමනා package සියල්ල එකවිට දාගන්න පුලුවන් නම් කොයි තරම් පහසුද. ඔව් ඒක කරන්නෙ මෙහෙම, ඉස්සෙල්ල අදාල group එක yum grouplist එකෙන් තෝරල, yum groupinstall "<group name>" කියල දෙන්නයි තියෙන්නෙ.
හොදට මතක තියාගන්න, අපි භාවිතා කරන 2,3,4,5 කියන run level වලදි මේක on කරන්න. (chkconfig httpd on) මොකද ඊලග වතාවෙදි මේ levels වලින් ඇතුලු වෙනකොට මේක on කරල නොතිබුනොත් service එක start වෙලා නොතිබේවි.
දැන් web browser එකට ගිහින් අපේ server එකේ host name (server.example.com) එක දුන්නට වැඩ කරන්නෙ නැ. ඒ මොකද මේ host name එක මේ static ip(192.168.0.119) එකට map වෙලා නැ. ඒක හදන්නෙ මෙතනින්.
ඒක extract කරගන්නෙ මෙහෙමයි.
ll හා -ltrh ls වල වෙනස තමයි. ls වල ලිස්ට් වෙන්නෙ නම විතරයි. නමුත් ll වලින් owner user, owner group, file permission වගේ විස්තර පෙන්වනව. ඒකත් හිතේ තියාගෙන මේක බලමු, මේ කරන්න යන්නෙ root user ගෙන් file එකක් හදල ඒක othersලට writable permission එක දෙන එක.
shortcuts හදන්නෙ මෙහෙම. hear link එක remove කලොත් original එකටත් බලපාන නිසා ඒකත් remove වෙනව.
soft link
ln -s /full/path/of/original/file /full/path/of/soft/link/file
heard link
ln /full/path/of/original/file /full/path/of/hard/link/file
තවත් අමතර දෙයක් කියන්න ඔන. cp(copy file) එකෙයි mv(move file) එකෙයි වෙනස තමයි copy කරනකොට copy වෙන්නෙ permission මාරු වෙලාමයි. ඒත move කරනකොට permission copy වෙන්නෙ නැ. ඒක හදන්න වෙනව වෙනම.
path එක දෙනකොට එකෙන් කියන්නෙ දෑන් ඉන්න directory එක.
cd .. වරක් පසුපසට, cd ../.. දෙවරක් පසුපසට.
firewall
Method 1
vi /etc/sysconfig/iptables
## allow everyone to access port 80 and 443 (IPv4 Only)##
තවත් අමතර දෙයක් කියන්න ඔන. cp(copy file) එකෙයි mv(move file) එකෙයි වෙනස තමයි copy කරනකොට copy වෙන්නෙ permission මාරු වෙලාමයි. ඒත move කරනකොට permission copy වෙන්නෙ නැ. ඒක හදන්න වෙනව වෙනම.
path එක දෙනකොට එකෙන් කියන්නෙ දෑන් ඉන්න directory එක.
cd .. වරක් පසුපසට, cd ../.. දෙවරක් පසුපසට.
firewall
Method 1
vi /etc/sysconfig/iptables
## allow everyone to access port 80 and 443 (IPv4 Only)##
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
Method 2 (GUI)
# system-config-firewall
Method 3(A note about text based config tool (recommend for remote server with ssh access))
# system-config-firewall-tui-------------------------
wget <link.tar.gz>
copy it to any dest ex: /usr/local/tomcat7
tar -xvzf name.tar.gz
goto bin
./bin/startup.sh
conf/tomcat-users.xml
http://www.davidghedini.com/pg/entry/install_jboss_7_on_centos
-------------------------------
yum install postgresql
yum install postgresql-server
service postgresql initdb
/etc/init.d/postgresql start
sudo -i -u postgres
createuser
createdb mydb
psql
\l
\c mydb
create table t1(id int);
\d t1
\q
exit
--------------
mysql 3306 tcp
postgresql 5432
------------------------------------------------------------------
HTTPD Install
yum -y install httpd
mkdir -p /var/www/example.com/public_html vim
/var/www/example.com/public_html/index.html
<html> <head> <title>Welcome to Example.com!</title> </head> <body> <h1>Success! The example.com virtual host is working!</h1> </body> </html>
vim /etc/httpd/conf/httpd.conf
1)listen port 80
2)<VirtualHost *:80> ServerName www.example.com ServerAlias example.com DocumentRoot /var/www/example.com/public_html ErrorLog /var/www/example.com/error.log CustomLog /var/www/example.com/requests.log combined </VirtualHost> 3)server address example.com
vim /etc/hosts
(
192.168.1.10 example.com
service httpd restartapachectl restart)
++++++++++++++++++++++ Mount google drive into ubuntu
sudo add-apt-repository ppa:alessandro-strada/ppa sudo apt-get update sudo apt-get install google-drive-ocamlfuse
google-drive-ocamlfuse --->allow
mkdir /home/hasaranga/my_folder
google-drive-ocamlfuse /home/hasaranga/my_folder
===========================
classroom
host example.com (
install apache, copy example.com/content/* files to /var/www/html/
qemu-img convert -O vdi rh124-desktop-vda.qcow2 vda.vdi (qemu-utils should be installed)
server and desktop convert as above. (give chown user.user to running user)
then virtual box ->new->name, rhel7 64-> and ram is 512-> use an existing hdisk->set converted one
network type is briged
vms:
change hostname (desktop1 | server1) -
hostnamectl set command
change /etc/hosts both server names should point your clasroom ip which install apache (above one)
change ip and details DEVICE=enp0s3 #BOOTPROTO=dhcp PREFIX=24 IPADDR=192.168.8.108 GATEWAY=192.168.8.1 ONBOOT=yes TYPE=Ethernet USERCTL=yes PEERDNS=yes IPV6INIT=no #PERSISTENT_DHCLIENT=1 vim /etc/rht RHT_COURSE=rh124
verify cmd : lab
No comments:
Post a Comment