Why?


Search This Blog

Saturday, June 6, 2015

Centos 7 Samba Setup on

Centos 7 Samba Setup on

I did this in Centos 7 with kernel 4.0.4

Since I am behind a firewall in my local LAN I have disabled SELINUX and turned firewall off. i am also fully up to date on packages as of 4/1/2015.

Get your system ready.

Turn off firewall and iptables if they are on.

# systemctl disable firewalld.service
# systemctl stop firewalld.service
# systemctl disable iptables.service
# systemctl stop iptables.service


Disable selinux if it is enforced.

# vi /etc/sysconfig/selinux
    SELINUX=disabled


reboot if you have changed these

# reboot

NOTE** I fought with this for day so beware! I am on Centos 6.6 I have the epel repo active in my repo list. When I used yum for the install of samaba, I think it got it from there. All worked well with using \\ip_addr_of_samba_server\ but I could never get my samba server to show up in windows network browser. I discovered nmb was NOT running on the samba server. Not good if you want windows to discover it automatically. So I completely removed samba using “yum –y remove samba*” (notice the * at the end of samba. And leave out the quotes). I then removed the epel repo with “rpm -e your-epel-package-name-here” Now you can install samba with the steps below and have it work 100%.

Install samba

# yum -y install samba*

Create user and set password for samba share use

# useradd samba -s /sbin/nologin
# smbpasswd -a samba
            Supply a password
            Retype the password

mkdir for the shared files and set permissions

# mkdir /share
# chown -R samba:root /share/

Now config samba for the share and share user

# vi /etc/samba/smb.conf

Add/edit this under the [global] section

[global]
workgroup = WORKGROUP ;use name of your workgroup here
server string = Samba Server Version %v
netbios name = SAMBA

Add this to botton of /etc/samba/smb.conf file

[share]
comment = Share
path = /share
writable = yes
valid users = samba

Now start samaba and make sure it is on after boot

# service smb start
# chkconfig smb on
# service nmb start
# chkconfig nmb on

Now test your setup with

# testparm

Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No
[share]
comment = Share
path = /share
valid users = samba
read only = No


NOTE** make sure your workgroup =  is the actual name of your Windows workgroup, smb service is running, and nmb service is running, or you won’t see your samba server when windows machines browse the network.

NOTE: ** when accessing your samba server from windows 8.1 there is a problem with accessing the same server with two sets of credentials. Meaning if you login to a samba share as one user you will not be able to login to another share as another user. If you need to change users you can relogin into Windows OS (not cool) or use:

C:\> net use * /DELETE

Say yes to remove the connection(s) you already have, thus saving a reboot :) 

Thanks to:

http://www.if-not-true-then-false.com/2010/yum-remove-repo-repository-yum-disable-repo-repository/

http://www.krizna.com/centos/installing-configuring-samba-centos-6/

The end!

Centos 7 Systemd

This was taken from

http://www.tejasbarot.com/2014/07/22/rhel-7-centos-7-how-to-get-started-with-systemd/#axzz3cIJAIqNe

 

Presentation


As the Systemd now replaces SysVinit, it is time to get familiar with it and learn new commands.
Systemd is quicker because it uses fewer scripts and tries to run more tasks in parallel (Systemd calls them units).

The Systemd configuration is stored in the /etc/systemd directory.

 

Boot process


Systemd primary task is to manage the boot process and provides informations about it.
To get the boot process duration, type:

# systemd-analyze
Startup finished in 422ms (kernel) + 2.722s (initrd) + 9.674s (userspace) = 12.820s

To get the time spent by each task during the boot process, type:
 
# systemd-analyze blame
7.029s network.service
2.241s plymouth-start.service
1.293s kdump.service
1.156s plymouth-quit-wait.service
1.048s firewalld.service
632ms postfix.service
621ms tuned.service
460ms iprupdate.service
446ms iprinit.service
344ms accounts-daemon.service
...
7ms systemd-update-utmp-runlevel.service
5ms systemd-random-seed.service
5ms sys-kernel-config.mount

Note: You will find additional information on this point in the Lennart Poettering’s blog.

 

Journal analysis


In addition, Systemd handles the system event log, a syslog daemon is not mandatory any more.

To get the content of the Systemd journal, type:
 
# journalctl

To get all the events related to the crond process in the journal, type:
 
# journalctl /sbin/crond

Note: You can replace /sbin/crond by `which crond`.

To get all the events since the last boot, type:
 
# journalctl -b

To get all the events that appeared today in the journal, type:
 
# journalctl --since=today

To get all the events with a syslog priority of err, type:
 
# journalctl -p err

To get the 10 last events and wait for any new one (like “tail -f /var/Log/messages”), type:
 
# journalctl -f

Note: You will find additional information on this point in the Lennart Poettering’s blog or Lennart Poettering’s video (44min: the first ten minutes are very interesting concerning security issues).

 

Control groups


