pxe server configuration on centos 7 to bootup debian 8




In centos 7 (PXE  server)
Tested on virtualbox 5.1.24
Make sure below network card settings other wise fatal error:cannot read from boot medium is seen


Steps:1

mkdir /downloads
yum install epel-release rsync tcpdump wget curl vim httpd xinetd syslinux tftp-server -y
cd /usr/share/syslinux/
cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/
cp /etc/xinetd.d/tftp /downloads/
sed -i 's/yes/no/g' /etc/xinetd.d/tftp
mkdir -p /downloads/netboot
cd /downloads &&  wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/netboot.tar.gz
mkdir -p /downloads/netboot
tar xvfz netboot.tar.gz -C /downloads/netboot/
rsync -avz /downloads/netboot/debian-installer /var/lib/tftpboot/
mkdir /var/lib/tftpboot/debian8

#cp -fr /mnt/debian8isomount /var/lib/tftpboot/debian8
cp -rf /mnt/* /var/lib/tftpboot/debian-installer/amd64/

#Then, create a configuration directory for PXE server:

mkdir /var/lib/tftpboot/pxelinux.cfg

#Now, create PXE server configuration file under the pxelinux.cfg:

vim /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

label 1
menu label ^1) Install Debian 8 x64
kernel debian-installer/amd64/linux
append vga=788 initrd=debian-installer/amd64/initrd.gz -- quiet

label 2
menu label ^2) Install Debian 8 x64 Automated
kernel debian-installer/amd64/linux
append auto=true priority=critical vga=788 initrd=debian-installer/amd64/initrd.gz -- quiet

label 3
menu label ^3) Boot from local drive localboot

find default ip used for connection

ip route list

ip route get 8.8.8.8

# ip route get 8.8.8.8
8.8.8.8 via 100.126.1.1 dev eth0  src 100.126.1.100
    cache  mtu 1500 advmss 1460 hoplimit 64

# ip route list      
100.126.1.0/24 dev eth0  proto kernel  scope link  src 100.126.1.100
192.168.2.0/24 dev eth1  proto kernel  scope link  src 192.168.2.1
10.0.2.0/23 dev eth1  proto kernel  scope link  src 10.0.2.8
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 100.126.1.1 dev eth0 

part 6 docker from development to production

docker run --name coolwordpress -v /host/directory:/container/directory --link  anothermysqlCnt:mysql -e WORDPRESS_DB_PASSWORD=p@ssw0rD -d -p 8080:80  wordpress:4.6.1-apache

Import and export CSV file into MySQL Table


Clean up csv for file like below

    "Email"
    "abc@exammle.com"
    "xyz@kdjfi.com.np"
    "oioi@uyii.net"
    ...  ## note not commas and carriage returns because csv was imported from windows os

move the files to /var/lib/mysql-files  directory 

sed -i  's/$/,/g'  Aggregate-SentList-Introduction.csv 

sed -i  's/\r//g'  Aggregate-SentList-Introduction.csv 

First of all create necessary table for example `table name = gel `

mysql> create table gel(email VARCHAR(255));

Now import the csv file 

mysql> LOAD DATA LOCAL INFILE '/home/user1/Desktop/temporary/gel.csv'
INTO TABLE store.gel
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

ignoring 1st row because it contained the column name for example

"Email List"
"jack@example.com"
"jill@abc.com"
"wfpk@unitki.com"
....
...

mysql> LOAD DATA LOCAL INFILE '/home/user1/Desktop/temporary/sentlog1.csv'  INTO TABLE store.sent1  FIELDS TERMINATED BY ','  ENCLOSED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 ROWS;
Query OK, 3376 rows affected (0.66 sec)
Records: 3376  Deleted: 0  Skipped: 0  Warnings: 0

mysql> LOAD DATA LOCAL INFILE '/home/user1/Desktop/temporary/sentlog2.csv'  INTO TABLE store.sent2  FIELDS TERMINATED BY ','  ENCLOSED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 ROWS;
Query OK, 8732 rows affected (1.71 sec)
Records: 8732  Deleted: 0  Skipped: 0  Warnings:


EXPORT sql select result

mysql> SELECT email FROM blocks WHERE email NOT IN (select mail from `TABLE 2`) INTO OUTFILE '/var/lib/mysql-files/filteredaug24.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Query OK, 67782 rows affected (0.62 sec)
If file exist then it will give error you need to remove it first

Useful query
SELECT emails FROM sent
LEFT JOIN blocks ON sent.emails=blocks.email
WHERE blocks.email IS NULL;

OR

SELECT emails FROM sent
WHERE emails NOT IN ( select email from blocks )
INTO OUTFILE '/var/lib/mysql-files/filteredaug24-5.csv'  LINES TERMINATED BY '\n' ;

nginx micro caching

What we wanted to achieve in our test configuration was to have a URL like:
http://www.example.com/image/<width>x<height>/<URL>
...that would retrieve the image at:
https://upload.wikimedia.org/<URL>
...then resize it on the fly, cache it and serve it.
Our setup ended up being almost the same as the one in that blog post, with some slight differences.
Requirements installation

First, as the post points out, the Image Filter module is not installed by default on many Linux distributions. As we're using Nginx's official repositories, it was just a matter of installing the nginx_module_image_filter package and restarting the service.
Cache Storage configuration

Continuing following the post's great instructions, we set up the cache in our main http section, tuning each parameter to fit ur specific needs. We wanted a 10MB storage space for keys and 100MB for actual images, that will be removed after not being accessed for 40 days. The main configuration entry was then:

proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=nginx_cache:10M max_size=100M inactive=40d;

This went straight in the http section of nginx.conf.
Caching Proxy configuration

Next, we configured our front facing virtual host. In our case, we needed the reverse proxy to live within an already existing site, and that's why we chose the /image/ path prefix.

server {
      ...
 
      location /image/ {
          proxy_pass http://127.0.0.1:20000;
          proxy_cache nginx_cache;
          proxy_cache_key "$proxy_host$uri$is_args$args";
      }
 
      location / {
          # other locations we may need for the site.
          root /var/www/whatever;
      }
 
  }


Every URL starting with /image/ would be server from the cache if present, otherwise it would be proxied to our Resizing Server, and cached for 30 days, as desired.
Resizing Server configuration

We then configured the resizing server, using a regexp to extract the width, height and URL of the image we desire.
The server will proxy the request to https://upload.wikimedia.org/ looking for the image, resize it and then serve it back to the Caching Proxy. We preferred to keep it simple and tidy, as we didn't actually need any aws-related configuration as the blog post did.


Note that we may also use image_filter resize and crop options, should we need different results than just resizing.
Testing the final result

You should now be able to fire up your browser and access an URL like:

http://www.example.com/image/150x150/wikipedia/commons/0/01/Tiger.25.jpg



...and enjoy your caching, resizing, reverse proxying image server.
Optionally securing access to your image server

As this was not a public server, we didn't use any security mechanism to validate the request.
The original blog post, though, reports a very simple and clever way to prevent abuse from unauthorized access, using the Secure Link module.
To access your server you will now need to add an auth parameter to the request, with a secure token that can be easily calculated as an MD5 hash.
This is the simple Bash command we used to test it:
1
echo -n '/image/150x150/wikipedia/commons/0/01/Tiger.25.jpg your_secret' | openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =


.and the resulting URL would be:
http://www.example.com/image/150x150/wikipedia/commons/0/01/Tiger.25.jpg?auth=TwcXg954Rhkjt1RK8IO4jA

http://blog.endpoint.com/2016/05/caching-resizing-reverse-proxying-image-server-nginx.html

jenkins reset password

edit /var/lib/jenkins/users/username/config.xml

<password> replace below string </password>

#jbcrypt:$2a$10$razd3L1aXndFfBNHO95aj.IVrFydsxkcQCcLmujmFQzll3hcUrY7S

password= test

Delete common rows between tables


tableA                                                        
apple@gmail.com
ram@gmail.com
user@hotmail.com
jai@qqmail.com
bai@example.com

tableB
ram@gmail.com
jai@qqmail.com

Query

delete
    from tableA
where exists
  ( select 1 
         from tableB
          where email = tableA.email )

Resulting table tableA  where common item from tableB is deleted: 

TableA
apple@gmail.com
user@hotmail.com
bai@example.com

part 5 dockerizing simple flask application and docker exec

### vim Dockerfile

FROM python:3.5
RUN pip install  Flask==0.11.1
RUN useradd -ms /bin/bash admin
USER admin
WORKDIR /app
COPY app /app
CMD ["python", "app.py"]

###

docker build -t urgen/dockerapp:1.01

docker images   <copy imageid>

docker run -d -p 5000:8080

    -d = run container in background
    -p = expose port
    5000 = port of container
    8080 = port of real host


user1@localhost ~ $ docker run -d -i -t busybox
8ba73738bf52630e31106be2f3a1cb4d4e0ab8f79d311f38c6ec8ff5ce7eba24

# to docker exec the container must be running in background (-d option)
docker exec -it 8ba73738bf52630e31106be2f3a1cb4d4e0ab8f79d311f38c6ec8ff5ce7eba24  sh

part 4 push docker image to docker hub public

1) docker images  ## list images

docker tag  <image id>  <docker hub repositoryname>:<tag>

2) docker tag  c75bebcdd211 urgensherpa2/box1:1.01

docker login --username=urgensherpa2
password:
Login succeed

3) docker push urgensherpa2/box1:1.01

part 4 docker automate building images

Build docker images

   docker file - is text doc that contains all the instructions to assemble the image

By default the filename is "Dockerfile" where we put all the instructions

cd /home/user1/

# vim Dockerfile
FROM debian:jessie
RUN apt-get update
RUN apt-get install -y git vim rsync
COPY localfile.txt  /src/localfile.txt   ##copy local file to containers /src/ directory ..look ADD command too!

docker build -t repositoryname:tag .


docker build -t vieux/apache:2.0 .

docker build -t urgen/dockerfiledemo -f Dockerfile /home/user1/

docker build -t urgen/dockerfiledemo -f customdockerfilemame /home/user1/

OR

docker build -t ubuntu:latest .

    --tag, -t  = Name and optionally a tag in the ‘name:tag’ format
    --file, -f = Name of the Dockerfile (Default is ‘PATH/Dockerfile’)


in screenshot "Dockerfile" is saved at /home/user1/docker directory