แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - golfreeze

Pages: [1] 2 3 ... 72
1
Proxmox เจอปัญหา
Connection error 401: permission denied - invalid PVE ticket
แก้ไขโดย
#systemctl restart pvedaemon pveproxy

และทำการ เข้าไปที่ /etc/pve
แล้วทำการ
#mv authkey.pub authkey_20230312.pub
หลังจากนั้นทำการ login เข้า ui ใหม่อีกรอบ

2
mongodb dump and restore only specific collection or table
database : test123
collection-name : ProductManager

===mongodump only collection
/usr/bin/mongodump -h localhost -d test123 --collection=ProductManager -o /home/test/backup_mongo/

===mongorestore only collection
mongorestore --db=test123 --collection=ProductManager /home/test/backup_mongo/test123/ProductManager.bson

3
==expect command
/app/pklscript/sftp.sh
set DATE.[timestamp -format {%Y-%m-%d}]
$DATE

4
All about virtualization openstack + vmare esxi / reset user root on cli esx-i
« on: กุมภาพันธ์ 12, 2023, 03:03:03 PM »
**** ถ้าเจอกรณี login เข้า root ผ่านหน้า ui ไม่ได้ แสดงว่าอาจจะ โดน brute force จากหน้า ui
ต้องเข้าผ่าน account admin อีกตัว แล้วเข้าไปเปิด ssh แล้วทำการ un-locked user “root” *** ผ่าน command :
pam_tally2 --user root --reset

แล้วทำการ login ผ่านหน้าเวบ ui อีกที ถ้า login ได้ก็ปิด ssh service ด้วยนะครับ
 8)

5
command , shell script ,tool , crontab / memcache export and import with memcached-tools and nc
« on: กุมภาพันธ์ 07, 2023, 12:42:48 PM »
=== export memcache data from old-web
/usr/share/memcached/scripts/memcached-tool 127.0.0.1:11211 dump > memcache7feb.dumpall

### import memcache data into new-memcache node #
nc 127.0.0.1 11211 < oldweb_memcached7feb.dumpall

6
ถ้าต้องการเพิ่ม php-fpm pool เพื่อใช้งานใน nginx เพิ่มเติม เพื่อรองรับ web connection เพิ่มเติม สามารถทำได้ดังนี้

PKLLAB.com have php-fpm5.6 running 4 pool
If need to add pool add configure on
#cp /etc/php/5.6/fpm/pool.d/www4.conf /etc/php/5.6/fpm/pool.d/www5.conf
And change configure pool-name on www5.conf
From
www4->www5

