1. Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit
1 2 3 4
root@stan-virtual-machine:~# file /sbin/init /sbin/init: symbolic link to /lib/systemd/systemd root@stan-virtual-machine:~# file /lib/systemd/systemd /lib/systemd/systemd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=03b9d43299696aa6b67b92f1225fa6045b978cb2, stripped
2. Check if you have Java installed on your system
1 2 3 4 5 6 7 8 9
root@stan-virtual-machine:~# java -version The program 'java' can be found in the following packages: * default-jre * gcj-5-jre-headless * openjdk-8-jre-headless * gcj-4.8-jre-headless * gcj-4.9-jre-headless * openjdk-9-jre-headless Try: apt install <selected package>
3. Completely remove the OpenJDK/JRE from your system and create a directory to hold your Oracle Java JDK/JRE binaries.
# tar xvzf jdk-8u101-linux-x64.tar.gz # vim /etc/profile #add into end of the file JAVA_HOME=/usr/local/java/jdk1.8.0_101 JRE_HOME=$JAVA_HOME/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME export JRE_HOME export PATH
<body> <h1>Welcome to <strong>nginx</strong> on EPEL!</h1>
<div class="content"> <p>This page is used to test the proper operation of the <strong>nginx</strong> HTTP server after it has been installed. If you can read this page, it means that the web server installed at this site is working properly.</p>
<div class="alert"> <h2>Website Administrator</h2> <div class="content"> <p>This is the default <tt>index.html</tt> page that is distributed with <strong>nginx</strong> on EPEL. It is located in <tt>/usr/share/nginx/html</tt>.</p>
<p>You should now put your content in a location of your choice and edit the <tt>root</tt> configuration directive in the <strong>nginx</strong> configuration file <tt>/etc/nginx/nginx.conf</tt>.</p>
[root@toad salt]# salt '*' state.sls upload_data
salt-minion01:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Error encountered while render pillar top file.
macadamina:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Error encountered while render pillar top file.
Fix 01:
[root@toad salt]# salt "*" saltutil.refresh_pillar
macadamina:
True
salt-minion01:
True
copy the file form master to minion: [root@toad salt]# salt ‘macadamina’ cp.get_file salt://files/zfgtai.zip /deploy/source/aofa_pro/zfgtai.zip macadamina: /deploy/source/aofa_pro/zfgtai.zip
# mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup # vim /etc/dnsmasq.conf
interface=eth0,lo #bind-interfaces domain=centos6.lan # DHCP range-leases dhcp-range= eth0,192.168.0.3,192.168.0.253,255.255.255.0,1h # PXE dhcp-boot=pxelinux.0,pxeserver,192.168.0.132 # Gateway dhcp-option=3,192.168.0.1 # DNS dhcp-option=6,192.168.0.1, 8.8.8.8 server=8.8.4.4 # Broadcast Address dhcp-option=28,192.168.0.255 # NTP Server dhcp-option=42,0.0.0.0 pxe-prompt="Press F8 for menu.", 60 pxe-service=x86PC, "Install CentOS 6 from network server 192.168.0.132", pxelinux enable-tftp tftp-root=/var/lib/tftpboot
interface – Interfaces that the server should listen and provide services.
bind-interfaces – Uncomment to bind only on this interface.
domain – Replace it with your domain name.
dhcp-range – Replace it with IP range defined by your network mask on this segment.
dhcp-boot – Replace the IP statement with your interface IP Address.
dhcp-option=3,192.168.0.1 – Replace the IP Address with your network segment Gateway.
dhcp-option=6,92.168.0.1 – Replace the IP Address with your DNS Server IP – several DNS IPs can be defined.
server=8.8.4.4 – Put your DNS forwarders IPs Addresses.
dhcp-option=28,192.168.0.255 – Replace the IP Address with network broadcast address –optionally.
dhcp-option=42,0.0.0.0 – Put your network time servers – optionally (0.0.0.0 Address is for self-reference).
pxe-prompt – Leave it as default – means to hit F8 key for entering menu 60 with seconds wait time..
pxe=service – Use x86PC for 32-bit/64-bit architectures and enter a menu description prompt under string quotes. Other values types can be: PC98, IA64EFI, Alpha, Arcx86, IntelLeanClient, IA32EFI, BCEFI, XscaleEFI and X86-64EFI.
enable-tftp – Enables the build-in TFTP server.
tftp-root – Use /var/lib/tftpboot – the location for all netbooting files.
read more dnsmasq manual
STEP 2: INSTALL SYSLINUX BOOTLOADERS
1 2
# yum install syslinux # ls /usr/share/syslinux
STEP 3: INSTALL TFTP-SERVER AND POPULATE IT WITH SYSLINUX BOOTLOADERS
Typically the PXE Server reads its configuration from a group of specific files (GUID files – first, MAC files – next, Default file – last) hosted in a folder called pxelinux.cfg, which must be located in the directory specified in tftp-root statement from DNSMASQ main configuration file.
# vim /var/ftp/ks.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="ftp://192.168.0.132/pub" # Root password rootpw --iscrypted $1$MzJZISZ7$wX0pW3sFy/5y80l2BAQD81 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install #graphical text
%include /tmp/network.ks
firstboot --disable # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --disabled # Installation logging level logging --level=info # Reboot after installation #reboot # System timezone timezone Australia/Sydney # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --asprimary --fstype="ext4" --size=250 part swap --asprimary --fstype="swap" --size=1024 part / --asprimary --fstype="ext4" --grow --size=1
#vim /var/ftp/pub/install_mysql groupadd mysql useradd -s /sbin/nologin -g mysql -M mysql tail -1 /etc/passwd id mysql # setup the tar file download add wget ftp://192.168.0.134/pub/mysql-5.5.50-linux2.6-x86_64.tar.gz tar xf mysql-5.5.50-linux2.6-x86_64.tar.gz mkdir -p /application/ mv mysql-5.5.50-linux2.6-x86_64 /application/mysql-5.5.50 ln -s /application/mysql-5.5.50/ /application/mysql ls -l /application/ cd /application/mysql/ ls -l support-files/*.cnf /bin/cp support-files/my-medium.cnf /etc/my.cnf mkdir -p /application/mysql/data chown -R mysql.mysql /application/mysql/ /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql /bin/cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
/etc/init.d/mysqld start netstat -lntup|grep mysql
chkconfig --add mysqld chkconfig mysqld on chkconfig --list mysqld
echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile tail -1 /etc/profile source /etc/profile echo $PATH # after install run the following command #/application/mysql/bin/mysql_secure_installation
[root@ip-172-31-5-191 ~]# nohup sleep 1000 & [1] 19786 [root@ip-172-31-5-191 ~]# nohup: ignoring input and appending output to ‘nohup.out’
Bash Shell Variables
Put variable into the file /etc/environment
Another very important rule is that a child process will never be able to change the parent’s environment variables, because the child and parent are independent from each other and the child only has a local copy of the parent’s environment:
[root@ip-172-31-5-191 ~]# say_hello() { > echo "My name is $1"; > }
[root@ip-172-31-5-191 ~]# say_hello Stan My name is Stan [root@ip-172-31-5-191 ~]# say_another_thing() { > say_hello Stan > echo "I like CentOS 7"; > }
[root@ip-172-31-5-191 ~]# say_another_thing My name is Stan I like CentOS 7
[root@ip-172-31-5-191 ~]# PASSWORD="tt4321" [root@ip-172-31-5-191 ~]# if [[ $PASSWORD -eq "hello_world" || $PASSWORD -eq "tt4321" ]]; then echo "password correct"; fi password correct
if
1 2 3 4 5 6 7 8 9
if [[ $EXIT -eq 0 ]] if ! [[ $EXIT -eq 0 ]] if [[ $PASSWORD == "Hello_world" ]] if [[ $PASSWORD -eq "hello_world" || $PASSWORD -eq "tt4321" ]]
STRING="Lorem ipsum dolor sit" if [[ $STRING =~ ^..rem ]] if [[ $NUMBER -lt 10 ]] ##-lt less than if [[ $NUMBER -gt 10 ]] ##-gt greater than
file or diri tests
1 2
if [[ -a $FILE ]] if [[ -d $DIR ]]
for read the bash manual man bash /CONDITIONAL EXPRESSIONS
else statement
1 2 3 4 5 6
if [[ $EXIT -eq 0 ]] then echo "whatever" else echo "cannot access the files" fi
if elif statement
1 2 3 4 5 6 7 8 9 10
if [[ $VALUE -gt 5 ]] then echo "value is bigger than 5" elif [[ $VALUE -eq 5 ]] then echo "value is equal to 5" elif [[ $VALUE -lt 5 ]] then echo "value is less than 5" fi
Loops statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14
for count in 1 2 3 4 do echo $count done
for number in $(seq 1 20) do echo "This is $number" done
for number in {1..20} do echo "This is $number" done
change multi file names
1 2 3 4 5 6
mkdir ~/stuff touch ~/stuff/1.txt ~/stuff/2.txt ~/stuff/3.txt ~/stuff/4.txt ~/stuff/5.txt for file in ~/stuff/*.txt do mv $file ~/stuff/$(basename $file .txt).doc done
for dbname in $DATABASE do MYDIR=/backup/mysql/$dbname [ ! -d $MYDIR ] && mkdir -p $MYDIR $MYDUMP $dbname|gzip >$MYDIR/${dbname}_$(date +%F).sql.gz done
Output:
1 2 3 4 5 6 7 8 9 10
[root@aofa-staging backup]# tree mysql mysql ├── allyoubank │ └── allyoubank_2016-08-28.sql.gz ├── test │ └── test_2016-08-28.sql.gz └── wgzy └── wgzy_2016-08-28.sql.gz
# vim /etc/backup/backupwk.sh #!/bin/bash # ==================================================================== # user input backup location # basedir=backup dir basedir=/backup/weekly
# backup folders #named=$basedir/named #postfixd=$basedir/postfix #vsftpd=$basedir/vsftp sshd=$basedir/ssh #sambad=$basedir/samba wwwd=$basedir/wwwd #others=$basedir/others userinfod=$basedir/userinfo # check if the file exists, if didn't create a dir for dirs in $sshd $wwwd $userinfod do [ ! -d "$dirs" ] && mkdir -p $dirs done
# 1. service config file #cp -a /var/named/chroot/{etc,var} $named #cp -a /etc/postfix /etc/dovecot.conf $postfixd #cp -a /etc/vsftpd/* $vsftpd cp -a /etc/ssh/* $sshd #cp -a /etc/samba/* $sambad cp -a /etc/my.cnf $wwwd cp -a /application/nginx/conf/nginx.conf $wwwd
cd /application tar -jpc -f $wwwd/tomcat.tar.bz2 tomcat tar -jpc -f $wwwd/nginx.tar.bz2 nginx
# 2. about user par cp -a /etc/{passwd,shadow,group} $userinfod cd /var/spool tar -jpc -f $userinfod/mail.tar.bz2 mail cd /var/spool tar -jpc -f $userinfod/cron.tar.bz2 cron at
Every Sun 3.30 run weekly backup script:
1 2
# vim /etc/crontab 30 3 * * 0 root /backup/backupwk.sh