Thursday, September 5, 2019

Setting up a DNS server in Centos 7


The configuration of a DNS server in Linux Centos 7 is very simple. First of all, we will have to install the bind product, with the following command:

yum -y install bind bind-utils

Next, in the file /etc/named.conf, we define the service area of what we want to solve. In this case, I want to resolve the service namemain.webserver.local:



zone “webserver.local” IN {type master;file “forward.webserverlocal.db“;allow-update { none; };};zone “2.0.0.10.in-addr.arpa” IN {type master;file “reverse.webserverlocal.db“;allow-update { none; };};

In the file forward.webserverloca.db we define the IPs and the names of the service. That is, a service can point to several servers as can happen with google.com:

C:\Users\MyPC>nslookup www.google.comServer: resolver.hp.netAddress: 16.110.135.51Non-authoritative answer:Name: www.google.comAddresses: 2607:f8b0:4000:815::200474.125.195.10574.125.195.14774.125.195.9974.125.195.10474.125.195.10674.125.195.103

let´s take a look to our file “forward”:

[root@Centos7 ~]# cat /var/named/forward.webserverlocal.db$TTL 86400@ IN SOA maindns.webserver.local. root.webserver.local. (2011071001 ;Serial3600 ;Refresh1800 ;Retry604800 ;Expire86400 ;Minimum TTL)@ IN NS maindns.webserver.local.@ IN NS secondarydns.webserever.local.@ IN A 10.0.0.2@ IN A 10.0.0.3maindns IN A 10.0.0.2secondarydns IN A 10.0.0.3

In the “reverse” file we define the response path:

[root@Centos7 ~]# cat /var/named/reverse.webserverlocal.db$TTL 86400@ IN SOA main.webserver.local. root.webserver.local. (2011071001 ;Serial3600 ;Refresh1800 ;Retry604800 ;Expire86400 ;Minimum TTL)@ IN NS masterdns.webserver.local.maindns IN A 10.0.0.2secondarydns IN A 10.0.0.3101 IN PTR maindns.webeserver.local.102 IN PTR secondarydns.unixmen.local.

Once all the parameters have been defined, we restart the named service with the systemctl restart named command.


In our file /etc/resolv.conf, we have to point to the IP where the DNS service runs. In the case for this example, I have located everything on the same server:


[root@Centos7 ~]# cat /etc/resolv.confnameserver 10.0.0.2

Finally, we test the name resolution via DNS:



[root@Centos7 ~]# dig maindns.webserver.local; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> maindns.webserver.local;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33754;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096;; QUESTION SECTION:;maindns.webserver.local. IN A;; ANSWER SECTION:maindns.webserver.local. 86400 IN A 10.0.0.2;; AUTHORITY SECTION:webserver.local. 86400 IN NS secondarydns.webserever.local.webserver.local. 86400 IN NS maindns.webserver.local.;; Query time: 0 msec;; SERVER: 10.0.0.2#53(10.0.0.2);; WHEN: Mon Nov 12 13:27:25 CET 2018;; MSG SIZE rcvd: 120

Or like me, you are more used to the old nslookup:



[root@Centos7 ~]# nslookup maindns.webserver.localServer: 10.0.0.2Address: 10.0.0.2#53Name: maindns.webserver.localAddress: 10.0.0.2

I will also check the test WEB server that I have started on both servers:

[root@Centos7 ~]# curl -s http://maindns.webserver.local<html><body>Hola desde el Webserver 1</body></html>[root@Centos7 ~]# curl -s http://secondarydns.webserver.local<html><body>Hola desde el Webserver 2</body></html>


DNS configuration by round robin

Now we want that if the application of one server falls, the service continues to be given by the other WEB server. This configuration is called "high availability" by round robin of DNS.What I am going to do is configure the DNS so that the same name points to several different IPs. Each IP is raised on a different server (operating system), so if the "Webserver 1" drops, the service will continue to be given by the "Webserver 2".The name of the service I'm going to point to is called webservertest and I have a WEB server started on the server with IP 10.0.0.2 and the other Webserver on server 10.0.0.3.The result is as follows:


[root@Centos7 named]# curl -s http://webservertest<html><body>Hola desde el Webserver 1</body></html>[root@Centos7 named]# systemctl stop httpd[root@Centos7 named]# curl -s http://webservertest<html><body>Hola desde el Webserver 2</body></html>


As we can see, although for the Apache server with IP 10.0.0.2, the URL continues to service through Apache with IP 10.0.0.3.
To achieve this, I have configured new entries in the DNS. Let's see them:

  • File /etc/named.conf:

# webservertestzone “webservertest” IN {type master;file “forward.webservertest.db”;allow-update { none; };};zone “reverse.webservertest” IN {type master;file “reverse.webservertest.db”;allow-update { none; };};

  • File/var/named/forward.webservertest.db:

