แสดงกระทู้

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.


Messages - golfreeze

Pages: 1 ... 6 7 [8] 9 10 ... 146
106
ถ้าในกรณีใช้งานเป็น ldapsearch บน openldap 2.4.4 แล้วจะให้ search ออกมาเกิน limit ที่ตั้งไว้ 
เราสามารถใช้ "-E pr=1000/noprompt -x" ไปด้วยครับดังนี้

ldapsearch -E pr=1000/noprompt -x

 8)

107
command , shell script ,tool , crontab / Re: basic command for xargs
« on: กุมภาพันธ์ 03, 2021, 07:23:16 PM »
มีโจทย์อยู่ว่า มีชื่อไฟล์ดังนี้

domain1_215sati.php
domain2_215sati.php
domain3_215sati.php
.
.
domain50_215sati.php

ต้องการเปลี่ยนชื่อไฟล์เป็น
domain1_99packetlove.php
domain2_99packetlove.php
domain3_99packetlove.php
.
.
domain50_99packetlove.php

ถ้ามีเวลาเราก็นั่ง mv ทีละไฟล์ได้ แต่ถ้าเวลาน้อยก็นี่เลย 1 command
ls -alh | grep 215sati | awk '{print $9}' | grep \.php$ | sed 'p;s/215sati.php/99packetlove.php/' | xargs -n2 mv

เท่านี้ก็เสร็จภายใน 2 วินาที ครับ  8)

108
=== compile make on centos 8.3 จะเจอ error นี้ครับ เกิดจาก lib ที่ใช้งานใน 2.1.1 เก่าเกินให้ทำการแก้ไขโดย download v.2.3.3 มา compile แทนนะครับ
===wget http://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz

make[3]: Entering directory '/home/golf/nagios_nrpe/nagios-plugins-2.1.1/lib'
gcc -DHAVE_CONFIG_H -I. -I..  -DNP_STATE_DIR_PREFIX=\"/usr/local/nagios/var\" -I. -I../gl -I../intl -I../plugins   -g -O2 -MT utils_base.o -MD -MP -MF .deps/utils_base.Tpo -c -o utils_base.o utils_base.c
In file included from ../plugins/common.h:117,
                 from utils_base.c:27:
../gl/getopt.h:198:8: error: redefinition of 'struct option'
 struct option
        ^~~~~~
In file included from /usr/include/getopt.h:36,
                 from ../gl/getopt.h:32,
                 from ../plugins/common.h:117,
                 from utils_base.c:27:
/usr/include/bits/getopt_ext.h:50:8: note: originally defined here
 struct option
        ^~~~~~
In file included from ../plugins/common.h:117,
                 from utils_base.c:27:
../gl/getopt.h:247:12: error: conflicting types for 'getopt_long'
 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
            ^~~~~~~~~~~
In file included from /usr/include/getopt.h:36,
                 from ../gl/getopt.h:32,
                 from ../plugins/common.h:117,
                 from utils_base.c:27:
/usr/include/bits/getopt_ext.h:66:12: note: previous declaration of 'getopt_long' was here
 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
            ^~~~~~~~~~~
In file included from ../plugins/common.h:117,
                 from utils_base.c:27:
../gl/getopt.h:251:12: error: conflicting types for 'getopt_long_only'
 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
            ^~~~~~~~~~~~~~~~
In file included from /usr/include/getopt.h:36,
                 from ../gl/getopt.h:32,
                 from ../plugins/common.h:117,
                 from utils_base.c:27:
/usr/include/bits/getopt_ext.h:70:12: note: previous declaration of 'getopt_long_only' was here
 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
            ^~~~~~~~~~~~~~~~
make[3]: *** [Makefile:1394: utils_base.o] Error 1
make[3]: Leaving directory '/home/golf/nagios_nrpe/nagios-plugins-2.1.1/lib'
make[2]: *** [Makefile:1427: all-recursive] Error 1
make[2]: Leaving directory '/home/golf/nagios_nrpe/nagios-plugins-2.1.1/lib'
make[1]: *** [Makefile:1418: all-recursive] Error 1
make[1]: Leaving directory '/home/golf/nagios_nrpe/nagios-plugins-2.1.1'
make: *** [Makefile:1341: all] Error 2