Systemd organizes tasks in control groups. For example, all the processes started by an apache webserver will be in the same control group, CGI scripts included.

To get the full hierarchy of control groups, type:
 
# systemd-cgls
├─user.slice
│ └─user-1000.slice
│ └─session-1.scope
│ ├─2889 gdm-session-worker [pam/gdm-password]
│ ├─2899 /usr/bin/gnome-keyring-daemon --daemonize --login
│ ├─2901 gnome-session --session gnome-classic
. .
└─iprupdate.service
└─785 /sbin/iprupdate --daemon

To get the list of control group ordered by CPU, memory and disk I/O load, type:
 
# systemd-cgtop
Path Tasks %CPU Memory Input/s Output/s
/ 213 3.9 829.7M - -
/system.slice 1 - - - -
/system.slice/ModemManager.service 1 - - - -

To kill all the processes associated with an apache server (CGI scripts included), type:
 
# systemctl kill httpd

To put resource limits on a service (here 500 CPUShares), type:
 
# systemctl set-property httpd.service CPUShares=500

Note1: The change is written into the service unit file. Use the –runtime option to avoid this behavior.

Note2: By default, each service owns 1024 CPUShares. Nothing prevents you from giving a value smaller or bigger.

To get the current CPUShares service value, type:
 
# systemctl show -p CPUShares httpd.service

 

Service management


Systemd deals with all the aspects of the service management. The systemctl command replaces the chkconfig and the service commands. The old commands are now a link to the systemctl command.

To activate the NTP service at boot, type:
 
# systemctl enable ntpd

Note1: You should specify ntpd.service but by default the .service suffix will be added.

Note2: If you specify a path, the .mount suffix will be added.

Note3: If you mention a device, the .device suffix will be added.

To deactivate it, start it, stop it, restart it, reload it, type:
 
# systemctl disable ntpd
# systemctl start ntpd
# systemctl stop ntpd
# systemctl restart ntpd
# systemctl reload ntpd

To know if the NTP service is activated at boot, type:
 
# systemctl is-enabled ntpd
enabled

To know if the NTP service is running, type:
 
# systemctl is-active ntpd
inactive

To get the status of the NTP service, type:
 
# systemctl status ntpd
ntpd.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

If you change a service configuration, you will need to reload it:
 
# systemctl daemon-reload

To get the list of all the units (services, mount points, devices) with their status and description, type:
 
# systemctl

To get a more readable list, type:
 
# systemctl list-unit-files

To get the list of services that failed at boot, type:
 
# systemctl --failed

To get the status of a process (here httpd) on a remote server (here rhel7.example.com), type:
 
# systemctl -H root@rhel7.example.com status httpd.service

 

Run levels


Systemd also deals with run levels. As everything is represented by files in Systemd, target files replace run levels.

To move to single user mode, type:
 
# systemctl rescue

To move to the level 3 (equivalent to the previous level 3), type:
 
# systemctl isolate runlevel3.target

Or:
 
# systemctl isolate multi-user.target

To move to the graphical level (equivalent to the previous level 5), type:
 
# systemctl isolate graphical.target

To set the default run level to non-graphical mode, type:
 
# systemctl set-default multi-user.target

To set the default run level to graphical mode, type:
 
# systemctl set-default graphical.target

To get the current default run level, type:
 
# systemctl get-default
graphical.target

To stop a server, type:
 
# systemctl poweroff

Note: You can still use the poweroff command, a link to the systemctl command has been created (the same thing is true for the halt and reboot commands).

To reboot a server, suspend it or put it into hibernation, type:
 
# systemctl reboot
# systemctl suspend
# systemctl hibernate

 

Linux standardization


Systemd‘s authors have decided to help Linux standardization among distributions. Through Systemd, changes happen in the localization of some configuration files.

 

Miscellaneous


To get the server hostnames, type:
 
# hostnamectl
Static hostname: rhel7.example.com
Icon name: computer-laptop
Chassis: laptop
Machine ID: bcdc71f1943f4d859aa37e54a422938d
Boot ID: f84556924b4e4bbf9c4a82fef4ac26d0
Operating System: Red Hat Enterprise Linux Everything 7.0 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:beta:everything
Kernel: Linux 3.10.0-54.0.1.el7.x86_64
Architecture: x86_64

Note: There are three kinds of hostnames: static, pretty, and transient.
“The static host name is the traditional hostname, which can be chosen by the user, and is stored in the /etc/hostname file. The “transient” hostname is a dynamic host name maintained by the kernel. It is initialized to the static host name by default, whose value defaults to “localhost”. It can be changed by DHCP or mDNS at runtime. The pretty hostname is a free-form UTF8 host name for presentation to the user.” Source: RHEL 7 Networking Guide.

To assign the rhel7 hostname permanently to the server, type:
 
# hostnamectl set-hostname rhel7