$TTL 86400@ IN SOA webservertest. root.webserver.local. (2011071001 ;Serial3600 ;Refresh1800 ;Retry604800 ;Expire86400 ;Minimum TTL)@ IN NS webservertest.@ IN NS webserevertest.@ IN A 10.0.0.2@ IN A 10.0.0.3webservertest IN A 10.0.0.2webservertest IN A 10.0.0.3

As we can see the same name services points to two diferrent IP´s.

  • File /var/named/reverse.webservertest.db:

$TTL 86400@ IN SOA webservertest. root.webservertest. (2011071001 ;Serial3600 ;Refresh1800 ;Retry604800 ;Expire86400 ;Minimum TTL)@ IN NS webservertest.webservertest IN A 10.0.0.2webservertest IN A 10.0.0.3101 IN PTR webservertest.102 IN PTR webservertest.

Thursday, April 11, 2019

kernel parameters in HP_UX


kctune: It is the administrative command for HP-UX kernel to view or change kernel parameters. The following information provides how to view or modify the kernel parameters.

 Viewing Kernel Parameters:
1
$usr/sbin/kctune

Modifying Kernel Parameters:
/usr/sbin/kctune <parameter name and it’s value>
Sample Output: 
1
2
3
4
5
6
7
8
9
10
mydb:/ #/usr/sbin/kctune hires_timeout_enable=1
     ==> Update the automatic 'backup' configuration first? yes
       * The automatic 'backup' configuration has been updated.
       * Future operations will update the backup without prompting.
        * The requested changes have been applied to the currently
         running configuration.
Tunable                         Value  Expression  Changes
hires_timeout_enable  (before)     0   Default     Immed
                       (now)       1   1
mydb:/ #

Viewing Specific Kernel Parameter:
/usr/sbin/kctune <parameter name >
Use the bellow command if you have HP_UX B.11.31 
1
2
3
4
mydb:/ #/usr/sbin/kctune hires_timeout_enable
Tunable               Value  Expression  Changes
hires_timeout_enable      1  1           Immed
mydb:/ #
Use the bellow command if you have HP_UX B.11.23
1
2
3
sun2:/home/oracle #sysdef | grep kctune hires_timeout_enable
maxuprc                    3686          -          3-                   -
sun2:/home/oracle #

Tuesday, November 20, 2018

Highly Available Clusters with kubeadm

In CentOs 7, we´ll install Kubernetes with the following command:

yum install - and kubernetes etcd

For it to work, we must have the Centos-Extras repository enabled.

Once the packages are installed we can start booting services.

Booting services in the Master

systemctl start etcd
systemctl start kube-controller-manager
systemctl start kube-scheduler
systemctl start kube-apiserver

Start-up of the services in each of the nodes

systemctl start docker
systemctl start kube-proxy
systemctl start kubelet

you will notice that a new network interface called docker0 has been created.



POD Configuration

We will create a file in JSON format like the one below. If you remember, in the article Installation and configuration of Dockers (Containers) in Centos 7 we already downloaded the Apache container, so we will use it to configure the POD.

This time, I will start it in the local port 9090, since for the 8080 I have another service listening:

root@Centos7 kubernetes]# docker run -dit -name apachetest -p 9090:80 -v /tmp/ws/:/usr/local/apache2/htdocs/ httpd
7983a74eee23fa59abd434ad5107896e2b2a1a5b9539c5770e6d1c8549eeb060
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7983a74eee23 httpd "httpd-foreground" About a minute ago Up About a minute 0.0.0.0:9090->80/tcp apachetest
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# curl -s http://localhost:9090
<html>
<body>
I'm a container
</body>
</html>
[root@Centos7 kubernetes]#
The JSON file would be as follows:
[root@Centos7 kubernetes]# cat container-httpd-rc.json
{ "kind": "ReplicationController",
"apiVersion": "v1″,
"metadata":{ "name": "apachepod-controller" },
"spec":{
"replicas":3,
"selector":{ "name": "apachepod" },
"template:{
"metadata":{
"labels":{ "name": "apachepod" }
},
"spec":{
"containers:[ {
"name": "apachepod",
"image": "docker.io/httpd",
"ports:[ {
"containerPort":80,
"protocol": "TCP"
} ]
} ]
}
}
}
}
[root@Centos7 kubernetes]#
Next, we apply the settings:
- If we haven't previously created a key, we have to create it for the first time:
[root@Centos7 kubernetes]# openssl genrsa -out /tmp/serviceaccount.key 2048
Generating RSA private key, 2048 bit long modulus
……………………….+++
……………………………………………………+++
e is 65537 (0x10001)

