How to do the mount and check the NFS server shared from Linux client

Here is some major commands to mount to NFS server from a client:

sudo apt-get install cifs-utils

sudo mkdir /media/temp

change your /etc/fstab file to let it mount on boot up

//nfsserver/temp /media/temp cifs guest,uid=1000,iocharset=utf8 0 0

then can use

mount -a

to do a manually mount

And here is how to check waht folder avaliable from a server to be mounted? and what address they permitted?

sudo apt install nfs-common
showmount -e 10.1.1.22

Export list for 10.1.1.22:
/volume1/shared 10.1.1.0/24
/volume1/SW 10.1.1.156
/volume1/backup 10.1.1.0/24

 

Advertisements

Build NAT for Vmware Esxi with pfSense

By default, Vmware Esxi hyper-visor doe not support NAT, it only gives bridge to the guest VMs to get the network address. So when you do not have enough DHCP resources to assign to many VMs in your network, NAT will be a option to let the VMs can share IP resources and also let outside can access VMs.

Here is some links I refereed when I did our Esxi + pfSense servers reconfiguration recently.

https://doc.pfsense.org/index.php/PfSense_on_VMware_vSphere_/_ESXi

http://blog.romant.net/technology/configuring-nat-on-esx-and-esxi/

https://sxkdz.org/vmware-esxi-and-pfsense-router-deploy/

https://www.jsnowcreations.com/guides/computer-guides/setup-steps-for-single-nic-hetzner-root-server-running-esxi-with-pfsense-router/

And I note down some points you need to pay attention when doing this , my cases are in the 5.1 and 5,5 version Esxi:

1. If you only have one physical NIC running (vmnic0), then you need one IP for VMware Management Interface,  and another IP for pfSense WAN interface, these two IP running at same NIC interface. So two IPs face to outside is minimum for NAT even in one NIC case.

2. vSwitch0 is used by VMs by default, and your new created switch group (not binding to any NIC) will be vSwitch1. So normally pfSense will have two virtual network interface: WAN binding to the vSwitch0 and LAN binding to the vSwitch1 to work as the NAT gateway.

3. After you have the pfSense running, assign some VMs to the LAN and you then can surf from LAN VM to the pfSense LAN interface (LAN gateway)’s http admin UI to manage the pfSense,  with default account admin/pfsense. You need to have basic firewall and LAN gateway knowledge to manage this gateway.

4. To let outside client to access the VM, you need to config the NAT port forwarding at the pfSense WAN interface. And also pay attention to the default check box of the firewall policy to let the 10.****, 198.*****, 172**** can access the your VM if you need it.

4. For the flexibility of the system pfSense WAN MAC can be changed, but not LAN side. you may need a reboot of the pfSense when you change the WAN MAC.

Spring boot actuator – system monitoring and management

I am using the 1.5.10 as the example, detailed docs can see at here:

https://docs.spring.io/spring-boot/docs/1.5.10.RELEASE/reference/html/production-ready.html

1. Just add starter-actuator to maven

<!– for logging and minitoring =============================== –>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2. Restart and suppose my app running at the 8080 port, you can see the actuator works at http://localhost:8080/health

{
  "status" : "UP",
  "diskSpace" : {
    "status" : "UP",
    "total" : 217631211520,
    "free" : 20183724032,
    "threshold" : 10485760
  },
  "rabbit" : {
    "status" : "UP",
    "version" : "3.5.7"
  },
  "db" : {
    "status" : "UP",
    "database" : "MySQL",
    "hello" : 1
  }
}

actuator gives you a lot data about your system, such as metrics, health, configuration, http trace ….FULL list can see from here ID List

3. Some ID will be blocked by spring security if your system using it. So you have to authenticate and get the token or get the role to access them. But if system is behind a firewall, you can disable the security for actuator. Let us change the actuator to running in a different port and using new path root to access it. Add these into the application.properties file:

management.port = 9091
management.address = 127.0.0.1
management.security.enabled=false
management.context-path=/manage
endpoints.jmx.enabled=false

So we can access http://localhost:9091/manage/health  now to get data.

4. Based on actuator feature, you can monitor and manage the system performance and health,  logging, and many others.  And use actuator API to process data by your self.

5. There are some GUI feature has been done based on the actuator already. like this one:

spring-boot-admin

Try to use it for your system!

 

 

 

 

 

 

 

RabbitMQ quick start for Spring Boot

  1. Install the rabbitmq
sudo apt-get update
sudo apt-get install rabbitmq-server
sudo service rabbitmq-server stop
sudo service rabbitmq-server start
sudo service rabbitmq-server status
sudo rabbitmqctl status

