Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, May 27, 2020

Rabbitmq create user

# Enable web interface plugin
rabbitmq-plugins enable rabbitmq_management

# Create user with password
rabbitmqctl add_user megaadmin zwuvY0Ce7AETPsY2t4v5

# Set user role
rabbitmqctl set_user_tags megaadmin administrator
# Set user permissions
rabbitmqctl set_permissions -p / megaadmin ".*" ".*" ".*"

Friday, November 24, 2017

Linux top opened files

## Get common list of all opened files
lsof > lsof.log

## Get top
cat lsof.log | awk '{ print $2 " " $1; }' | sort -rn | uniq -c | sort -rn | head -20

Thursday, October 6, 2016

Openvz notes


Migrate container between nodes

vzmigrate --live REMOTE-IP LOCAL-CTID

For example

vzmigrate --live -v 192.168.5.5 413

Quotas

Disk quota
vzctl set CTID --diskspace 45G:49G --save

Ram quota
vzctl set CTID --ram 3G --swap 2048M --save

Tuesday, July 26, 2016

firewalld allow ports

Check rules

# firewall-cmd --state

Get default zone

# firewall-cmd --get-default-zone

Add allowed ports

# firewall-cmd --zone=public --add-port=50000-51000/tcp

Add permanent allowed ports

# firewall-cmd --zone=public --permanent --add-port=50000-51000/tcp

Check ports and services

# firewall-cmd --zone=public --permanent --list-services
# firewall-cmd --zone=public --permanent --list-ports

Add custom service

# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --zone=public --permanent --add-service=smtp
# firewall-cmd --zone=public --permanent --add-service=imap

After all changes need apply rules

# firewall-cmd --reload

Monday, March 21, 2016

check processlist from swap

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

Tuesday, March 15, 2016

MariaDB enable slow logs


MariaDB [(none)]> SET GLOBAL slow_query_log = 'ON';
MariaDB [(none)]> set global slow_query_log_file = '/var/log/mariadb/slow.log';

Friday, February 26, 2016

mysql create user and db with privileges



> create database newdb;

 > GRANT ALL PRIVILEGES ON newdb . * TO 'newusername'@'localhost'  IDENTIFIED BY 'PASS';

> flush privileges;

// Change user password 

> SET PASSWORD FOR 'newusername'@'hostname' = PASSWORD('new-password');

> flush privileges;

Thursday, December 24, 2015

/var/cache/nginx/fastcgi_temp permission denied

check which user nginx is running

ps aux | grep "nginx: worker process"

in my case it "apache"

chown apache:apache /var/cache/nginx/ -R

Thursday, November 19, 2015

openssl csr request

openssl req -new -nodes -newkey rsa:2048 -keyout mydomain.key -out mydomain.csr

Monday, November 16, 2015

allow, deny not working apache + nginx

For allow remote connections for specific IP add next to htaccess

SetEnvIf Remote_Addr «10.11.12.15|10.11.12.16″ realremoteaddr
Order Deny,Allow
Deny from all
allow from env=realremoteaddr

10.11.12.15|10.11.12.16 — allowed IP


For deny:

SetEnvIf Remote_Addr «10.11.12.15|10.11.12.16″ realremoteaddr
Order Allow,Deny
Allow from all
Deny from env=realremoteaddr

10.11.12.15|10.11.12.16 — now allowed IPs

Friday, November 13, 2015

Tuesday, November 10, 2015

nginx init.d script

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

Friday, October 30, 2015

haproxy exclude redirect domain to https


in frontend http-in section


redirect scheme https if !{ hdr(Host) -i sub.domain.com } !{ ssl_fc }


Tuesday, October 6, 2015

git server hook after push

in server repo site edit file
.git/hooks/post-receive

add next script


#!/bin/bash
export GIT_WORK_TREE=/var/www/sitepath
git checkout -f



Tuesday, August 25, 2015

Thursday, May 21, 2015

linux кем слушаются порты

rpcinfo -p

вывод примерно такой

[root@host ~]# rpcinfo -p
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100011    1   udp    678  rquotad
    100011    2   udp    678  rquotad
    100011    1   tcp    681  rquotad
    100011    2   tcp    681  rquotad
    100021    1   udp  32768  nlockmgr
    100021    3   udp  32768  nlockmgr
    100021    4   udp  32768  nlockmgr
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100021    1   tcp  33303  nlockmgr
    100021    3   tcp  33303  nlockmgr
    100021    4   tcp  33303  nlockmgr
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100005    1   udp    718  mountd
    100005    1   tcp    721  mountd
    100005    2   udp    718  mountd
    100005    2   tcp    721  mountd
    100005    3   udp    718  mountd
    100005    3   tcp    721  mountd

nginx / apache parse access log

cat /var/log/nginx/access_log | awk '{print $1}' |sort | uniq -c | sort -k 1 -n

Tuesday, May 12, 2015

AH00082: an unknown filter was not added: PHP

Должно быть так
/etc/apache2/apache2.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
А не так
/etc/apache2/mod-available/php5filter.conf
<Files *.php>
       SetOutputFilter PHP
       SetInputFilter PHP
</Files>

Делаем так

#<Files *.php>
#      SetOutputFilter PHP
#       SetInputFilter PHP
#</Files>

Thursday, April 30, 2015

grub2-install: error: disk `mduuid/e54081d398c6d57b4d67436f6d032162' not found

After raid 1 disk replacement faced with this issue # grub2-install /dev/sdb Installing for i386-pc platform. grub2-install: error: disk `md...