Note: With this syntax all three hostnames (static, pretty, and transient) take the rhel7 value at the same time. However, it is possible to set the three hostnames separately by using the –pretty, –static, and –transient options.

To get the current locale, virtual console keymap and X11 layout, type:
 
# localectl
System Locale: LANG=en_US.UTF-8
VC Keymap: en_US
X11 Layout: en_US

To assign the en_GB.utf8 value to the locale, type:
 
# localectl set-locale LANG=en_GB.utf8

To assign the en_GB value to the virtual console keymap, type:
 
# localectl set-keymap en_GB

To assign the en_GB value to the X11 layout, type:
 
# localectl set-x11-keymap en_GB

To get the current date and time, type:
 
# timedatectl
Local time: Fri 2014-01-24 22:34:05 CET
Universal time: Fri 2014-01-24 21:34:05 UTC
RTC time: Fri 2014-01-24 21:34:05
Timezone: Europe/Madrid (CET, +0100)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2013-10-27 02:59:59 CEST
Sun 2013-10-27 02:00:00 CET
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2014-03-30 01:59:59 CET
Sun 2014-03-30 03:00:00 CEST

To set the current date, type:
 
# timedatectl set-time YYYY-MM-DD

To set the current time, type:
 
# timedatectl set-time HH:MM:SS

To get the list of time zones, type:
 
# timedatectl list-timezones

To change the time zone to America/New_York, type:
 
# timedatectl set-timezone America/New_York

To get the users’ list, type:
 
# loginctl list-users
UID USER
42 gdm
1000 tom
0 root

To get the list of all current user sessions, type:
 
# loginctl list-sessions
SESSION UID USER SEAT
1 1000 tom seat0

1 sessions listed.

To get the properties of the user tom, type:
 
# loginctl show-user tom
UID=1000
GID=1000
Name=tom
Timestamp=Fri 2014-01-24 21:53:43 CET
TimestampMonotonic=160754102
RuntimePath=/run/user/1000
Slice=user-1000.slice
Display=1
State=active
Sessions=1
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0

For a better understanding, you can additionally read Bob Cromwell’s blog about Systemd.

Thanks to Original Author for explaining it very nicely.

Source : http://www.certdepot.net/rhel7-get-started-systemd/

Monday, June 1, 2015

pfSense setting up bridge networks for use in KVM

pfSense setting up bridge networks for use in KVM

My KVM host is Centos 6.6 with kernel upgrade to 3.19.8. I have an on-board and an add on PCIe 1GB NIC's for use.

I use this setup to install pfSense as a KVM guest using the two physical NIC's in my KVM host.

My first interface eth0 is a Qualcomm® Atheros 1GB on-board NIC with HWADDR=74:d4:35:ea:90:1f and using IP addr of 192.168.10.100 and network of 192.168.10.0/24
This interface is behind a 1GB switch then to my router attached to the Internet.

My second interface eth1 is a TP Link 1GB add on card with HWADDR=30:B5:C2:02:77:2B and using IP addr of 192.168.100.100 and network of 192.168.100.0/24
This interface is plugged into a standalone 1GB switch and has no other connectivity or networks attached.

My object is to be able to build guest images in my KVM host that can use either, or both, interfaces.
I want to install a pfSense guest image using both interfaces, eth0 as WAN and eth1 and LAN.
Then I can build two more Centos guest images, one with just eth0 and the other with eth1, and use the pfSense image as the router between the two.

First I make sure network manager is off, and stays off on reboot.

# chkconfig NetworkManager off
# service NetworkManager stop


Verify your resolv.conf file. Should look something like

# vi /etc/resolv.conf
search whittenberg.domain
nameserver 192.168.10.1


Verify your networks file

# vi /etc/networks
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0


Verify your network file

# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nas.whittenberg.domain
GATEWAY=192.168.10.1
NETWORKING_IPV6=no


Setup your ifcfg-eth0 file. Notice I rem out the IP numbers and add BRIDGE=br0 at the bottom .

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=74:d4:35:ea:90:1f
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
NETWORKING_IPV6=no
IPV6_AUTOCONF=no
#IPADDR=192.168.10.100
#NETMASK=255.255.255.0
#BROADCAST=192.168.10.255
#NETWORK=192.168.10.0
#GATEWAY=192.168.10.1
BRIDGE=br0


Setup your ifcfg-eth1 file. Notice I rem out the IP numbers and add BRIDGE=br1 at the bottom .

# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=30:B5:C2:02:77:2B
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
NETWORKING_IPV6=no
IPV6_AUTOCONF=no
#IPADDR=192.168.100.100
#NETMASK=255.255.255.0
#BROADCAST=192.168.100.255
#NETWORK=192.168.100.0
#GATEWAY=192.168.10.1
BRIDGE=br1


Build a new ifcfg-br0 file. Notice this has the IP numbers in it and not rem'd out, DEVICE=br0, and TYPE=Bridge (Use upper-case B in Bridge or will not work)

# vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
NETWORKING_IPV6=no
IPV6_AUTOCONF=no
STP=yes
DELAY=0
IPADDR=192.168.10.100
NETMASK=255.255.255.0
BROADCAST=192.168.10.255
NETWORK=192.168.10.0
GATEWAY=192.168.10.1


Build a new ifcfg-br1 file. Notice this has the IP numbers in it and not rem'd out, DEVICE=br1, and TYPE=Bridge (Use upper-case B in Bridge or will not work)
I also have my GATEWAY at 192.168.10.1 so I can route out on the KVM host from either interface

# vi /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE=br1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
NETWORKING_IPV6=no
IPV6_AUTOCONF=no
STP=yes
DELAY=0
IPADDR=192.168.100.100
NETMASK=255.255.255.0
BROADCAST=192.168.100.255
NETWORK=192.168.100.0
GATEWAY=192.168.10.1


Now restart the network

# service network restart

Verify your setup

# ifconfig
br0       Link encap:Ethernet  HWaddr 74:D4:35:EA:90:1F
          inet addr:192.168.10.100  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::76d4:35ff:feea:901f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4364 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2023 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:742025 (724.6 KiB)  TX bytes:255958 (249.9 KiB)

br1       Link encap:Ethernet  HWaddr 30:B5:C2:02:77:2B
          inet addr:192.168.100.100  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::32b5:c2ff:fe02:772b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2381 errors:0 dropped:0 overruns:0 frame:0
          TX packets:535 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:291677 (284.8 KiB)  TX bytes:38805 (37.8 KiB)

eth0      Link encap:Ethernet  HWaddr 74:D4:35:EA:90:1F
          inet6 addr: fe80::76d4:35ff:feea:901f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10464 errors:0 dropped:34 overruns:0 frame:0
          TX packets:3595 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2023784 (1.9 MiB)  TX bytes:481595 (470.3 KiB)
          Interrupt:18

eth1      Link encap:Ethernet  HWaddr 30:B5:C2:02:77:2B
          inet6 addr: fe80::32b5:c2ff:fe02:772b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5202 errors:0 dropped:34 overruns:0 frame:0
          TX packets:2479 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1166588 (1.1 MiB)  TX bytes:157098 (153.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:2951 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2951 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:646709 (631.5 KiB)  TX bytes:646709 (631.5 KiB)

         

Verify the bridge

# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.74d435ea901f       yes             eth0
br1             8000.30b5c202772b       yes             eth1
pan0            8000.000000000000       no



Check your routes

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         TEW-731BR       0.0.0.0         UG    0      0        0 br0
link-local      *               255.255.0.0     U     1011   0        0 br0
link-local      *               255.255.0.0     U     1012   0        0 br1
192.168.10.0    *               255.255.255.0   U     0      0        0 br0
192.168.100.0   *               255.255.255.0   U     0      0        0 br1


Notice my default gateway. TEW-731BR is my router name on 192.168.10.1 IP addr.

Test we have internet access bot FQDN and IP addr

# ping www.google.com
PING www.google.com (74.125.21.99) 56(84) bytes of data.
64 bytes from yv-in-f99.1e100.net (74.125.21.99): icmp_seq=1 ttl=42 time=90.1 ms


# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=24.4 ms

         
Now you should be able to use br0 and br1 in your KVM guest images.

I will setup br0 as my WAN interface in pfSense guest image and give it IP addr of 192.168.10.10 with a route out of 192.168.10.1

I will also setup br1 as my LAN interface in pfSense guest image and give it IP addr of 192.168.100.10

Now any other guest image I build using the br1 interface I can set that image for a route out on 192.168.100.10 and it will go through the pfSense router for all request off the 192.168.100.0/24 network.

Hope this helps!

Added 6/1/2015 18:18 AZ
Well it worked! I used the e1000 NIC adapter on both interfaces when I built my pfSense image. The max transfer speed I was able to get out of it was 50MBs across the router. I think this may be do to the fact I am using the same zfs pool for source and destination file. My pfSense image is on the zfs pool. My test Centos image I put on 192.168.100.0 network is on the zfs pool. And the file I was retrieving is also on the zfs pool, but on a 192.168.10.0 network. I will try and get a share off the pool, and on my SSD, from the 192.168.10.0 network and trying the transfer again. BTW cpu was at 45% during the transfer. I used all 4 cores for all images. This is shared with the Host of course that was serving up the file off the zfs pool on 192.168.10.0 network. I may need another physical machine on the 192.168.10.0 network to get into the 100MB's (That's my goal).

Saturday, May 30, 2015

Centos 7 Plex media server install

Centos 7 Plex media server install

I am on Centos7 using kernel 3.19.8 with Desktop install. I am putty/ssh into system as root.

I am at home behind firewall and do not use iptables, firewall, or selinux on my Centos7 system, so I have turned them off.

Turn off firewall and iptables if they are on.

