Skip to main content

Posts

[Linux/k8s] set faking hyper-v uuid on k8s woker node

* conclusion     Unable to create weave-net (pod-to-pod connection) which works well with conflicting uuid. So in the end i reinstalled ubuntu in hyper-v (not import mode). remap-uuid.sh #!/bin/bash function make_bind_or_copy() {   if [ "$3" == "bind" ]; then     echo "MountBind $1 > $2"     mount -o ro,bind "$1" "$2"   else # copy     echo "Copy $1 > $2"     cp "$1" "$2"   fi } function make_newID() {   TITLE="$1"   ORG_FILE="$2"   TAR_FILE="$3"   BIND_MODE="$4"   if -f [ -f $TAR_FILE ]; then     make_bind_or_copy "${TAR_FILE}" "${ORG_FILE}" "${BIND_MODE}"     return   fi   CUR_ID=`cat ${ORG_FILE}`   echo "Current   ${TITLE}: ${CUR_ID}"   echo -n "Write New ${TITLE}: "   read NEW_ID   echo "Inputed   ${TITLE}: ${NEW_ID}"   echo "${NEW_ID}" > ${TAR_FILE}   echo -n "Re-Write(mount) ${OR

Linux/Process fork monitoring

ps_moniter.sh  #!/bin/bash . /etc/profile let LIMIT_PROCESS=400 let LIMIT_BIG_PROCESS=40 ALL_PROCESS_NUM=`ps x |wc -l` if [ ${ALL_PROCESS_NUM} -gt ${LIMIT_PROCESS} ]; then   echo ${ALL_PROCESS_NUM} fi BIG_PROCESS=`ps x -o cmd |sort  |uniq -c |sort -n |tail -n 10` BIG_PROC_SUM=`echo "${BIG_PROCESS}" |awk ' { SUM=SUM+$1 } END { print SUM } '` if [ ${BIG_PROC_SUM} -gt ${LIMIT_BIG_PROCESS} ]; then   MESSAGE="Process Report [Big Process Larger than ${LIMIT_BIG_PROCESS}] ${BIG_PROCESS}"   echo "$MESSAGE" fi crontab */5 * * * * cd /root/bin && ./ps_moniter.sh &>/dev/null

uri modificatin on http response

In haproxy : cannot. In nginx : possible. Backend Host: 1.2.3.4 Frontend Host: 2.2.2.2         location ^~ /its/         {             proxy_buffering   off;             rewrite           /its/(.*) /$1 break;             proxy_pass        http://1.2.3.4/;             proxy_redirect    default;             sub_filter_once off;             sub_filter ' href="/' ' href="/its/';             sub_filter ' src="/' ' src="/its/';             sub_filter ' src="http://1.2.3.4/' ' src="/its/';             sub_filter ' action="/' ' action="/its/';         } ex1. 2.2.2.2/its --> (2.2.2.2 connect to 1.2.3.4 ) 1.2.3.4/ 2.2.2.2/its/xxx <-- (2.2.2.2 response by 1.2.3.4 ) 1.2.3.4/xxx ex2. 2.2.2.2/its/aaa --> (2.2.2.2 connect to 1.2.3.4 ) 1.2.3.4/aaa 2.2.2.2/its/xxx <-- (2.2.2.2 response by 1.2.3.4 ) 1.2.3.4/xxx

rsyslog file log to remote syslog

 1. rsyslog    [file-A]     <--->    [remote rsyslog] 1) Edit conf file (The filename is your choice.)   @: udp   @@: tcp /etc/rsyslog.d/01-testlog.conf $ModLoad imfile # Default Apache Access Log $InputFileName /var/log/haproxy.log #$InputFileName /var/log/httpd/access_log #$InputFileTag httpd-access-default: #$InputFileStateFile stat-httpd-access #$InputFileSeverity info $InputFileFacility local4 $InputRunFileMonitor $InputFilePollInterval 10 local4.* @127.0.0.1:514 2) ignore local4 from /var/log/message and /var/log/syslog   edit /etc/rsyslog.conf Before: *.*;auth,authpriv.none    -/var/log/syslog After: *.*;!(local4.*);auth,authpriv.none    -/var/log/syslog Before: *.=debug;\   auth,authpriv.none;\   news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\   auth,authpriv.none;\   cron,daemon.none;\   mail,news.none    -/var/log/messages  After: *.=debug;\   auth,authpriv.none;\   news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\   auth,authpriv.none;\  

Redmine save_revision error by DB charset

* Check unit rails runner "Repository.fetch_changesets" -e production * ErrorLog /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query': Mysql2::Error: Incorrect string value:.......) (ActiveRecord::StatementInvalid)         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/a

Mysql/MariaDB Recovery.

[DB_NAME]: DB-name to recovery. /dev/shm Usage: First, check your memory if you can use shm directory.   For recovery speed, I use /dev/shm/ directory. Process flow. 01. Stop DB  service mysqld stop 02. Stop web-service. (If you don't use, block DB-connection by using firewall-cmd.)  service httpd stop 03. Change DB-mode on server.cnf   set innodb_force_recovery = 5 on /etc/my.cnf.d/server.cnf 04. Start DB for recovery.  service mysqld start 05. Run DB-dump.  mysqldump -u root -p --databases [DB_NAME] > /dev/shm/[DB_NAME].sql 06. Stop DB  service mysqld stop 07. Change DB-mode on server.cnf (normal mode)  set innodb_force_recovery = 0 on /etc/my.cnf.d/server.cnf 08. Backup old DB-files. (Run follows if you necessarily need backup.)  mkdir /backup/DB_BackupTmp  mv /backup/DB/ibdata1 /backup/DB_BackupTmp  mv /backup/DB/ib_logfile0 /backup/DB_BackupTmp  mv /backup/DB/ib_logfile1 /backup/DB_BackupTmp  mv /backup/DB/[DB_NAME] /backup/DB_BackupTmp 09. Start DB  service mysqld start 10

[redmine] repository trouble shooting

 1) Timeout occurs when deleting repository.    Check queries by using processlist.   "show processlist;" 2) If the reason of that case is timeout, set follows.  show variables like '%timeout';  set global innodb_lock_wait_timeout=300;  set session innodb_lock_wait_timeout=300;  If you necessary, kill process to restart process.     "kill <id>;" 3) Check if you have dummy data. SELECT changesets.repository_id FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories) group by changesets.repository_id ; Do A or B. * A DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories)); DELETE FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories); * or B (415 = your target repository id) DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id = 415);