We edit the file /etc/kubernetes/apiserver, adding:

KUBE_API_ARGS="-service_account_key_file=/tmp/serviceaccount.key"
We edit the file /etc/kubernetes/controller-manager, adding:
KUBE_CONTROLLER_MANAGER_ARGS="-service_account_private_key_file=/tmp/serviceaccount.key"

We restart the Kubernetes service:

root@Centos7 kubernetes]# systemctl restart etcd
[root@Centos7 kubernetes]# systemctl restart kube-controller-manager
[root@Centos7 kubernetes]# systemctl restart kube-scheduler
[root@Centos7 kubernetes]# systemctl restart kube-apiserver
[root@Centos7 kubernetes]#

- Once the key is generated, we can finally create our POD from the previously created JSON file:

[root@Centos7 kubernetes]# kubectl create -f container-httpd-rc.json
replicationcontroller "apachepod-controller" created
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl get pod
NAME READY STATUS RESTARTS AGE
apachepod-controller-10xv7 0/1 Pending 0 50s
apachepod-controller-dx8nr 0/1 Pending 0 50s
apachepod-controller-nm5k4 0/1 Pending 0 50s
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl get replicationcontrollers
NAME DESIRED CURRENT READY AGE
apachepod-controller 3 3 0 1m
[root@Centos7 kubernetes]#
If you wish, you can scale the number of PODs in real time:
root@Centos7 kubernetes]# kubectl scale rc apachepod-controller -replicas=4
replicationcontroller "apachepod-controller" scaled
[root@Centos7 kubernetes]# kubectl get replicationcontrollers
NAME DESIRED CURRENT READY AGE
apachepod-controller 4 4 0 2m
[root@Centos7 kubernetes]# kubectl get pod
NAME READY STATUS RESTARTS AGE
apachepod-controller-10xv7 0/1 Pending 0 3m
apachepod-controller-dx8nr 0/1 Pending 0 3m
apachepod-controller-ksrdc 0/1 Pending 0 14s
apachepod-controller-nm5k4 0/1 Pending 0 3m
[root@Centos7 kubernetes]#

Creation of the nodes that will form part of the kubernetes cluster:

[root@Centos7 kubernetes]# cat nodes.json
{
"kind": "Node",
"apiVersion": "v1",
"metadata": {
"name": "10.0.0.2",
"labels: {
"environment: production,
"name": "kubernete1"
}
}
}
{
"kind": "Node",
"apiVersion": "v1",
"metadata": {
"name": "10.0.0.3",
"labels: {
"environment: production,
"name": "kubernete2"
}
}
}
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl create -f nodes.json
node "10.0.0.2" created
node "10.0.0.3" created
[root@Centos7 kubernetes]#

Thursday, April 26, 2018

Two ways to create mksysb images in AIX


1) create on NIM server command: 

nim -o define -t mksysb -a server=master -a source=<server name> -a mk_image=yes -a location=<location of the store image> <mksysb image name> 

This will create the mksysb image of the client server and define it on the NIM server. 

Example: 
nim -o define -t mksysb -a server=master -a source=edppbuslvd01 -a mk_image=yes -a location=/nim/mksysb/edppbuslvd01_6100-04-03-05112010 edppbuslvd01_6100-04-03-05112010 

server=master: server to store image, in this case is master 
source=edppbuslvd01: the source of the image, which is client 
location: the location of the stored mksysb image 


2) create on client machine and then copy to NIM server and define on NIM server, or NFS mount the filesystem from NIM server on the client server. 

let say you successfully NFS mount nim server filesystem on the client machine as /mnt. 

mksysb -ieX /mnt/edppbuslvd01_6100-04-03-05112010 


-e: exclude the filesystem/dir that defined on /etc/exclude.rootvg 
-i: call the mkszfile command to generate the /image.data file 
The /image.data file contains information on volume groups, logical volumes, file systems, paging space, and physical volumes.
 This information is included in the backup for future use by the installation process. 
-X: set to automatically expand the /tmp if necessary 

After the mksysb image created, you need to define it on NIM server. 

nim -o define -t mksysb -a server=master -a location=<image location> <image name>





Wednesday, May 17, 2017

NFSv4 ownership as nobody:nobody

RHEL6.3 and newer NFS clients and servers disable idmapping when utilizing the AUTH_SYS/UNIX authentication flavor by enabling the following booleans:

        NFS client
 # echo 'Y' > /sys/module/nfs/parameters/nfs4_disable_idmapping

NFS server

# echo 'Y' > /sys/module/nfsd/parameters/nfs4_disable_idmapping 

Wednesday, March 22, 2017

AIX unique FCS ID & disk ID (UDID)