# systemctl disable firewalld.service
# systemctl stop firewalld.service
# systemctl disable iptables.service
# systemctl stop iptables.service


Disable selinux if it is enforced.

# vi /etc/sysconfig/selinux
    SELINUX=disabled


reboot if you have changed these

# reboot

Locate the latest version of Plex media server for Centos7

Go to

https://plex.tv/downloads


on your PC and then click download for Computer, not NAS. Choose Linux, then right click on the Centos 64-bit button. Chose copy link location.

Now putty into your Centos7 system as root. Changed to your root home dir.

# cd /root

Type "wget", space bar, then right click mouse. This should paste the link you copied above. Should look like:

# wget https://downloads.plex.tv/plex-media-server/0.9.12.1.1079-b655370/plexmediaserver-0.9.12.1.1079-b655370.x86_64.rpm

After download of the rpm package do a "yum -y localinstall <Plex Media Server RPM package>" command. Mine looks like:

# yum -y localinstall plexmediaserver-0.9.12.1.1079-b655370.x86_64.rpm

After install make sure it is set to start at boot and then make sure it is on now.

# systemctl enable plexmediaserver.service
# systemctl start plexmediaserver.service


Now see if you can access the Plex web ui from your PC with (use your IP addr of your system):

http://192.168.1.100:32400/web/

Lots of info on the Plex site on how to finish the config. I wont cover them here. This was just for the install.


Hope it helps !



Friday, May 29, 2015

Centos 7 zfs install

Centos 7 zfs install

I have already installed asterisk on this system (see my post on that if you wish). During that install I did a kernel upgrade to 3.19.8, and that is the kernel I am running.

I am using putty/ssh and root user.

I am at home behind firewall and do not use iptables, firewall, or selinux on my Centos7 system, so I have turned them off.

Turn off firewall and iptables if they are on.

# systemctl disable firewalld.service
# systemctl stop firewalld.service
# systemctl disable iptables.service
# systemctl stop iptables.service


Disable selinux if it is enforced.

# vi /etc/sysconfig/selinux
    SELINUX=disabled


reboot if you have changed these

# reboot

Now get the packages and install them.

# cd /root
# yum -y localinstall --nogpgcheck https://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# yum -y localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm
# yum -y install kernel-devel zfs


You can now load the ZFS module:

# modprobe zfs

After running the above command you should have seen a list of loaded modules from ZFS.

# lsmod | grep -i zfs
zfs                  2179437  3
zcommon                47120  1 zfs
znvpair                80252  2 zfs,zcommon
spl                    89796  3 zfs,zcommon,znvpair
zavl                    6784  1 zfs
zunicode              323046  1 zfs


You should now make sure the module is loaded persistently on boot. We need to make a new file and add a script to it.

# vi /etc/sysconfig/modules/zfs.modules

Add the following code:

#!/bin/sh

if [ ! -c /dev/zfs ] ; then
        exec /sbin/modprobe zfs >/dev/null 2>&1
fi


Make this file executable:

# chmod +x /etc/sysconfig/modules/zfs.modules

Now reboot and make sure everything loaded

# reboot

After reboot run lsmod again and make sure modules are loaded

# lsmod | grep -i zfs
zfs                  2179437  3
zcommon                47120  1 zfs
znvpair                80252  2 zfs,zcommon
spl                    89796  3 zfs,zcommon,znvpair
zavl                    6784  1 zfs
zunicode              323046  1 zfs



Create pool. I have 4 WD RED 3TB drives on /dev/sdb through /dev/sde. I will create a raid10 pool with these now.

First I make sure I am at the latest firmware on my drives. I use the WD tool for that

# ./wd5741x64
WD5741 Version 1
Update Drive
Copyright (C) 2013 Western Digital Corporation
-Dn   Model String           Serial Number     Firmware
-D0   Samsung SSD 850 PRO 128GB   S1SMNSAG301480T   EXM02B6Q
-D1   WDC WD30EFRX-68EUZN0   WD-WMC4N0J0YT1V   82.00A82
-D2   WDC WD30EFRX-68EUZN0   WD-WMC4N0J2L138   82.00A82
-D3   WDC WD30EFRX-68EUZN0   WD-WCC4N2FJRTU9   82.00A82
-D4   WDC WD30EFRX-68EUZN0   WD-WCC4N7SP4HHF   82.00A82


As you can see I have Samsung SSD 850 PRO 128GB I use as my /boot and OS drive.

Then I turn off head parking on my WD RED drives with the WD tool

# ./idle3ctl -d /dev/sdb
Idle3 timer disabled
Please power cycle your drive off and on for the new setting to be taken into account. A reboot will not be enough!


I do this on all four drives then reboot.

# reboot

I then make sure the setting stuck.

# ./idle3ctl -g /dev/sdc
Idle3 timer is disabled


I check all four drives for the "disabled" value above.

Now I zero out the MBR to remove any legacy info that may have been on them.

