Posted in Linux Server, Windows Powershell, Windows Server | No Comment | 2,324 views | 12/06/2014 22:44
This is an example for nxService of PowerShell DSC.
You will able to stop a service like postfix on Linux by using PowerShell DSC.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| $cred=Get-Credential -UserName:"root" -Message:"Root User?"
$opt = New-CimSessionOption -UseSsl:$true -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true
$linuxcomp=New-CimSession -Credential:$cred -ComputerName:linuxdsc.cloudapp.net -Port:5986 -Authentication:basic -SessionOption:$opt
Configuration StopService
{
Import-DSCResource -Module nx
Node "linuxdsc.cloudapp.net"{
nxService StopService
{
Name = "postfix"
Controller = "init"
State = "Stopped"
}
}
}
StopService -OutputPath:"C:\temp"
Start-DscConfiguration -CimSession:$linuxcomp -Path:"C:\temp" -Verbose -Wait |
$cred=Get-Credential -UserName:"root" -Message:"Root User?"
$opt = New-CimSessionOption -UseSsl:$true -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true
$linuxcomp=New-CimSession -Credential:$cred -ComputerName:linuxdsc.cloudapp.net -Port:5986 -Authentication:basic -SessionOption:$opt
Configuration StopService
{
Import-DSCResource -Module nx
Node "linuxdsc.cloudapp.net"{
nxService StopService
{
Name = "postfix"
Controller = "init"
State = "Stopped"
}
}
}
StopService -OutputPath:"C:\temp"
Start-DscConfiguration -CimSession:$linuxcomp -Path:"C:\temp" -Verbose -Wait
After you run DSC, postfix service will be stopped on destination Linux Server.
Posted in Linux Server | No Comment | 3,923 views | 01/04/2013 17:15
If you need to extend your logical volume, do following first:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| distro=$(cat /etc/issue | head -n 2 | tr -d "\n" | tr "[:upper:]" "[:lower:]")
device=$(fdisk -l | grep -w 8e | head -n 1 | cut -c-8)
partcount=$(fdisk -l | grep $device | sed 1d | grep -c $device)
newpartnum=$(($partcount+1))
startsector=$(fdisk -l | grep -w 8e | tail -1 | tr " " "\n" | sed "/^$/d" | head -n 3 | tail -1)
newstartsector=$(($startsector+1))
endsector=$(fdisk -l | grep sectors | head -n 1 | tr " " "\n" | tail -2 | head -n 1)
newendsector=$(($endsector-1))
fdisk $device <<EOF
n
p
$newpartnum
$newstartsector
$newendsector
t
$newpartnum
8e
w
EOF |
distro=$(cat /etc/issue | head -n 2 | tr -d "\n" | tr "[:upper:]" "[:lower:]")
device=$(fdisk -l | grep -w 8e | head -n 1 | cut -c-8)
partcount=$(fdisk -l | grep $device | sed 1d | grep -c $device)
newpartnum=$(($partcount+1))
startsector=$(fdisk -l | grep -w 8e | tail -1 | tr " " "\n" | sed "/^$/d" | head -n 3 | tail -1)
newstartsector=$(($startsector+1))
endsector=$(fdisk -l | grep sectors | head -n 1 | tr " " "\n" | tail -2 | head -n 1)
newendsector=$(($endsector-1))
fdisk $device <<EOF
n
p
$newpartnum
$newstartsector
$newendsector
t
$newpartnum
8e
w
EOF
Then reboot your server!
After that, you should do following to extend LVM:
1
2
3
4
5
6
7
8
9
10
11
12
| device=$(fdisk -l | grep -w 8e | head -n 1 | cut -c-8)
partnumber=$(fdisk -l | grep $device | sed 1d | grep -c $device)
pvcreate $device$partnumber
volgroupname=$(vgdisplay | grep -w "VG Name" | cut -b10- | tr -d " ")
vgextend $volgroupname $device$partnumber
volgroupchars=$(echo $volgroupname | wc --chars)
totalchars=$(($volgroupchars+13))
lvmname=$(df -h | grep -w $volgroupname | head -n 1 | cut -b$totalchars-)
set $lvmname
lvmname=$1
lvextend -l +100%FREE /dev/$volgroupname/$lvmname
resize2fs /dev/$volgroupname/$lvmname |
device=$(fdisk -l | grep -w 8e | head -n 1 | cut -c-8)
partnumber=$(fdisk -l | grep $device | sed 1d | grep -c $device)
pvcreate $device$partnumber
volgroupname=$(vgdisplay | grep -w "VG Name" | cut -b10- | tr -d " ")
vgextend $volgroupname $device$partnumber
volgroupchars=$(echo $volgroupname | wc --chars)
totalchars=$(($volgroupchars+13))
lvmname=$(df -h | grep -w $volgroupname | head -n 1 | cut -b$totalchars-)
set $lvmname
lvmname=$1
lvextend -l +100%FREE /dev/$volgroupname/$lvmname
resize2fs /dev/$volgroupname/$lvmname
You can control final size with this command:
You should see new disk size after this process.
Posted in Linux Server, Virtual Machine Manager | 4 Comments | 8,669 views | 26/03/2012 04:19
Ubuntu 12 is coming with Hyper-V drivers for the best integration and usability. Ubuntu 12 is still in Beta like Hyper-V v3 but results are promising. I’m posting some important screenshots from Ubuntu 12. You can also find benchmark results of new Ubuntu 12 on Hyper-V v3.
1. Ubuntu Login Screen and no “SMBus Base Address Uninitialized” warning anymore!
2. Ubuntu 12 recognizes Hyper-V synthetic network driver by default.
3. Let’s see installed Hyper-V modules.
Posted in Linux Server, Virtual Machine Manager | 2 Comments | 10,016 views | 28/01/2012 20:07
You may need to uninstall Hyper-V Linux Integration Services v3.2 due to some reasons.
Let’s read documentation and see if we can.
After my first look, i don’t see any difference between x86 and x64.
Lets check it on VM console and see if they are correct.
Posted in Linux Server | No Comment | 2,325 views | 27/12/2011 09:33
You can create MySQL database and user via command line.
1
2
3
4
| CREATE DATABASE dbname;
CREATE USER 'dbusername'@'localhost';
SET PASSWORD FOR 'dbusername'@'localhost' = PASSWORD('PASSWORD');
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES,LOCK TABLES,REFERENCES ON dbname.* TO `dbusername`@`localhost` WITH GRANT OPTION; |
CREATE DATABASE dbname;
CREATE USER 'dbusername'@'localhost';
SET PASSWORD FOR 'dbusername'@'localhost' = PASSWORD('PASSWORD');
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES,LOCK TABLES,REFERENCES ON dbname.* TO `dbusername`@`localhost` WITH GRANT OPTION;
That gives only localhost grant on MySQL server.
Posted in Linux Server | No Comment | 2,347 views | 27/12/2011 09:27
You can transfer data between two linux servers directly via SCP.
scp -r root@10.10.10.2:/var/www/html/production/common /var/www/html/production |
scp -r root@10.10.10.2:/var/www/html/production/common /var/www/html/production
It transfer common directory from 10.10.10.2 to under production directory.
|