Recently I discovered a new switch to lspv command -u. It seems to be available since AIX7 TL1 and AIX6 TL7. Thanks for this switch IBM; I like it very much.
A physical volume (hdisk) to an LPAR can be provided in several ways:
  • without VIOS
    • local physical disk connected to a physical disk SCSI/SAS controller owned by the LPAR
    • SAN disk connected to a physical FC controller
  • with VIOS
    • SAN disk connected to a virtual FC controller
    • a physical disk mapped through a virtual scsi
    • SAN disk mapped through a virtual scsi
    • logical volume on VIOS mapped through a virtual scsi
If you need to know where a specific disk comes from without looking into your documentation (which, indeed, is up to date and precise) or loging in to VIOSes etc, lspv -u helps significantly.
The command switch displays unique id of disks (UDID) and does the same job as the code I was using before, but in a more handy way.
lsdev -Cc disk -F name | while read hdisk; do
  echo ${hdisk},$(odmget -q "name=${hdisk} and attribute=unique_id" CuAt|grep value|cut -d '"' -f2)
done
UDID is build up using a certain logic. I haven't seen the code, but some of the interesting parts are easy to spot:
  • unique_id attribute of an SAS attached hdisk is 2A1135000C500337924AB0BST9146852SS03IBMsas. This ID contains WWNN of the SAS controller (00C500337924AB), disk vendor (IBM), connection type (sas), and also disk model ST9146852SS, which is 146,8GB SAS.
  • unique ID of a logical volume is VGID.sequence_number. For example ID of a third logical volume in a specific VG is 00cc572600004c00000001325d0ab9bd.3.
A few examples of lspv -u outputs with comments on UDID:
  • Locally attached SAS disk
    hdisk0  00cc57264df9dc6b  rootvg  active  2A1135000C500238633030BST9146852SS03IBMsas
  • virtual disk connected via virtual scsi, backed by SAS disk.
    hdisk28  00cc572646f271f9  none  3F2A2A1135000C500337924AB0BST9146852SS03IBMsas05VDASD03AIXvscsi
  • virtual disk connected via virtual scsi, backed by logical volume. Logical volume ID can by identified by a period.
    hdisk0  00cc57265d4534bd  rootvg  active  372200cc572600004c00000001325d0ab9bd.205VDASD03AIXvscsi
  • SAN disk attached via physical or virtual FC. The disk comes from a DS8100 disk array identified as 75BBXM1. Volume ID of the disk in DS8100 is 180D.
    hdisk39  00cc5726aaa9e19e  testvg  active  200B75BBXM1180D07210790003IBMfcp
  • virtual disk connected via virtual scsi, backed by SAN disk. The disk comes from a DS8300 disk array identified as 75YY981. Volume ID of the disk in DS8300 is 0501.
    hdisk2  00cc57260b6d4ca6  rootvg  active  3520200B75YY981050107210790003IBMfcp05VDASD03AIXvscsi
I trimmed the output slightly to fit on screen better. In fact lspv -u show one more column on right with a long string of unknown purpose.
Since disk unique id is in ODM, it can help you solve an issue, when you unmap a disk from a system on either VIOS or a storage by mistake and you want to put it back asap; lspv -u helps you to identify the disk, unless you perform rmdev -dl on that disk.
Didn't find your lspv -u output in the examples above? Leave a comment!


Two ways to create mksysb images in AIX

1) create on NIM server command: 

nim -o define -t mksysb -a server=master -a source=<server name> -a mk_image=yes -a location=<location of the store image> <mksysb image name> 

This will create the mksysb image of the client server and define it on the NIM server. 

Example: 
nim -o define -t mksysb -a server=master -a source=edppbuslvd01 -a mk_image=yes -a location=/nim/mksysb/edppbuslvd01_6100-04-03-05112010 edppbuslvd01_6100-04-03-05112010 

server=master: server to store image, in this case is master 
source=edppbuslvd01: the source of the image, which is client 
location: the location of the stored mksysb image 


2) create on client machine and then copy to NIM server and define on NIM server, or NFS mount the filesystem from NIM server on the client server. 

let say you successfully NFS mount nim server filesystem on the client machine as /mnt. 

mksysb -ieX /mnt/edppbuslvd01_6100-04-03-05112010 


-e: exclude the filesystem/dir that defined on /etc/exclude.rootvg 
-i: call the mkszfile command to generate the /image.data file 
The /image.data file contains information on volume groups, logical volumes, file systems, paging space, and physical volumes.
 This information is included in the backup for future use by the installation process. 
-X: set to automatically expand the /tmp if necessary 

After the mksysb image created, you need to define it on NIM server. 

nim -o define -t mksysb -a server=master -a location=<image location> <image name>