# dd if=/dev/zero of=/dev/sdb bs=1M count=1

Repeat for all four drives.

I will now create a raid10 pool, called myraid, for use.

# zpool create myraid mirror -f /dev/sdb /dev/sdc mirror /dev/sdd /dev/sde

Make sure it was created

# zpool status
  pool: myraid
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        myraid      ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            sdb     ONLINE       0     0     0
            sdc     ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            sdd     ONLINE       0     0     0
            sde     ONLINE       0     0     0


Check it is mounted

# mount | grep zfs
myraid on /myraid type zfs (rw,xattr)


# df -h | grep myraid
myraid                5.3T  284G  5.0T   6% /myraid


If you don’t see it mounted try

# zfs mount myraid

Add ZFS to auto mount /myraid with boot if wanted

# echo "zfs mount myraid" >> /etc/rc.local           

To speed things up

# zfs set sync=disabled myraid

Read below before disabling though

sync=standard
  This is the default option. Synchronous file system transactions
  (fsync, O_DSYNC, O_SYNC, etc) are written out (to the intent log)
  and then secondly all devices written are flushed to ensure
  the data is stable (not cached by device controllers).

sync=always
  For the ultra-cautious, every file system transaction is
  written and flushed to stable storage by a system call return.
  This obviously has a big performance penalty.

sync=disabled
  Synchronous requests are disabled.  File system transactions
  only commit to stable storage on the next DMU transaction group
  commit which can be many seconds.  This option gives the
  highest performance.  However, it is very dangerous as ZFS
  is ignoring the synchronous transaction demands of
  applications such as databases or NFS.
  Setting sync=disabled on the currently active root or /var
  file system may result in out-of-spec behavior, application data
  loss and increased vulnerability to replay attacks.
  This option does *NOT* affect ZFS on-disk consistency.
  Administrators should only use this when these risks are understood.

 
 
You can also turn lz4 compression on your pool which speeds things up, at the cost of some cpu though. I have an i5 4590 with 16GB RAM so I have the resources to do so.

Tuning

# cat /sys/module/zfs/parameters/zfs_prefetch_disable
0

# modprobe zfs zfs_prefetch_disable=1


This setting is done in the /etc/modprobe.d/zfs.conf file.

I have i5-6600k with 64GB DDR4 RAM on a Supermicro C7Z170-OCE motherboard, x4 WD RED 3TB drives in mirrored stripes on a Supermicro 8 port 600MB SAS/SATA HBA AOC. Dont use these parameters below unless you know your hardware :)

Below are my settings for my NAS with ZFS foir use in running ESXi VMware guest images off of over 10Gb network between ESXi 5.5 U2 and the NAS via NFS. I am getting 340+MB read and write across the wire with linux client with SSD to NAS ZFS pool using scp. I think I reached my drives/zpool performance. Time to add more drives. I also tested with Windows 10 guest image on the zpool via 10Gb NFS and get read and write of 280MB to/from the Zpool Windows image and the NAS SSD drive. I think the smb/samba adds some overhead there.

edit zfs.conf to reflect:

# disable prefetch
options zfs zfs_prefetch_disable=1
# set arc max to 48GB. I have 64GB in my server
options zfs zfs_arc_max=51539607552
# set size to 128k same as file system block size
options zfs zfs_vdev_cache_size=1310720
options zfs zfs_vdev_cache_max=1310720
options zfs zfs_read_chunk_size=1310720
options zfs zfs_vdev_cache_bshift=17
options zfs zfs_read_chunk_size=1310720
# Set these to 1 so we get max IO at cost of bandwidth
options zfs zfs_vdev_async_read_max_active=1
options zfs zfs_vdev_async_read_min_active=1
options zfs zfs_vdev_async_write_max_active=1
options zfs zfs_vdev_async_write_min_active=1
options zfs zfs_vdev_sync_read_max_active=1
options zfs zfs_vdev_sync_read_min_active=1
options zfs zfs_vdev_sync_write_max_active=1
options zfs zfs_vdev_sync_write_min_active=1


# reboot


Sanity check

# cat /sys/module/zfs/parameters/zfs_prefetch_disable
# cat /sys/module/zfs/parameters/zfs_arc_max


Example commands to see settings

# zfs get all
# zfs get all myraid
# zfs get checksum
# zfs get checksum myraid

*ALWAYS* use Mirror / RAID10 – never, never, ever use RAIDz !

Data compression : LZ4 ( Yes, on *everything*, make sure you have enough CPU though. )
    zfs set compression=lz4 myraid
   
Checksum : Fletcher4
    zfs set checksum=fletcher4 myraid

Use Cache for : Data & Metadata*1
    zfs set primarycache=all myraid

Write bias : Latency*1
    zfs set logbias=latency myraid

Record size / block size : 128k ( This is vital people – we go against the “use record size as in workload” recommandation )
    zfs set recordsize=128k myraid

Update access time on read : disable
    zfs set atime=off myraid
   