cat /proc/$RABBITMQ_BEAM_PROCESS_PID/limits

The broker always appends to the log files, so a complete log history is retained.

/var/log/rabbitmq directory.
See /etc/logrotate.d/rabbitmq-server to configure logrotate.

The rabbbitMQ will run at port localhost:5672

 

2. Let us build a Spring Boot project to make MQ work.

2.1  Download the spring boot sample project from https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-amqp.

remember to change pom.xml parent as this:

 <parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>1.5.10.RELEASE</version>
 <relativePath /> <!-- lookup parent from repository -->
 </parent>

 

2.2 Use eclipse to import this maven project. and use “java -jar” run it, you will see it continuously say hello.

2.3 The code use following tricks:

a. @EnableScheduling and @Scheduled(fixedDelay = 1000L)  will make the app auto start a Schedule task every 1 second and call the send() method to send a msg “hello” to the MQ queue “foo”:

@RabbitListener(queues = "foo")

defines a mq listener to listen to the queue of “foo”.

b. When a msg is in the queue, this method

@RabbitHandler
 public void process(@Payload String foo) { ...}

will be triggered to process the msg got in this queue, code just prints it our in stdout.

c. the method fooQueue must names as the fooQueue as the queue name in this example is “foo”.

public Queue fooQueue() {...}

d. This code:

 @Autowired
 private RabbitTemplate rabbitTemplate;

Will auto get a connection from the RabbitMQ so it can do the send later for you.

 

3. Access RabbitMQ GUI to make simple management

Enable the rabbitmq_management module:

sudo rabbitmq-plugins enable rabbitmq_management

The Web UI is located at: http://server-name:15672/
The user “guest” is created with password “guest” by default.

 

 

 

 

 

 

 

 

 

Start from Vagrant – create your own VM Box

Here I will create a ubuntu 16 64bit server image. for which altas link in fact have issue some times. So we create from ubuntu cloud image directly:

https://cloud-images.ubuntu.com/xenial/current/

After you get where is the URL for xenial-server-cloudimg-amd64-vagrant.box, then we can use this cmd to do things.

vagrant init boxname boxurl

vagrant init ubuntu/xenial64 https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-vagrant.box
less Vagrantfile
vagrant up
vagrant ssh

Then you install anything you want to customize your linux VM.
After every thing ready, just exit from your VM.  Shutdown it and pack as a new box.

vagrant halt
vagrant package --output newU64.box

So you will get a new box named as newU64.box. Now you can release this box to team and they can use init command to create a VM at their local folder.

 

To make your new box smaller, there are some command you can use. see this article for details:

https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one#toc-add-the-box-into-your-vagrant-install

 

 

 

 

 

 

 

Start from Vagrant – install and up

This is a simple demo how to install the vagrant in the Ubuntu Linux

Install virtualbox

sudo apt-get install virtualbox

Install vagrant

sudo apt-get update
sudo apt-get install vagrant
vagrant version

Create a Vagrantfile from default category list

https://app.vagrantup.com/boxes/search

mkdir ~/vagrant
cd ~/vagrant
vagrant init hashicorp/precise64
less Vagrantfilevagrant up
vagrant ssh

To turn your VM on, navigate to the directory with your Vagrantfile:

vagrant up

To pause your VM, navigate to the directory with your Vagrantfile:

vagrant suspend

To turn your VM off, navigate to the directory with your Vagrantfile:

vagrant halt

To destroy your VM, navigate to the directory with your Vagrantfile:

vagrant destroy

Linux command check CPU IO and VM info

  • Check the CPU utilize rate and disk IO info
$ iostat
Linux 4.4.0-103-generic (xw-HP-Z420-Workstation) 02/02/2018 _x86_64_ (12 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
 0.17 0.00 0.03 0.01 0.00 99.78

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 1.73 15.20 18.99 3663865 4578881
sdb 0.00 0.03 0.00 6317 56
  • Virtual memory info
$ vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r b swpd free buff cache si so bi bo in cs us sy id wa st
 0 0 0 21497140 917372 3875112 0 0 1 2 5 3 0 0 100 0 0
 0 0 0 21497336 917376 3875112 0 0 0 172 577 2320 2 0 98 0 0
 0 0 0 21497196 917376 3875112 0 0 0 0 553 2380 3 0 97 0 0
 0 0 0 21497336 917376 3875116 0 0 0 8 553 2432 2 0 97 0 0
 0 0 0 21497336 917376 3875112 0 0 0 0 490 2173 2 0 97 0 0
  • check kernel and driver’s log
dmesg