And add configure on /etc/nginx/sites-available/pkllab.com
upstream php56_pkllab {
        server "unix:/run/php/php5.6-fpm-www1.sock" max_fails=0;
        server "unix:/run/php/php5.6-fpm-www2.sock" max_fails=0;
        server "unix:/run/php/php5.6-fpm-www3.sock" max_fails=0;
        server "unix:/run/php/php5.6-fpm-www4.sock" max_fails=0;
        server "unix:/run/php/php5.6-fpm-www5.sock" max_fails=0;

Then restart 2 service
/etc/init.d/php5.6-fpm restart
Systemctl restart nginx

7
===สคิป find folder then chmod folder 755 and file 644 in wordpress
find /home/wordpress/htdocs \
\( -type f -exec chmod ug+rw,o+r {} \; \) , \
\( -type d -exec chmod ug+rwxs,o+rx {} \; \)

8
command , shell script ,tool , crontab / grep , egrep , fgrep howto
« on: กันยายน 04, 2022, 06:16:03 PM »
==show line number if found exact word "day" not "today" in file test.txt
grep -n -w "day" test.txt

9
command , shell script ,tool , crontab / basic of awk by golfreeze
« on: กันยายน 04, 2022, 10:24:46 AM »
##show second column contain word "account"
awk '$2 ~ account {print} ' filenamel

##show first column start with "e" in file check.sh
awk '$1 ~ /^e/ {print } ' check.sh

##show first column start with not contain "e" in file check.sh
awk '$1 !~ /^e/ {print } ' check.sh

##search and grep "account" from file
awk '/account/ {print } ' check.sh
awk '/^account/ {print }' check.sh

##if > < >= <= && || finding $5 more than 2000 and less than 2500 then print
awk '$5 > 2000 && $5 <2500 {print $0}' check.sh

##if > < >= <= && || finding $5 more than 2000 or $5 not contain "sal" in line then print
awk '$5 > 2000 || $5 !~ /sal/ {print $0}' check.sh

##if need change first line with specific "Start processing" and grep "account"
awk 'BEGIN {print "Start processing"} {print $0}' check.sh
awk 'BEGIN {print "Start processing"} /account/ {print $0}' check.sh

###if need add BEGIN and END of awk and grep "account"
awk 'BEGIN {print "Start processing"} /account/ {print $0} END {print "End processed"}' check.sh

##if need count NR=Number record , NF=Number of field
awk '{print NR,$0,NF} END {print "End processed"}' check.sh

##if need print LAST Field $NF
awk '{print NR,$0,$NF,FILENAME} ' check.sh

##if need only line4 until line8 in file to show
awk 'NR==4,NR==8  {print $0}' check.sh
awk 'NR==4,NR==8 {print $0}' check.sh | awk '$3 ~ /username/'

##if substitute space with some character use OFS=output field substitute => if see space " " then replace with "@@"
awk 'NR==4,NR==8 {print $0}' check.sh | awk 'BEGIN{OFS="@@"} {print $2,$3}'
awk 'BEGIN {print "Start processing"} {print $0}' text3 | awk 'BEGIN{OFS="@"} {print $1,$2".com"}'

##if substitute space with some character use FS=field substitute => if see ":" then replace with space " "
awk 'BEGIN{FS=":"} {print $2,$3}' text4

##if substitute space with some character use FS=field substitute => if see ":" then replace with "@@"
awk 'BEGIN{FS=":";OFS="@@"} {print $2,$3}' text4

##if substitute last character in file use ORS=":" with :
awk 'BEGIN {print "Start processing"} {print $0}' text3 | awk 'BEGIN{OFS="@";ORS=":"} {print $1,$2".com"}'
output=> Start@processing.com:store@manager.com:Woodridge,Australia@Jon.com:Lethbridge,Canada@Mike.com:Bridge,
Canada@Mike.com:Sisaket,Thailand@Liamthong.com:Pathumthani,Thailand@White.com:Saimai,Bangkok@Packetlove.com:

###if need awk run if condition or run condition on script file
awk '{if ($3 > 2000) print $0 }' text3
output=>
store                manager       total_sales
Woodridge,Australia  Jon Stephens     33726.77
Lethbridge,Canada    Mike Hillyer     33679.79
Bridge,Canada   Mike Hillyer          43679.89
Saimai,Bangkok          Packetlove      8229.4

awk '{if ($3 > 2000) print $0; else print "Low" }' text3
output=>
store                manager       total_sales
Woodridge,Australia  Jon Stephens     33726.77
Lethbridge,Canada    Mike Hillyer     33679.79
Bridge,Canada   Mike Hillyer          43679.89
Low
Low
Saimai,Bangkok          Packetlove      8229.4

###if need awk run if condition or run condition on script file
awk -f script text4

###toupper=change small character to BIG capital leeter  on first column , length=count length of character on $3
awk '{print toupper($1),length($3)} {print $0}' text3

10
all application on unix knowledges by golfreeze / postgres export data to csv file
« on: สิงหาคม 20, 2022, 03:01:02 AM »
===== DB Task ===== run import script in sql
testdb=> \copy (select * from param_change_request where id in (161, 162)) TO '/home/testdb/backhour.csv' CSV HEADER;

แล้วสามารถไปดูที่ไฟล์ backhour.csv ได้ครับ

11
all application on unix knowledges by golfreeze / postgres psql command import query
« on: สิงหาคม 20, 2022, 02:56:45 AM »
ถ้าเรามีการเตรียม สคิปในไฟล์ check_query_alter_update.sql เพื่อทำรายการใน db=testdb เราสามารถรันผ่าน command psql ได้ดังนี้

postgres=> \c  testdb
testdb=> \i 19aug2022_operation/Script/check_query_alter_update.sql
ALTER TABLE

เท่านี้ครับผม

12
===for centos , debian 11
cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh
./php-extension.sh install redis

==for freebsd
cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh

mkdir -p /usr/local/src
และแก้ไข #!/bin/bash -> #!/usr/local/bin/bash ใน php-extension.sh แล้วรัน
./php-extension.sh install redis

13
csf lfd stop alert email for nrpe on debian os directadmin
กรณีมีอีเมลส่งมาแจ้ง เยอะ alert สามารถแก้ไขเพื่อไม่ให้ส่ง email จาก service csf ที่เป้นหัวข้อ lfd ได้โดย

If debian enable “csf” need allow on csf.conf “TCP_in” and “TCP_out” and
Disable lfd for resource usage

Subject: lfd on packetlove.com: Excessive resource usage: nagios (494190 (Parent PID:494190))
From:  <root@packetlove.com>
Message-Id: <E1ne3x7-002N0R-7t@packetlove.com>
Date: Tue, 12 Apr 2022 07:00:13 +0700

Time:         Tue Apr 12 07:00:13 2022 +0700
Account:      nagios
Resource:     Process Time
Exceeded:     75567 > 1800 (seconds)
Executable:   /usr/local/nagios/bin/nrpe
Command Line: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
PID:          494190 (Parent PID:494190)
Killed:       No

--1649721613-eximdsn-849789542--

==แก้ไขเพื่อไม่ให้ส่ง email ได้โดย
vi /etc/csf/csf.pignore
user:nagios
exe:/usr/local/nagios/bin/nrpe
cmd:/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
==reload csf rule 1 รอบ
csf -r

14
วันนี้มีโจทย์ให้ทำ บน DirectAdmin ให้ uninstall pureftp และทำการ enable proftpd พร้อมกับ sFTP feature ขึ้นมา

==เริ่มด้วย stop pureftp first เพราะ default ลงมาเป็น pureftp
cd /usr/local/directadmin/custombuild
./build set pureftpd_uploadscan no

ทำการ build proftpd
# cd /usr/local/directadmin/custombuild
# ./build update
# ./build set ftpd proftpd
# mkdir -p custom/proftpd/conf (make a directory for custom ProFTPd config that adds mod_sftp)
# wget -O custom/proftpd/configure.proftpd http://files.directadmin.com/services/all/sftp/configure.proftpd.sftp
# wget -O custom/proftpd/conf/proftpd.conf http://files.directadmin.com/services/all/sftp/proftpd.conf
# chmod 755 custom/proftpd/configure.proftpd
# wget -O /etc/proftpd.sftp.conf http://files.directadmin.com/services/all/sftp/proftpd.sftp.conf
# mkdir /etc/proftpd.ssl
# cp /etc/ssh/ssh_host_rsa_key* /etc/proftpd.ssl
# chmod 400 /etc/proftpd.ssl/ssh_host_rsa_key
# cp /etc/proftpd.sftp.conf /etc/proftpd.sftp.conf_original

===Edit /etc/proftpd.sftp.conf ตรงส่วน SFTPHostKey ให้ไปชี้ /etc/proftpd.ssl/ssh_host_rsa_key แทน !!!! ไม่งั้นจะทำงาน sftp ไม่ได้ ===
<IfModule mod_sftp.c>
<VirtualHost 0.0.0.0>
# The SFTP configuration
# Port 23
Port 22 # Change to standard port now possible after moving SSH to 44
AuthUserFile /etc/proftpd.passwd
TransferLog /var/log/proftpd/xferlog.legacy
ExtendedLog /var/log/proftpd/75.126.244.2.bytes WRITE,READ userlog
SFTPEngine on
SFTPLog /var/log/proftpd/sftp.log
# SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/proftpd.ssl/ssh_host_rsa_key # Change to use key pair copied to /etc/proftpd.ssl and given necessary rights (0400) for mod_sftp.c work.
SFTPAuthorizedUserKeys file:~/.sftp/authorized_keys

หลังจากนั้นทำการ rebuild อีกรอบ
# cd /usr/local/directadmin/custombuild
# ./build proftpd
service proftpd restart

แล้วเทสกับ Filezilla ก็จะใช้งาน sFTP ได้ครับผม  :)

===recompile proftpd
https://forum.directadmin.com/threads/how-to-set-up-your-proftpd-ftp-server-to-support-the-secure-protocols-while-disabling-insecure-ftp.65025/
https://forum.directadmin.com/threads/proftpd-issue-with-sftp.63352/
https://docs.directadmin.com/other-hosting-services/ftp/general.html

15
upgrade mac-os แล้วทำการ copy text content on terminal ไม่ได้

คือหลังจากอัฟเกรด mac os จาก mojave-> montery แล้วทำการ copy text บน terminal ไม่ได้แก้ไขโดย ไปที่
Terminal -> View -> ติ๊กถูก Allow Mouse Reporting ออก 

 8)

Pages: [1] 2 3 ... 72