Do not use dedupe.
    # zfs set dedup=off myraid

Enable Jumbo Frames

Disable sync
    # zfs set sync=disabled myraid

Have fun!

Centos 7 Asterisk 13.3.2 install with kernel 3.19.8 update

Centos 7 Asterisk 13.3.2 install with kernel 3.19.8 update

I am not going to cover basic OS install here, You should have your OS installed and able to reach the internet. I did the Desktop install as I will be using this for other purposes. If this is a production asterisk only system you should do a minimal install.

I logged in as root user via putty/ssh.

Get your system ready.

Install some prereqs

# cd /root
# contrib/scripts/install_prereq install


Turn off firewall and iptables if they are on.

# systemctl disable firewalld.service
# systemctl stop firewalld.service
# systemctl disable iptables.service
# systemctl stop iptables.service


Disable selinux if it is enforced.

# vi /etc/sysconfig/selinux
    SELINUX=disabled


reboot if you have changed these

# reboot

Install NTP and turn on of not already.

# yum -y install ntp*
# systemctl disable chronyd.service
# systemctl enable ntpd.service
# systemctl start ntpd.service
# ntpq -p
# date


Update system and reboot.

# yum -y update
# reboot


I update the kernel as this is new build an I like to use a good updated kernel when I start things out. This "could be" optional. I don't know. I have not tried this on another kernel.

Update kernel to latest 3.x (3.19.8).

Get required packages for the kernel update, and some for asterisk install.

# yum -y groupinstall "Development Tools"
# yum -y install ncurses-devel qt-devel hmaccalc zlib-devel binutils-devel elfutils-libelf-devel wget bc gzip uuid* libuuid-devel jansson* libxml2* sqlite* openssl*
# yum -y update


Now from /root directory download the kernel source.

# wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.19.8.tar.gz

Unzip and extract the source file.

# gzip -d ./linux-3.19.8.tar.gz
# tar -xvf ./linux-3.19.8.tar -C /usr/src/


Now let’s go to our source directory and configure the new Kernel. I just left everything alone and saved the file before I exit the menu.

# cd /usr/src/linux-3.19.8/
# make menuconfig


Compile kernel.

# make

Now go get coffee or beer. The compile will take a bit.

Install kernel.

# make modules_install
# make install


When finished lets reboot and use the new kernel. This will not be the default selection in grub so after you reboot the machine you need to press enter when you see the grub menu. You will only have a few seconds so beware.

You must be at console for choosing the kernel at boot manually. After we set this to to default kernel in grub we can return to putty.

# reboot

On boot screen select the new kernel for boot. After the boot and login type:

# uname -r
3.19.8


Looks like I am on the new Kernel.

Now set new kernel for default boot. I also leave console and return to putty here.

Check menu entries in grub.

# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
CentOS Linux 7 (Core), with Linux 3.19.8
CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64
CentOS Linux 7 (Core), with Linux 3.10.0-229.4.2.el7.x86_64
CentOS Linux 7 (Core), with Linux 0-rescue-455229da2acf4d3b941fda6a689c779c


Check current default.

# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)


Set new default.

# grub2-set-default "CentOS Linux 7 (Core), with Linux 3.19.8"

Check new default.

# grub2-editenv list
saved_entry=CentOS Linux (3.19.8) 7 (Core)


Now reboot and make sure new kernel is set for default.

# reboot
# uname -r
3.19.8


Download Asterisk and supported packages.

# cd /root

Get libpri.


# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
# gzip -dfv libpri-1.4-current.tar.gz
# tar -xvf libpri-1.4-current.tar -C /usr/src/


Get DAHDI.

# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
# gzip -dfv dahdi-linux-complete-current.tar.gz
# tar -xvf dahdi-linux-complete-current.tar -C /usr/src/


Get asterisk.

# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
# gzip -dfv asterisk-13-current.tar.gz
# tar -xvf asterisk-13-current.tar -C /usr/src/


DAHDI install.

# cd /usr/src/dahdi-linux-complete*
# make
# make install
# make config


libpri install.

# cd /usr/src/libpri*
# make
# make install


Asterisk install

# cd /usr/src/asterisk*
# ./configure --libdir=/usr/lib64
# make menuselect
# make
# make install
# ldconfig


Optional items.

# cd /usr/src/asterisk*
# make samples
# make progdocs


See if asterisk will run.

# asterisk -vvv &
# ps -ef | grep asterisk
root     15498  2402  0 21:12 pts/0    00:00:00 asterisk -vvv


Now go to asterisk console.

# asterisk -r
    -- Remote UNIX connection
Asterisk 13.3.2, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 13.3.2 currently running on centos7vm (pid = 15498)
centos7vm*CLI> help


Get asterisk to start up on boot

# cd /usr/src/asterisk*
# make config

# /sbin/chkconfig --add asterisk
# /sbin/chkconfig asterisk on

