• Install DenyHosts on Linux VPS

    #!/bin/bash
    PKG_VER=2.10
    PKG_DIR=denyhosts-${PKG_VER}
    PKG_TAR=${PKG_DIR}.tar.gz
    PKG_URL=https://sourceforge.net/projects/denyhosts/files/denyhosts/${PKG_VER}

    rm ${PKG_TAR}
    rm -rf ${PKG_DIR}
    wget –no-check-certificate  ${PKG_URL}/${PKG_TAR}
    tar xvfz ${PKG_TAR}

    sudo mv ${PKG_DIR}/ /usr/share/denyhosts

    cd /usr/share/denyhosts/
    sudo cp denyhosts.conf /etc

    CFG=/etc/denyhosts.conf
    sudo sed -i “s/DENY_THRESHOLD_ROOT = 1/DENY_THRESHOLD_ROOT = 8/” ${CFG}
    sudo sed -i “s/ADMIN_EMAIL = root@localhost/ADMIN_EMAIL = /” ${CFG}

    sudo cp denyhosts.py /usr/sbin/denyhosts
    sudo mv daemon-control-dist daemon-control

    cd /etc/init.d
    sudo ln -s /usr/share/denyhosts/daemon-control denyhosts
    sudo touch /var/log/auth.log
    sudo update-rc.d denyhosts start
    sudo /etc/init.d/denyhosts start

     

     

  • iLO4 2.78

    The iLO4 2.78  (2021/05/07) of HP MicroServer Gen:

    HTML5 Integrated Remote Console

    The HTML5 IRC provides remote access to the system KVM and control of Virtual Media from a single console that runs in a supported browser.
     

     

     

  • mysql server with GTID log-bin

    Mysql Master Server:

         ARGU+=” –gtid-mode=ON “
         ARGU+=” –enforce-gtid-consistency=TRUE “
         ARGU+=” –log-slave-updates=FALSE “
         ARGU+=” –log-bin=/opt/local/data/mysqld/mysql-bin “

     

    Mysql Slave Server:

         ARGU+=” –relay_log=/opt/local/data/mysqld/relay-bin “
         ARGU+=” –read_only=on “
         ARGU+=” –skip_slave_start=on “

     

    Launch Mysl Server:

          mysqld     ${ARGU}     ${OTHER_ARGU} 

    Display Master Status:
           mysql>  show master status;

    Display Master Status:
          mysql>  show slave status;

    Display uuid:
          mysql>  show GLOBAL VARIABLES like ‘server_uuid’;

    Display gtid variable:
          mysql>  mysql> show variables like ‘%gtid%’;

     

     

     

     

     

  • Config NUT for CyberPower VAL600 UPS with TrueNAS Core 12.0-U6

         Master NAS,   PC/TrueNAS Core attached with UPS USB Cable

    • Step 1:   Power on the Cyberpower VAL600 & plug the USB cable into TrueNas system

    • Step 2:   Find out UPS port information, say ugen3.0

    TrueNAS Web Gui / System/Advance/Show Console Message

    • Step 3:   Config with the UPS

    TrueNAS Web Gui / Services/UPS

    UPS Mode:  Master

    Remote Monitor:    Enable

    Monitor User:      upsmon

    Monitor Password:   Your Passwrod

    Driver:  Cyber Power System ups2 Value 600E USB

    Port or Hostname:   /dev/ugen0.3auto

    Shutdown Command:  shutdown -h now

    • Step 4:  Check with command upsc ups@localhost

    TrueNAS Web Gui / Shell

    • Step 5:   Verify shutdown command is working by turn off the AC power supplier of UPS

         Slave NAS:    PC/TrueNAS Core not  attached with UPS USB Cable

    • Step 6:Config TrueNAS PC as NUT Salve

    UPS Mode:     Slave

    Remote Host:   IP of Master NAS

    Remote Port:    3493

    Port or Hostname:  auto

    Monitor User:     upsmon

    Monitor Password:    Same as Master UPS

    Shutdown command:     shutdown -h now

         Slave Linux:    PC/Linux not  attached with UPS USB Cable

    • Step 7: Config Linux PC as NUT slave

    Install NUT

    Config upsmon as following

    POWERDOWNFLAG /etc/nut/killpower
                   MONITOR ups@MASTER_UPS_IP 1  upsmon YOUR_PASSWORD  slave
                   MINSUPPLIES 1
                   SHUTDOWNCMD “/sbin/shutdown -h +0”

                   POLLFREQ 5
                   POLLFREQALERT 5
                   HOSTSYNC 15
                   DEADTIME 15
                   RBWARNTIME 43200
                   NOCOMMWARNTIME 300
                   FINALDELAY 5

    Launch upsmon service

    Note:

    TrueNAS Core only support  UPS On Battery Action

  • Using CyberPower UPS to keep NAS data safety

    The CyberPower VALUE600ELCD UPS is supported by NUT, it can be used to switch off the NAS and computer system when main power fail, for the purpose to keep data and disk safety.

     

    NUT,  Network UPS Tools

    A suite of open source software component designed for UPS

     

    Architect of NUT:   

    Kernel:                USB HID Class driver

    User Space:       Three linux daemon design

    Driver Daemon:  usbhid_ups,   usb hid based protocol

    upsd Daemon:   API for client, including upsmon

    upsmon Daemon:   monit events from UPSD, and action by launch the pre-defined script

     

    Install NUT under ubuntu or debian:

    sudo apt-get install -y nut

     

    NUT Config  for CyberPower VALUE600ELCD

    Modify 4 config file in /etc/nut, by adding following lines

    nut.conf:

        MODE=standalone

     

    ups.conf
       [cyberpower]
         driver = usbhid-ups
         port = auto
         desc = “CP1500 AVR UPS”
         offdelay = 20
         ondelay = 0
         ignorelb
         override.battery.charge.low = 20
         override.battery.charge.warning = 40
         pollinterval = 15

    upsd.conf

        [admin]
             password = 123456
             actions = SET
             instcmds = ALL

       [upsmonuser]
            password = 123456
            upsmon master

    upsmon.conf

          MONITOR cyberpower@localhost 1 upsmon 123456 master

     

     

    • Start  or Stop   NUT driver :

                 sudo upsdrvctl start

                 sudo upsdrvctl stop

     

    • Start/Stop NUT server:

                sudo upsd

                sudo upsd -c stop

     

    • Start/Stop monit Daemon

                sudo upsmon

                sudo upsmon -c stop

     

    • Display UPS status:

                sudo upsc cyberpower@localhost

     

     

     

     

  • TOSHIBA P300 failing in 5 month

    It is reported that one harddisk is failling during boot time of PC,

    Error log:

    SMART overall-health self-assessment test result: FAILED!
    Drive failure expected in less than 24 hours. SAVE ALL DATA.
    Failed Attributes:
    ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
      5 Reallocated_Sector_Ct   0x0033   002   002   005    Pre-fail  Always   FAILING_NOW 1933

     

    Disk Model:    TOSHIBA P300 

    Supplier:         JD.com

    Purchased Date:    2021/05

    Report Date:           2021/10

    Usage:   SWAP

     

    How to check disk status:

    smartctl -H /dev/sda

    How to make disk test:

    smartctl -t long /dev/sda

    How to get disk test report:

    smartctl -l error /dev/sda

  • Reproduction Build of LFS

    To achieve the target of reproduction build, the following action should be taken:

     

    • Strip the result, via modification gcc spec file
    • Set and export the SOURCE_DATE_EPOCH environment variable, say
    SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)

     

  • FreeNAS

     Two TrueNAS (FreeNAS)  NAS system are setup for the purpose of data backup, including the resumed blog running on ESXi virtual machine, replaced the Buffalo lS-WXL and WdMycloud.

    The benefit of FreeNAS:

    • Based on Freebsd OS, stable
    • Native support ZFS, and snapshot
    • Other professional feature ready

     

    The blog data is backup into the 1st FreeNAS, manually after updating the blog.

    The 1st FreeNas will generate a snapshot every day, thanks to the Periodic Snapshot Task provided by FreeNAS system, and them replicate the snapshot to the 2nd FreeNas machine, also thanks to the Replication Task of freeNas system.

     

    Hardware spec of 1st NAS:

    1. HP T610 plus thin client  ( AMD (G-T56N) 1.65GHz dual core / E350 )
    2. 16GB DDR3  (2 X 8GB)
    3. 32GB Flash driver  for FreeNAS system + 4TB 3.5 HD for data
    4. 10/100/1000  Ethernet

     

        Cost: without Data Disk:

                 AMD T610 Plus                               RMB 185
                 Power:19V4.74  7.4*5.0mm         RMB 30
                 SATA2 32G SSD                            RMB 45
                 DDR3L 8G/1600  X2                       RMB 398
    ———————————————————————–
                     Total                                            RMB 658      

     

     

    Hardware spec of 2st NAS:

    1. HP Z220 MT workstation
    2. 32GB DRR3 ECC RAM
    3. Intel G3250T CPU
    4. One USB key for FreeNAS system + 10T HD for data

     

    The Raid sub-system is not a best choice.

    As Home User, we don’t care about the data lost, or data server down in a short period of time.  That’s way we two NAS system / Data replication instead of raid sub-system.

     

     

     

     

     

  • Linux Application From Scratch

    The new wordpress platform is based on Linux Application From Scratch.

    The mysql server, php, nginx (openresty), and all dependency, including gcc and C library, any code in User Space, are build from source code, and installed into /opt/local as root directory.

    The benefit of LAFS (LFS for wordpress application):

    Could be running on any linux platform, as long as same mode (x86-64),  and support the selected basic instruction set (Sandy Bridge). The software is binary compatible,to run it on a new linux machine,  just the copy the image to the /opt/local.

    Thanks to the linux kernel API backword compability,  the kernel version have no side impacts for most of application.

     

    With the help of LAFS implementation, we can build blog platform, modification blog contents locally, and push to the remote public vps with easy:

          Just the file level sync (rsync):

     

    Dev Machine   ==>   Local Production Env   ==>  Remote Public Production Env

      ( Intel E3 )                  ( Vmware ESXi )                         (VPS)      

     

     

     

     

     

  • Blog Resume

    Blog   Resume

            Sept 2021