=== compile make on centos 8.3 จะเจอ error นี้ครับ เกิดจาก lib ที่ใช้งานใน 2.1.1 เก่าเกินให้ทำการแก้ไขโดย download v.2.3.3 มา compile แทนนะครับ
===wget http://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar zxf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3
useradd nagios
passwd nagios

export LDFLAGS=-ldl
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround && make && make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec/

==> ต้องติดตั้ง compat-openssl10 ด้วยนะครับ
yum install compat-openssl10
ln -s /usr/lib64/libnsl.so.2 /usr/lib64/libnsl.so.1
updatedb
แล้วทำการ restart nrpe ดูอีกรอบนะครับ  8)

110
อัฟเดทเป็น firo-0.14.2.3 ทั้งบน window
https://firo.org/get-firo/download/
https://github.com/firoorg/firo/releases/download/v0.14.2.3/firo-0.14.2.3-win64-setup.exe


และทำการอัฟเกรดใน ubuntu box ของท่านด้วย
wget https://github.com/firoorg/firo/releases/download/v0.14.2.3/firo-0.14.2.3-linux64.tar.gz
./firod -daemon

==more information on
https://firo.org/guide/masternode-upgrade.html

111
ในกรณี ที่รัน update

===generate new "feeSourceAddress" by run below command on debug console in "Znode"
listaddressbalances 0.01

and get line3 value to input as "feeSourceAddress"
then running
=> protx update_service xxx again.

 8)

112
all application on unix knowledges by golfreeze / limit bandwidth in linux app
« on: ธันวาคม 22, 2020, 02:29:26 PM »
https://www.tecmint.com/wondershaper-limit-network-bandwidth-in-linux/

สามารถใช้งาน wondershaper command ได้ครับ

#apt install wondershaper  [On Debian/Ubuntu]
$ sudo yum install wondershaper  [On CentOS/RHEL]
$ sudo dnf install wondershaper  [On Fedora 22+]

wondershaper -a wlp1s0 -d 4048 -u 1048

113
=== compile nginx1.19.5 with Lua on Centos7.x 64bit
yum install nginx-1.19.5

เราสามารถทำการ install ผ่าน repo nginx ของ nginx ได้ครับผม จะทำให้ง่ายกว่า แล้วค่อยมารัน compile module lua เพิ่มได้ครับผม

wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.10.10.zip
wget http://nginx.org/download/nginx-1.19.5.tar.gz
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz

yum install gcc zlib-devel gcc-c++
yum install openssl-devel-1.0.2k openssl11-libs

cd /home/packetlove
tar zxvf v0.3.0.tar.gz
unzip -q v0.10.10.zip

tar zxf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make && make install

tar zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

tar zxf nginx-1.19.5.tar.gz
cd nginx-1.19.5
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0

tar zxf nginx-1.19.5.tar.gz
cd nginx-1.19.5
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0

==ทำการ reconfigure module nginx ที่สำคัญคือเพิ่ม module lua เข้าไปครับ
== --add-module=../ngx_devel_kit-0.3.0/ --add-module=../lua-nginx-module-0.10.10/
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'  --add-module=../ngx_devel_kit-0.3.0/ --add-module=../lua-nginx-module-0.10.10/
==make
make -j2 && make install
==link
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

systemctl restart nginx
netstat -ntlp
เรียบร้อยครับผม
nginx -V ก็จะมี lua-nginx-module ขึ้นมาด้วยครับผม : )

114
ในกรณีเราติดตั้ง apache 2.4 อยู่บน centos 7 หรือ 8
โดยปกติแล้วจะมีการใช้งาน selinux เป็น
SELINUX=enforcing
SELINUXTYPE=targeted
 
