แสดงกระทู้

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 [4] 5 6 ... 73
46
all application on unix knowledges by golfreeze / upgrade centos 6 to centos7 during year 2021
« on: กุมภาพันธ์ 15, 2021, 05:39:21 PM »
upgrade centos 6 to centos7 during year 2021
ผมเชื่อว่ายังมีคนที่ อัฟเกรด kernel สำหรับ centos 6 ไป centos 7 ไม่ทันช่วงที่ Centos 6 ประกาศ EOF เมื่อเดือน Nov2020 ที่ผ่านมา
ซึ่งทำให้ คนที่ใช้ centos 6 (kernel 2.6.x) อยู่ จะไม่สามารถอัฟเดท package ผ่าน yum ได้ อาจจะต้อง compile source เอา และหาพวก package dependency มาติดตั้งก่อน

ซึ่งในวันนี้ทางทีมงาน Packetlove.com เองอยากมาแนะนำ วิธีการครับ อันดับแรก ต้องทำการ backup system เอาไว้ก่อนทำการอัฟเกรด นะครับ
ถ้า backup system เสร็จแล้วก็ ลุยกันเลย

==clear CentOS-base.repo
cd /etc/yum.repo
mv CentOS-base.repo CentOS-base.repo.ori

==vi /etc/yum.repo/CentOS-upgrade.repo
[centos-upgrade]
name=centos-upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
enabled=1
gpgcheck=0


======== if found error please complete install before
No package libxml2-devel available.
No package libxslt-devel available.
No package openscap, available.
No package pcre-devel available.
No package mod_wsgi available.

==ผมรวบรวมไฟล์ที่จำเป็นในการอัฟเกรดมาให้นะครับ ทำการ download และรัน Fixed ตามด้านล่างได้เลยครับ
wget https://golfreeze.packetlove.com/download/package_upgrade_need.tar.gz
rpm -ivh libgpg-error-devel-1.7-4.el6.x86_64.rpm
rpm -ivh libgcrypt-devel-1.4.5-12.el6_8.x86_64.rpm                                                                                               
rpm -ivh libxml2-devel-2.7.6-21.el6_8.1.x86_64.rpm
rpm -ivh libxml2-2.7.6-21.el6_8.1.src.rpm
rpm -ivh libxslt-devel-1.1.26-2.el6_3.1.x86_64.rpm
rpm -ivh pcre-devel-7.8-7.el6.x86_64.rpm
rpm -ivh mod_wsgi-3.4-1.el6.rfx.x86_64.rpm

===need to use openscap on version 1.0.8
yum install openscap
yum -y install redhat-upgrade-tool preupgrade-assistant-*
yum -y install preupgrade-assistant-contents redhat-upgrade-tool preupgrade-assistant
rpm --import http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7


mkdir -pv /var/tmp/system-upgrade/base/ /var/tmp/system-upgrade/extras/ /var/tmp/system-upgrade/updates/
echo http://mirror.centos.org/centos/7/os/x86_64/ >> /var/tmp/system-upgrade/base/mirrorlist.txt
echo http://mirror.centos.org/centos/7/extras/x86_64/ >>   /var/tmp/system-upgrade/base/mirrorlist.txt
echo http://mirror.centos.org/centos/7/updates/x86_64/ >>  /var/tmp/system-upgrade/base/mirrorlist.txt

===start
yes | preupg -v

==new version
centos-upgrade-tool-cli --network=7 --instrepo=http://vault.centos.org/7.2.1511/os/x86_64/
centos-upgrade-tool-cli --force --network=7 --instrepo=https://vault.centos.org/7.2.1511/os/x86_64/ --cleanup-post


==old version
centos-upgrade-tool-cli --network=7 --instrepo=http://vault.centos.org/7.0.1406/os/x86_64/
centos-upgrade-tool-cli --force --network=7 --instrepo=https://vault.centos.org/7.0.1406/os/x86_64/ --cleanup-post


==reboot and waiting 5-10minute please monitoring on console
===ตรงจุดนี้หลังการ ก่อนการรัน reboot เราสามารถเขียน shell script แล้วรันบน crontab ได้นะครับผม
===เพื่อให้ libsasl2 ที่ใช้งานร่วมกับ openssh version บน centos6 สามารถเรียกใช้งานบน centos7 ได้ครับผม


=== script ===
vi ln_shell.sh

#!/bin/bash

export PATH=/usr/sbin:/sbin:/usr/bin:/bin
ln -s /lib64/libpcre.so.1 /lib64/libpcre.so.0
ln -s /usr/lib64/libsasl2.so.3 /usr/lib64/libsasl2.so.2
systemctl restart sshd