Enjoy!

Wednesday, May 27, 2015

KVM create Windows guest Centos 6.6 and 7



KVM create Windows guest

This is what works best for me. I have a Centos 6.6 with 3.19.8 kernel I use for my KVM host. I use this at home for testing/play.

This also works for Centos7. I have used the same procedure.

My KVM host is an i5 4590 with 16GB (2x8GB) Corsair DDR3 1600 RAM, 120GB Samsung PRO SSD for boot and OS, with 4x WD RED 3TB in zfs RAID 10.

# zpool create myraid mirror /dev/sdb /dev/sdc mirror /dev/sdd /dev/sde

I used the name myraid for the pool.

My KVM host, I mention above, is headless and I have Gnome and VNC installed on it. I manage most everything through the cli via ssh, but working with KVM for Windblows, I mean Windows, quest is very difficult without a desktop. Of course I have virt-manager, virt-viewer, virt-win, etc... on it.

I found this procedure works fairly well. Sometimes I see heavy CPU load from the Windows guest I occasional run on it, but hey, it’s Windows.

First I create a 100GB disk in my pool for the image. For this example I use disk1, to keep it simple.

# zfs create -V 100G myraid/disk1

Verify the new zvol is there

# ls -l /dev/zvol/myraid
total 0
lrwxrwxrwx 1 root root 9 May 26 18:54 disk1 -> ../../zd0

# ls -l /dev/zvol/myraid/disk1
lrwxrwxrwx 1 root root 9 May 26 18:54 /dev/zvol/myraid/disk1 -> ../../zd0

We now have a block device in our zfs pool we can manage like any other block device in Linux. The fdisk commands below are:

n = for new partition.
p = when asking for primary or extended.
1 = is the partition number.
Then hit enter key twice to choose default first cylinder.
p = to to print to screen our new partition, verify it looks good.
w = for write changes.

Now let’s get a partition on it

# fdisk /dev/zvol/myraid/test1
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-20805, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-20805, default 20805):
Using default value 20805

Command (m for help): p

Disk /dev/zvol/myraid/test: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 8192 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disk identifier: 0x094e7df9

                Device Boot      Start         End      Blocks   Id  System
/dev/zvol/myraid/test1               1       20805    10485688+  83  Linux
Partition 1 does not start on physical sector boundary.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

Lets put a file system on it

# mkfs.ext4 /dev/zvol/myraid/disk1

Make a directory for a mount point. I used /disk1 for simplicity here

# mkdir /disk1

Mount it so we can us it

# mount /dev/zvol/myraid/disk1 /disk1

To make this mount on boot edit your fstab file and add a line like the following to bottom of file:

# vi /etc/fstab
/dev/zvol/myraid/disk1   /disk1   ext4    defaults,_netdev    0 0

I used the _netdev above as I was getting a failed to mount message in my boot.log, although it got mounted by the end of the boot. It was trying to mount this before zfs loaded, therefore not able to mount a zvol. The _netdev I think makes it wait for the services to start before trying to mount.

I then issue the following command so I don't have any permission issues later down the road. Remember this is home play setup, not corporate production.

# chmod 777 /disk1

Now create your KVM guest image on /disk1 using the virt-manager in the Gnome desktop, via VNC if your headless like me. Options I found that run the best for me are:

Storage format: virtio and raw
Cache mode: none (not default!)
I/O mode: native

I Also create a floppy and CDROM, and attach the virt-win drivers to each. ISO gets the CDROM and the floppy gets the fd. !!NOTE you must have these mounted and available on quest boot our the quest will not have a hard drive to use. Hence the virtio.

I also use the virt-nic and virt-mem found in the virt-win drivers ISO. The virt-nic gave me a 10GB network card and really improved my network speed.

Get virtio drivers for windows.

# wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo

Copy the contents of the virtio-win.repo file you just downloaded and paste in this new file

# vi /etc/yum.repos.d/virtio-win.repo

As of 8/24/2015 the contents of virtio-win.repo are.

# virtio-win yum repo
# Details: https://fedoraproject.org/wiki/Windows_Virtio_Drivers

[virtio-win-stable]
name=virtio-win builds roughly matching what was shipped in latest RHEL
baseurl=http://fedorapeople.org/groups/virt/virtio-win/repo/stable
enabled=1
skip_if_unavailable=1
gpgcheck=0

[virtio-win-latest]
name=Latest virtio-win builds
baseurl=http://fedorapeople.org/groups/virt/virtio-win/repo/latest
enabled=0
skip_if_unavailable=1
gpgcheck=0

[virtio-win-source]
name=virtio-win source RPMs
baseurl=http://fedorapeople.org/groups/virt/virtio-win/repo/srpms
enabled=0
skip_if_unavailable=1
gpgcheck=0

Now install the virtio-win drivers.

# yum -y install virtio-win

Drivers are now located at.

# ls -lsah /usr/share/virtio-win/

Have fun!