เราต้องทำการ enable homedir ด้วยนะครับ เพราะปกติค่าตัวนี้จะถูกตั้งเป็น false
เลยทำให้ apache homedir ที่ใช้เป็น /home/user/public_html เวลาเรียกแล้วจะขึ้นเป้น error 403
getsebool -a | grep http

===enable homedir public_html
/home/gotomoon/public_html
setsebool -P httpd_enable_homedirs true

ลองเข้าหน้าเว็บอีกทีก็จะเรียกได้ปกติครับ  8)


115
เราสามารถทำการ debug nagios nrpe ได้ครับ

#strace -f -s 128 -e execve -p `pgrep -ox nrpe`
แล้วเปิดอีก terminal ทำการรัน

/usr/local/nagios/libexec/check_nrpe -H0 -c check_pose_score

ก็จะสามารถดู debug ได้ครับผม

strace: Process 23817 attached
[pid xxxx] execve("/usr/local/nagios/libexec/check_post_score.sh", ["/usr/local/nagios/libexec/check_post_score.sh"], 0x5564695cfb70 /* 9 vars */) = -1 ENOENT (No such file or directory)

ก็แสดงว่าไม่มีสิทธิ์ในการเข้าถึง folder เลยไม่เจอ path หรือ file ดังกล่างในสคิป check_pose_score.sh

116
=== download new version from
https://gitmemory.com/reubenyap
https://github.com/zcoinofficial/zcoin/releases/download/v0.14.0.5/zcoin-0.14.0.5-win64-setup.exe

=== Upgrade from zcoin-0.14.0.1-win64.exe to zcoin-0.14.0.5-win64.exe

Added “znodeblsprivkey” into file
===zcoin.conf in window locate on
C:\Users\Administrator\AppData\Roaming\zcoin\zcoin.conf

====  block you are stuck on. Memorize this number
https://zcoinkb.wordpress.com/2017/12/22/zcoin-wallet-shows-no-block-source-available-or-stuck-on-block/


Open your wallet and see which block you are stuck on. Memorize this number
Go to Help > Debug Window. In there, go to Console .
Subtract about 1,000 blocks from the block number you memorized
Now type getblockhash block# where block# is the block number from step 1 minus 1,000. Example: You’re stuck on block 62393, subtract 1,000 and a little more, type getblockhash 61000
Copy the resulting block hash
We are now invalidating this hash by typing invalidateblock copiedhash where copiedhash is – you guessed it – the copied hash from step 5
Great. Now you confused your poor wallet. Give it a nudge and ask it to reconsider the block by typing reconsiderblock copiedhash
Now your wallet will start syncing from this block onwards and once it’s done, you should be all set!

===then open zcoin-qt.exe program again
And see stuck on block:296903
Minus 1000 -> 295903
And choose 295900

===access “Help” -> “Debug” ->  to “console" in window
getblockhash 295900
a20bf26a75c90920a79595fb7aa50acc9954dsssxxxxxxxxxxxxxx

invalidateblock a20bf26a75c90920a79595fb7aa50acc9954dsssxxxxxxxxxxxxxx
null

reconsiderblock a20bf26a75c90920a79595fb7aa50acc9954dsssxxxxxxxxxxxxxx
null

==then zcoin console will re-sync again and pass that block

117
=== change selinux=targeted to  selinux=disabled
Then reboot found “Failed to load SELinux policy, freezing.
Random: cringe init done

ต้องบูตเข้า linux rescue
แล้วทำการ edit boot loader แก้ไข บันทัดที่มี linux16
ให้เพิ่ม selinux=0 ก่อนหน้า ro
แล้วทำการ ctrl+x เพื่อ boot ตัวที่แก้ไข ก็จะเข้าได้

118
Nodejs Nginx error: (13: Permission denied) while connecting to upstream
ถ้าเจอเรื่อง permission denied ของ nginx
ถึงแม้จะแก้ไขเรื่อง chmod , chown เรียบร้อยแล้ว ก็ยังเป็นอยู่
ให้ลองเชค selinux อีกทีนะครับ ว่ามีใช้งาน mode ไหน
หรือจะเปิดให้ httpd เข้าใช้งาน network ได้
setsebool -P httpd_can_network_connect 1