แล้วตั้งใน crontab เป็น
@reboot  /root/ln_shell.sh > /dev/null 2>&1

เท่านี้เราก็พร้อมทำการ reboot ละครับ
reboot

ถ้าใครไม่รัน crontab ก็ต้องรันหน้าเครื่อง console ตามนี้นะครับ
ln -s /lib64/libpcre.so.1 /lib64/libpcre.so.0
ln -s /usr/lib64/libsasl2.so.3 /usr/lib64/libsasl2.so.2
systemctl restart sshd

ก็จะสามารถ login ผ่าน ssh ได้ครับผม  8)
welcome to Centos7.x kub

หลังจากอัฟเกรดเสร็จแล้วอาจจะต้องแก้ไขปัญหาพวก service ที่ยังรันไม่ได้ให้ทำงานได้นะครับ
ซึ่งในส่วนนี้จะต้องไล่เชค log error แล้วตามแก้ไขเอา ขอให้ทุกท่านผ่านไปได้ด้วยดีนะครับ
: )

48
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

49
=== 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 ขึ้นมาด้วยครับผม : )

50
ในกรณีเราติดตั้ง 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)


51
=== 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

52
=== 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 ตัวที่แก้ไข ก็จะเข้าได้

53
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 ดูนะครับผม : )

54
=== 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 ทีครับ

55
custom memory_limit for user da

cd /usr/local/directadmin/data/users/php
vi php-fpm74.conf

edit
memory_limit=256MB

==restart service 1 times
/usr/local/etc/rc.d/php-fpm74 restart

56
ถ้ามีการอัฟเกรดระบบ และถ้ามีการเรียกอัฟเกรด xz ไปด้วย จะทำให้ตอน boot os เจอ error ประมาณนี้ครับ
xz /usr/local/lib/liblzma.so.5 version XZ 5.2.2 not found (required by xz)
/lib64/liblzma.so.5: version `XZ_5.1.2alpha' not found (required by /lib/librpmio.so.5)

ทำการแก้ไขโดยใช้ ISO ของ CentOS7.x image โหลดเข้า "linux rescue" mode
ทำการเข้าไปในโหมด Option 1 (Continue) to get to the shell.

mount --bind /proc /mnt/sysimage/proc
mount --bind /dev /mnt/sysimage/dev
mount --bind /sys /mnt/sysimage/sys
chroot /mnt/sysimage
cd /usr/local/lib
unlink liblzma.so.5
ln -s /usr/lib64/liblzma.so.5  /usr/local/lib/liblzma.so.5

dracut -f
exit
cd /
sync
telinit 6

57
ทำการเพิ่ม
   location ~ .php$ {
                try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

ลงไปในแถบ server ใน nginx.conf ดังข้างล่างครับ

vi /etc/nginx/nginx.conf

server {
    server_name www.packetlove.com packetlove.com; # managed by Certbot
        index index.php index.html index.htm;
        root         /var/www/it-money.com/public_html;
        include snippets/phpMyAdmin.conf;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        if ( !-e $request_filename ){
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
        }

        location / {
                try_files $uri $uri/ /index.html;
        }

         location ~ .php$ {
                try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
....

หลังจากนั้นทำการ restart nginx 1 รอบ

58
command , shell script ,tool , crontab / added routing in centos 8.x
« on: กรกฎาคม 22, 2020, 08:14:15 PM »
ถ้าต้องการทำ static route ใน centos 8.x เช่น
192.168.0.0/16 ให้วิ่งออก 192.168.1.254 สามารถทำได้ดังนี้
172.30.0.0/16 ให้วิ่งออก 192.168.1.254 สามารถทำได้ดังนี้

vi /etc/sysconfig/network-scripts/route-ens160
192.168.0.0/16 via 192.168.1.254
172.30.0.0/16 via 192.168.1.254


59
all application on unix knowledges by golfreeze / rufus burn iso to boot disk usb on window 10
« on: มิถุนายน 23, 2020, 01:26:58 PM »
rufus burn iso to boot disk usb on window 10
https://github.com/pbatard/rufus/releases/download/v3.11/rufus-3.11.exe

หรือเข้าไป download จาก https://rufus.ie

60
/usr/local/etc/rc.d/pure-ftpd: WARNING: run_rc_command: cannot run /usr/local/sbin/pure-config.pl

=== re-build pureftpd & dovecot again.
cd /usr/local/directadmin/custombuild
Check versions.txt see pureftpd if found version then
./build pureftpd
./build dovecot

Pages: 1 2 3 [4] 5 6 ... 73