หรือบางทีเป็นที่ codeignetor ไม่สามารถเขียน sessions ลงใน folder system/cache/sessions ได้
ให้ลองเชคที่ selinux ดูนะครับผม : )

119
=== เจอปัญหา Posed_BANNED บน zcoin wallet (window)
เนื่องจากว่า upgrade Zcoin wallet แต่ลืมทำการ upgrade binary บน VPS server
ซึ่งทำให้โดน banned ไปเลย และหนักกว่านั้น ใน version 0.14.0.1 เป็นต้นมา ต้องใส่ค่า znodeblsprivkey ลงไปใน zcoin.conf ด้วย
แต่ว่าดันไม่ได้เซฟไว้ ค่า OperatorKey ไว้ งานเข้าเลย และ VPS server ยังคงเป็น binary version 0.13.0
ซึ่งสามารถที่จะ protx register ได้ แต่ใช้ไปสักพัก ก็จะให้โดน posed_banned ครับ

เพราะถ้าเจอปัญหา POSED_BANNED ถ้าเรามีค่า OperatorKey (znodeblsprivkey)  ก็สามารถรัน
protx update_service proTxHash ipAndPort operatorKey (operatorPayoutAddress feeSourceAddress)
ได้เลยแล้วรอ confirm address ขึ้นแค่ 1 ก็จะทำให้ ค่าที่เป็น posed_banned หายไป แล้วค่อยมานับเริ่มใหม่ เพื่อรอรับ zcoin reward

ดังนั้นเราต้องทำการรัน "bls generate" บน wallet console ใหม่ แล้วทำการ update_registrar ใหม่อีกที ซึ่งมี syntax ดังนี้ (operatorPubKey)=> ใช้ตัวใหม่ที่เจน bls generate ได้แล้วทำการเซฟไว้ด้วยนะครัห้ามลืม หลังจากนั้นทำการเพิ่ม configure "znodeblsprivkey" ใน zcoin.conf ด้วยแล้ว start process ใหม่
หลังจากนั้นทำการ update_registrar ตามด้านล่าง
#protx update_registrar protxhash operatorPubKey "" payoutAddress feeSourceAddress

หลังจากรัน update_registrar แล้วทำการรอ confirmed
หลังจากนั้นก็ให้รัน update_service อีกรอบ โดยใส่ ค่า operatorKey ชุดใหม่
protx update_service proTxHash ipAndPort operatorKey (operatorPayoutAddress feeSourceAddress)

เท่านี้ Znode เราก็จะกลับมา mined mint ต่อได้แล้วครับผม   8)

===Special Thank : Zcoin Support in Discord.
johnsmith [will not PM you]
CardcaptorZakura#9636

===site reference
https://github.com/zcoinofficial/zcoin/wiki/Deterministic-Znodes-Operator-Guide
https://github.com/zcoinofficial/zcoin/wiki/Migrating-your-Legacy-Znodes-to-the-new-Deterministic-Znodes-system

120
=== Rootclause  :  PostgreSQL v10 and v11
 ===check replicate log make disk full
 postgres=> select slot_name, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(),restart_lsn)) as replicationSlotLag, active from pg_replication_slots;

            slot_name             | replicationslotlag | active
----------------------------------+--------------------+--------
 re_sub                | 64 MB              | t
 replication_slot1  | 904 GB             | f
 replication_slot2  | 904 GB             | f

(3 rows)

เราสามารถทำการ drop slot ที่กินพื้นที่ได้ ดังนี้
postgres=# SELECT pg_drop_replication_slot('replication_slot1');
postgres=# SELECT pg_drop_replication_slot('replication_slot2');

แล้วทำการปรับ purge delete log จาก default 3 วัน (4320minute) เป็น 1 วัน (1440minute)ได้ครับ
rds.log_retention_period = 1440
แล้วทำการ  restart service 1 ทีครับ

Pages: 1 ... 6 7 [8] 9 10 ... 146