grant alter routine,create routine, execute on *.* to 'testuser'@'%' ;
Labels
amazon
apache
apt
aptitude
automate docker image
awk
aws
awstat
backup
bandwidth
bash
binary log
bond
bridge
caching
centos
centos 7
cluster
concurrency
csv
digitalocean
disk
django
docker
docker images
dovecot
drop cache
enviroment
error
explain
free
fstab
ftp
git
gluster
go
gpg
grep
grub
header
header check
icinga2
imapsync
information
innodb
ip
iproute
isolation
ispconfig
java
jenkins
jump
kdump
keepalived
kvm
linux
locale
logbuffer
lookbehind
macos
mail
maillog
matplotlib
mcrypt
memory
modrewrite
monitoring
mount
msyql ndbcluster
mta
multipath
mutt
my.cnf
mysql
mysql error
mysql optimization
mysql permission
mysqlcluster
mysqldump
nethogs
network
nginx
node
nopasswd
ntp
nxlog
openssl
optimization
parsing
parted
password
pflogsumm
php
php-fpm
php5-mcrypt
phpmyadmin
pip
policyd
post
postfix
proxy
pycurl
python
query_cache
querydict
rdesktop
rds
recommender systems
recover mysql
redhat
redolog
regex
regularexpression
resilver
roundcube
route
rsync
scrapy
script
scrub
security
service
setfacl
sftp
slow
smtp
snnp
spamassassin
spotlight
sql
squirrelmail
ssc
ssh
ssh-copy-id
ssl
startup
syslog
syslog over tls
tar
telnet
tls
tomcat
transaction
troubleshoot
tuning
ubuntu
udev
ulimit
usb
vdev removal
virtualhost
virtualization
virtualmin
vrrp
watch
webscrape
wget
x11
zfs
zfs send
zfs recv
zpool
grant create modify create procedure routines on linux
linux, web, ispconfig3, python, bash, apache
mysql,
mysql permission
mysql ndb cluster setup notes
Setup Overview
MySQL Cluster has one or more of several major components. Typically each component will have its own server (a node). Those components are
sql node(front-end)
data node (back-end)
management node (central config,meta-data and etc)
Generally speaking, application requests are sent to the SQL nodes, which then talk to the data nodes and coordinates each other via management node(s) to actually recover the content you want.
For redundancy you need at least two data nodes.
MGM Node - holds the configuration for MySQL Cluster in a file called config.ini. It also writes a cluster log, and takes part in arbitration to prevent split-brain or network partitioning.
You are recommended to have two MGM Nodes for redundancy. Since MGM hardly use any resources, and is not involved in query processing or routing of requests, it can be colocated with the SQL Nodes/Access Nodes.
SQL Node / Access Node - the most common way to read/write data to the Data Nodes is by using the MySQL Server (aka SQL Node). A query comes into the SQL Node. The SQL Node parses, optimizes and executes the query on the Data Nodes.You need at least two SQL Nodes for redundancy. Nodes in the access layer should have fast CPUs, disks are not important, fast network to the data nodes (same specs as for the data nodes), and about 2+ GB of RAM (depending on the number of connections, per thread buffers etc). Do not co-locate the SQL Nodes/Access Nodes with the Data Nodes.
Data nodes usually operate in pairs, so the number of data nodes would be two, four, six, etc. The data nodes should have many cores, fast cores, enough RAM to store your data, and fast disks.Distributing Data Nodes that belong to one cluster over WAN is generally not recommended, unless the WAN connection is very stable and the latency is very low (at most a few milliseconds).
Note:- All cluster nodes are using centos 6.7 x64bit
Node Configuration
management node = 10.10.10.10
sql-node1= 10.10.10.20
sql-node2= 10.10.10.21
data-node1= 10.10.10.30
data-node2 = 10.10.10.31
apache/php webserver
_________________|_________________
|| ||
Mgmt|Data|SQLnode Data || SQLnode
Let’s begin by disabling SELinux on all nodes.
iptables -A INPUT -p tcp --dport 1186 -j ACCEPT
Download the MySQL cluster packages:-
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.12-1.el6.x86_64.rpm-bundle.tar [New GA release might be available]
[Download the latest GA version]
tar xvf MySQL*.tar
Install MySQL cluster server package:-[on all nodes]
yum install libaio numactl perl-Class-MethodMaker rsync wget vim openssh-server -y
yum remove -y mysql-libs
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-server-gpl-7.4.11-1.el6.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-shared-compat-gpl-7.4.11-1.el6.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-client-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-client-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-compat-gpl-7.4.11-1.el6.x86_64.rpm
install MySQL-Cluster-server-gpl-xxx on management node
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
- create config.ini for initiating cluster nodes
- Recommeded way to Configure and deploy production-class database clusters for MySQL
- http://severalnines.com/cluster-configurator/
vim config.ini
[tcp default]
SendBufferMemory=128M
ReceiveBufferMemory=128M
[ndb_mgmd]
NodeId=10
hostname=100.126.1.101
datadir=/var/lib/mycluster
[ndbd default]
NoOfReplicas=2
LockPagesInMainMemory=1
DataMemory=10165M
IndexMemory=1271M
ServerPort=2202
ODirect=1
#CompressedLCP=1
#CompressedBackup=1
#table related things
MaxNoOfConcurrentOperations=100000
MaxNoOfConcurrentTransactions=16384
StringMemory=25
MaxNoOfTables=4096
MaxNoOfAttributes=24756
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=512
TimeBetweenLocalCheckpoints=30
### Params for BACKUP
BackupMaxWriteSize=1M
BackupDataBufferSize=24M
BackupLogBufferSize=16M
BackupMemory=40M
FragmentLogFileSize=256M
InitFragmentLogFiles=SPARSE
NoOfFragmentLogFiles=40
RedoBuffer=64M
TransactionBufferMemory=8M
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=100
TimeBetweenEpochsTimeout=0
### Watchdog
TimeBetweenWatchdogCheckInitial=60000
### TransactionInactiveTimeout - should be enabled in Production
TransactionInactiveTimeout=60000
### New 7.1.10 redo logging parameters
RedoOverCommitCounter=3
RedoOverCommitLimit=20
### DISK DATA
SharedGlobalMemory=20M
DiskPageBufferMemory=64M
BatchSizePerLocalScan=512
[ndbd]
NodeId=20
hostname=202.94.66.36
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[ndbd]
NodeId=30
hostname=202.94.66.49
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[mysqld]
NodeId=40
hostname=202.94.66.44
[mysqld]
NodeId=50
"config.ini" 90L, 1510C written
[root@mgmtsql ~]# cat config.ini
[tcp default]
SendBufferMemory=128M
ReceiveBufferMemory=128M
[ndb_mgmd]
NodeId=10
hostname=100.126.1.101
datadir=/var/lib/mycluster
[ndbd default]
NoOfReplicas=2
LockPagesInMainMemory=1
DataMemory=10165M
IndexMemory=1271M
ServerPort=2202
ODirect=1
#CompressedLCP=1
#CompressedBackup=1
#table related things
MaxNoOfConcurrentOperations=100000
MaxNoOfConcurrentTransactions=16384
StringMemory=25
MaxNoOfTables=4096
MaxNoOfAttributes=24756
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=512
TimeBetweenLocalCheckpoints=30
### Params for BACKUP
BackupMaxWriteSize=1M
BackupDataBufferSize=24M
BackupLogBufferSize=16M
BackupMemory=40M
FragmentLogFileSize=256M
InitFragmentLogFiles=SPARSE
NoOfFragmentLogFiles=40
RedoBuffer=64M
TransactionBufferMemory=8M
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=100
TimeBetweenEpochsTimeout=0
### Watchdog
TimeBetweenWatchdogCheckInitial=60000
### TransactionInactiveTimeout - should be enabled in Production
TransactionInactiveTimeout=60000
### New 7.1.10 redo logging parameters
RedoOverCommitCounter=3
RedoOverCommitLimit=20
### DISK DATA
SharedGlobalMemory=20M
DiskPageBufferMemory=64M
BatchSizePerLocalScan=512
[ndbd]
NodeId=20
hostname=202.94.66.36
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[ndbd]
NodeId=30
hostname=202.94.66.49
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[mysqld]
NodeId=40
hostname=202.94.66.44
[mysqld]
NodeId=50
hostname=202.94.66.45
[mysqld] # this is kept empty for MySQL Cluster Native Backup Tool
[mysqld] # this is kept empty for MySQL Cluster Native Backup Tool
#empty api slots for multiple ndb cluster connection pool
#for more info - https://dev.mysql.com/doc/mysql-cluster-excerpt/5.5/en/mysql-cluster-program-options-mysqld.html#option_mysqld_ndb-cluster-connection-pool
[api]
[api]
[api]
[api]
Download and extract the Mysql cluster rpm's and install below package
yum install libaio numactl -y
yum install perl-Class-MethodMaker #needed for running perl scripts provided by mysqlcluster
yum remove -y mysql-libs
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
vim /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=10.10.10.10
[mysql_cluster]
ndb-connectstring=10.10.10.10
Download and extract the Mysql cluster rpm's and install below package
yum install libaio numactl -y
yum install perl-Class-MethodMaker #needed for running perl scripts provided by mysqlcluster
yum remove -y mysql-libs
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-compat-gpl-7.3.6-2.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm
vim /etc/my.cnf
[mysqld]
ndbcluster
default-storage-engine=NDBCLUSTER
net_read_timeout=60000
connect_timeout=60000
max_allowed_packet=32M
max_connections=1000
query_cache_type=1
query_cache_size=37748736
query_cache_limit=2097152
ndb-cluster-connection-pool=2
slow-query-log=1
slow-query-log-file=/var/log/mysql/slowquery.log
long-query_time=2
log-queries-not-using-indexes
[mysql_cluster]
ndb-connectstring=10.10.10.10
Run mysql with below command to change mysql root password
mysqld_safe &
your default root password is already set during installation and is stored in /root/.mysql_secret , copy it and use in next step
run below command to change root password and have recommended settings suggested during the process
# mysql_secure_installation
After setting the root password kill the mysql process
Starting the cluster first time
===============================
#on management node [10.10.10.10]:-
ndb_mgmd --config-file /root/config.ini --config-dir /usr/mysql-cluster --initial
#on Data nodes [10.10.10.20-21]
ndbd --initial
#on SQL nodes [10.10.10.30-31]
service mysql start
# On any one of the SQL node
# Create database on any one of the node or import existing DB
The SQL engine will need to be set to ndbcluster. If you are importing an existing database, export it using mysqldump, then perform the following commands.
vim YourDB.sql
:%s/engine=InnoDB/engine=ndbcluster/g
:%s/engine=MyISAM/engine=ndbcluster/g
mysql -uroot -p [YourDB] < YourDB.sql
Enable remote mysql user to use YourDB database [Run on both SQL node]
mysql> GRANT ALL ON YourDB.* TO remoteuser@'202.54.10.20' IDENTIFIED BY 'PA$$WORD123';
mysql> flush privileges;
MySQL Cluster has one or more of several major components. Typically each component will have its own server (a node). Those components are
sql node(front-end)
data node (back-end)
management node (central config,meta-data and etc)
Generally speaking, application requests are sent to the SQL nodes, which then talk to the data nodes and coordinates each other via management node(s) to actually recover the content you want.
For redundancy you need at least two data nodes.
MGM Node - holds the configuration for MySQL Cluster in a file called config.ini. It also writes a cluster log, and takes part in arbitration to prevent split-brain or network partitioning.
You are recommended to have two MGM Nodes for redundancy. Since MGM hardly use any resources, and is not involved in query processing or routing of requests, it can be colocated with the SQL Nodes/Access Nodes.
SQL Node / Access Node - the most common way to read/write data to the Data Nodes is by using the MySQL Server (aka SQL Node). A query comes into the SQL Node. The SQL Node parses, optimizes and executes the query on the Data Nodes.You need at least two SQL Nodes for redundancy. Nodes in the access layer should have fast CPUs, disks are not important, fast network to the data nodes (same specs as for the data nodes), and about 2+ GB of RAM (depending on the number of connections, per thread buffers etc). Do not co-locate the SQL Nodes/Access Nodes with the Data Nodes.
Data nodes usually operate in pairs, so the number of data nodes would be two, four, six, etc. The data nodes should have many cores, fast cores, enough RAM to store your data, and fast disks.Distributing Data Nodes that belong to one cluster over WAN is generally not recommended, unless the WAN connection is very stable and the latency is very low (at most a few milliseconds).
Note:- All cluster nodes are using centos 6.7 x64bit
Node Configuration
management node = 10.10.10.10
sql-node1= 10.10.10.20
sql-node2= 10.10.10.21
data-node1= 10.10.10.30
data-node2 = 10.10.10.31
apache/php webserver
_________________|_________________
|| ||
Mgmt|Data|SQLnode Data || SQLnode
Let’s begin by disabling SELinux on all nodes.
On management node:-
iptables -A INPUT -p tcp --dport 1186 -j ACCEPT
Download the MySQL cluster packages:-
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.12-1.el6.x86_64.rpm-bundle.tar [New GA release might be available]
[Download the latest GA version]
tar xvf MySQL*.tar
Install MySQL cluster server package:-[on all nodes]
yum install libaio numactl perl-Class-MethodMaker rsync wget vim openssh-server -y
yum remove -y mysql-libs
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-server-gpl-7.4.11-1.el6.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-shared-compat-gpl-7.4.11-1.el6.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-client-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-client-gpl-7.4.11-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-compat-gpl-7.4.11-1.el6.x86_64.rpm
install MySQL-Cluster-server-gpl-xxx on management node
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
- create config.ini for initiating cluster nodes
- Recommeded way to Configure and deploy production-class database clusters for MySQL
- http://severalnines.com/cluster-configurator/
vim config.ini
[tcp default]
SendBufferMemory=128M
ReceiveBufferMemory=128M
[ndb_mgmd]
NodeId=10
hostname=100.126.1.101
datadir=/var/lib/mycluster
[ndbd default]
NoOfReplicas=2
LockPagesInMainMemory=1
DataMemory=10165M
IndexMemory=1271M
ServerPort=2202
ODirect=1
#CompressedLCP=1
#CompressedBackup=1
#table related things
MaxNoOfConcurrentOperations=100000
MaxNoOfConcurrentTransactions=16384
StringMemory=25
MaxNoOfTables=4096
MaxNoOfAttributes=24756
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=512
TimeBetweenLocalCheckpoints=30
### Params for BACKUP
BackupMaxWriteSize=1M
BackupDataBufferSize=24M
BackupLogBufferSize=16M
BackupMemory=40M
FragmentLogFileSize=256M
InitFragmentLogFiles=SPARSE
NoOfFragmentLogFiles=40
RedoBuffer=64M
TransactionBufferMemory=8M
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=100
TimeBetweenEpochsTimeout=0
### Watchdog
TimeBetweenWatchdogCheckInitial=60000
### TransactionInactiveTimeout - should be enabled in Production
TransactionInactiveTimeout=60000
### New 7.1.10 redo logging parameters
RedoOverCommitCounter=3
RedoOverCommitLimit=20
### DISK DATA
SharedGlobalMemory=20M
DiskPageBufferMemory=64M
BatchSizePerLocalScan=512
[ndbd]
NodeId=20
hostname=202.94.66.36
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[ndbd]
NodeId=30
hostname=202.94.66.49
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[mysqld]
NodeId=40
hostname=202.94.66.44
[mysqld]
NodeId=50
"config.ini" 90L, 1510C written
[root@mgmtsql ~]# cat config.ini
[tcp default]
SendBufferMemory=128M
ReceiveBufferMemory=128M
[ndb_mgmd]
NodeId=10
hostname=100.126.1.101
datadir=/var/lib/mycluster
[ndbd default]
NoOfReplicas=2
LockPagesInMainMemory=1
DataMemory=10165M
IndexMemory=1271M
ServerPort=2202
ODirect=1
#CompressedLCP=1
#CompressedBackup=1
#table related things
MaxNoOfConcurrentOperations=100000
MaxNoOfConcurrentTransactions=16384
StringMemory=25
MaxNoOfTables=4096
MaxNoOfAttributes=24756
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=512
TimeBetweenLocalCheckpoints=30
### Params for BACKUP
BackupMaxWriteSize=1M
BackupDataBufferSize=24M
BackupLogBufferSize=16M
BackupMemory=40M
FragmentLogFileSize=256M
InitFragmentLogFiles=SPARSE
NoOfFragmentLogFiles=40
RedoBuffer=64M
TransactionBufferMemory=8M
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=100
TimeBetweenEpochsTimeout=0
### Watchdog
TimeBetweenWatchdogCheckInitial=60000
### TransactionInactiveTimeout - should be enabled in Production
TransactionInactiveTimeout=60000
### New 7.1.10 redo logging parameters
RedoOverCommitCounter=3
RedoOverCommitLimit=20
### DISK DATA
SharedGlobalMemory=20M
DiskPageBufferMemory=64M
BatchSizePerLocalScan=512
[ndbd]
NodeId=20
hostname=202.94.66.36
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[ndbd]
NodeId=30
hostname=202.94.66.49
datadir=/var/lib/mycluster-data
#BackupDataDir=/dir/to/backup
[mysqld]
NodeId=40
hostname=202.94.66.44
[mysqld]
NodeId=50
hostname=202.94.66.45
[mysqld] # this is kept empty for MySQL Cluster Native Backup Tool
[mysqld] # this is kept empty for MySQL Cluster Native Backup Tool
#empty api slots for multiple ndb cluster connection pool
#for more info - https://dev.mysql.com/doc/mysql-cluster-excerpt/5.5/en/mysql-cluster-program-options-mysqld.html#option_mysqld_ndb-cluster-connection-pool
[api]
[api]
[api]
[api]
On Data Nodes [ run on both (2) data nodes ]
Download and extract the Mysql cluster rpm's and install below package
yum install libaio numactl -y
yum install perl-Class-MethodMaker #needed for running perl scripts provided by mysqlcluster
yum remove -y mysql-libs
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
vim /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=10.10.10.10
[mysql_cluster]
ndb-connectstring=10.10.10.10
Configure SQL Nodes[run on both of the 2 nodes]
Download and extract the Mysql cluster rpm's and install below package
yum install libaio numactl -y
yum install perl-Class-MethodMaker #needed for running perl scripts provided by mysqlcluster
yum remove -y mysql-libs
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-compat-gpl-7.3.6-2.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm
vim /etc/my.cnf
[mysqld]
ndbcluster
default-storage-engine=NDBCLUSTER
net_read_timeout=60000
connect_timeout=60000
max_allowed_packet=32M
max_connections=1000
query_cache_type=1
query_cache_size=37748736
query_cache_limit=2097152
ndb-cluster-connection-pool=2
slow-query-log=1
slow-query-log-file=/var/log/mysql/slowquery.log
long-query_time=2
log-queries-not-using-indexes
[mysql_cluster]
ndb-connectstring=10.10.10.10
Run mysql with below command to change mysql root password
mysqld_safe &
your default root password is already set during installation and is stored in /root/.mysql_secret , copy it and use in next step
run below command to change root password and have recommended settings suggested during the process
# mysql_secure_installation
After setting the root password kill the mysql process
Starting the cluster first time
===============================
#on management node [10.10.10.10]:-
ndb_mgmd --config-file /root/config.ini --config-dir /usr/mysql-cluster --initial
#on Data nodes [10.10.10.20-21]
ndbd --initial
#on SQL nodes [10.10.10.30-31]
service mysql start
# On any one of the SQL node
# Create database on any one of the node or import existing DB
The SQL engine will need to be set to ndbcluster. If you are importing an existing database, export it using mysqldump, then perform the following commands.
vim YourDB.sql
:%s/engine=InnoDB/engine=ndbcluster/g
:%s/engine=MyISAM/engine=ndbcluster/g
mysql -uroot -p [YourDB] < YourDB.sql
Enable remote mysql user to use YourDB database [Run on both SQL node]
mysql> GRANT ALL ON YourDB.* TO remoteuser@'202.54.10.20' IDENTIFIED BY 'PA$$WORD123';
mysql> flush privileges;
linux, web, ispconfig3, python, bash, apache
msyql ndbcluster,
mysqlcluster
mount usb pendrive linux with read write privilege
To enable everyone rw access, the key is umask=0 option to mount command.
umask=0 is enough, uid and gid just for sake of clarity, so you don't see more 'root' owners than necessarily.
sudo mount -o umask=0,uid=nobody,gid=nobody /dev/something /mnt/somewhere
umask=0 is enough, uid and gid just for sake of clarity, so you don't see more 'root' owners than necessarily.
specify port for rsync
ubuntu 14.04.4
rsync version 3.1.0
rsync version 3.1.0
rsync -rvz -e 'ssh -p 2222' --progress --remove-sent-files ./dir user@host:/path
rsync --progress -avz -e 'ssh -p 44022' user1@100.126.1.106:/remoteshared /local/dir_A
mysql 5.5 install error on ubuntu 14.04.4 libdbi error hashsum mismatch
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libd/libdbi-perl/libdbi-perl_1.630-1_amd64.deb Hash Sum mismatch
download libdbi...deb file from here
http://packages.ubuntu.com/trusty/amd64/libdbi-perl/download
or
http://cz.archive.ubuntu.com/ubuntu/pool/main/libd/libdbi-perl/libdbi-perl_1.630-1_amd64.deb
dpkg -i libdbi-perl_1.630-1_amd64.deb
apt-get install mysql-server
download libdbi...deb file from here
http://packages.ubuntu.com/trusty/amd64/libdbi-perl/download
or
http://cz.archive.ubuntu.com/ubuntu/pool/main/libd/libdbi-perl/libdbi-perl_1.630-1_amd64.deb
dpkg -i libdbi-perl_1.630-1_amd64.deb
apt-get install mysql-server
linux, web, ispconfig3, python, bash, apache
mysql error
nginx php-fpm wordpress centos 6.x
nginx 1.8
php-fpm 5.3
mysql 5.5
cpu core = 1 , memory = 2G
updated: 2016 April 3
vim /etc/nginx/conf.d/default.conf
/etc/php-fpm.d/www.conf
listen = /var/run/php5-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0666
vim /etc/my.cnf
php-fpm 5.3
mysql 5.5
cpu core = 1 , memory = 2G
updated: 2016 April 3
vim /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_tokens off;
sendfile on;
tcp_nopush on;
keepalive_timeout 10;
#gzip on;
# Gzip on
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
ignore_invalid_headers on;
client_max_body_size 20m;
client_body_buffer_size 15m;
client_header_timeout 10s;
client_body_timeout 10s;
send_timeout 10s;
connection_pool_size 256;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
# Cache most accessed static files
open_file_cache max=10000 inactive=10m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
include /etc/nginx/conf.d/*.conf;
}
vim /etc/nginx/conf.d/default.conf
server {
#for non www to www.domain.com
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
root /var/www/html/example.com/public_html;
index index.php index.html index.htm;
location / {
root /var/www/html/example.com/public_html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
root /var/www/html/example.com/public_html;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock ;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
expires max;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
}
/etc/php-fpm.d/www.conf
listen = /var/run/php5-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0666
vim /etc/my.cnf
server {
#for non www to www.domain.com
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
root /var/www/html/example.com/public_html;
index index.php index.html index.htm;
location / {
root /var/www/html/example.com/public_html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
root /var/www/html/example.com/public_html;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock ;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
expires max;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
}
## setup phpmyadmin with basic auth
Download phpmyadmin from phpmyadmin.net/downloads (note the php version dependency: im using php 5.3)
https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-english.tar.gz
extract the file and move it to /usr/share as /usr/share/phpMyAdmin
tar xvfz phpMyAdmin-4.4.15.5-english.tar.gz mv phpMyAdmin-4.4.15.5-english /usr/share/phpMyAdmin ln -s /usr/share/phpMyAdmin /var/www/html/example.com/public_html/DBadmin ## Create basic auth file htpasswd -c /var/secret/.htpasswd jimmy #Add a location block in server { ... } location /DBadmin { auth_basic "Admin Login Required"; auth_basic_user_file /var/secret/.htpasswd; }
Fix phpmyadmin error
Error during session start; please check your PHP and/or webserver
log file and configure your PHP installation properly. Also ensure that
cookies are enabled in your browser.
This error on my case was due to incorrect php session directory where root:apache was the default file ownership
ls -l /var/lib/php/
drwxrwx---. 2 root apache 4096 Mar 1 08:02 session
The FIX
chown root:nginx /var/lib/php/session
Remove old session files inside /var/lib/php/session
https://stavrovski.net/blog/install-and-configure-nginx-mysql-php-fpm-in-centos-6
https://www.scalescale.com/tips/nginx/improving-wordpress-performance-nginx-php-fpm-mysql-memcached-w3-total-cache/
mysql optimization for Write heavy NON-ACID
Reference:-
https://blogs.oracle.com/MySQL/entry/comparing_innodb_to_myisam_performance
http://www.tocker.ca/2013/05/06/when-does-mysql-perform-io.html
https://www.percona.com/blog/2011/03/31/innodb-flushing-a-lot-of-memory-and-slow-disk/
https://www.percona.com/blog/2011/04/04/innodb-flushing-theory-and-solutions/
When does MySQL data get loaded in and out of cache?
A cold cache, or a poorly tuned cache can be responsible for a number of performance problems. If we look at the data and indexes of InnoDB, the cache responsible is called the InnoDB buffer pool.
In earlier versions of MySQL the default value for the settinginnodb_buffer_pool_size was 8M - which is a little out of date when you consider the recommended value to be 50-80% of system memory. In MySQL 5.5 the default value was increased to 128M, which is a comprimise made for users that may install MySQL on a development machine and not have it running as a dedicated server. In production, it is unlikely that you will buy a new server with less than 64GB of RAM, so it is quite typical that this setting is 50GB+
So lets talk about the behaviour of the InnoDB buffer pool -
Up until and including MySQL 5.5
When MySQL starts up, the buffer pool is completely empty. As queries are executed, MySQL will determine which pages are required - and if they are not in memory, they will be loaded from disk.
Initially, performance will be very poor - since there will be 100% cache misses, but over time as the buffer pool fills this should reduce.
Provided there is enough memory - MySQL will just keep loading pages into cache, and warm to a state where it will not have to perform any reads to the disk at all. Only writes will go to disk.
From MySQL 5.6 onwards
Because server warm time is becoming a more serious problem (it always existed, but it is exacerbated by us now having an abundance of RAM, but if we are using hard drives, they are not really any faster), Oracle introduced a feature in MySQL 5.6 - buffer pool warming.
What it does is on demand or on shutdown saves the addresses (space_id + page_id) of InnoDB pages to permanent storage.
Upon startup, these pages can then automatically be loaded back into memory straight away so that we can have cache misses for less time.
This feature is not turned on by default, but I suspect in a future version it may be. There are a number of other advantages to pre-warming such as being able to sort and merge read requests and load the data in much faster. Also, since it is only the addresses of pages being saved it only takes 8 bytes to point to each 16KB page, and there are no risks if there have been modifications since the last address saving operation ran.
Cache evictions
So we've described the "best case" so far, which is that data only gets loaded into cache and performance keeps getting better and better. However in practice, our cache is never unlimited. When our buffer pool gets to the point of being completely full it will need to free space in order to load new pages into memory. The behavior of this 'eviction' is version specific.
Up until MySQL 5.5
InnoDB previously used a classic Least Recently Used (LRU) algorithm. What this means is that each page has an order in a list. I like to think of it as a "Hot or not" score. Each time a page is accessed it gets promoted up the list to be considered "more hot". When it comes to freeing space, InnoDB just picks the least hot page and frees it from memory to make space for the next page.
In typical operation MySQL will not free pages from memory unless it needs to make space for another page. I say 'typical', because pages will be freed if a table is dropped for example.
MySQL 5.5 ONWARDS
There are a number of operational limitations with using a classic LRU implementation on a database which has many users, and typically more than one workload. For example lets say that everything is working fine and we've figured out what is "hot or not", noting that we do not need as much memory as we do data because in most cases there will be pages that are not accessed frequently. Now imagine that a series of queries come in from mysqldump that want to run tablescans to export the data. What can happen, is the pages loaded in from the tablescans push out some of the good pages in our buffer pool, and even worse, as soon as the mysqldump operation is complete, they will no longer be required. So now post-mysqldump we have random IO as we try and re-settle cache-contents again.
So in MySQL 5.5 the LRU was split into two sublists:
- A 'young' sublist for our frequently accessed pages (default: 63%)
- An 'old' sublist for our table scan page accesses (default: 37%)
The configuration variable innodb_old_blocks_pct was introduced to configure the old/new split, and a variable innodb_old_blocks_time(default in 5.5: 0, in 5.6: 1000) was introduced to specify a minimum amount of milliseconds that a freshly loaded page must stay in the old sublist before it is ellible to be promoted to the young sublist.
As mentioned in the manual, and in blog posts it frequently makes sense to configure the innodb_old_blocks_time to a larger value, for example 1000 (ms).
A note on page churn
If you do not have enough memory to hold all of your working set in memory, what will happen is that the buffer pool will start juggling as it churns pages out of memory only to load them back in soon after. A small amount of this is probably okay, but it can start to degrade performance. The traditional rule of thumb is called "the 5 minute rule". This means that if you load a page into memory and are going to need it again in the next five minutes - it should not need to be churned out.
The goal of caching is to avoid having to perform disk IO, which if we are talking about hard drives, each operation is about 20 million times slower than CPUs or about 100 thousand times slower than memory.
So today I want to cover the subject of when are we required to do IO?But before I get there I first have to describe how IO works on all our modern operating systems.
An Introduction to Buffered IO
When you read or write to a file, by default you are speaking to a layer in between you and your disks called buffered IO. This layer is designed to increase performance and adds important features such as caching. Without going into this in detail, it's important to note that:
When you READ data, you may be reading from the disk or a cache provided by the operating system.
When you WRITE data you are not writing to the disks, but to a queue which will be flushed in the background. This queue is a little bit different to how a message queue in an application may behave: it usually has a hard limit to the number of outstanding requests, and it does not always complete requests in purely FIFO order - but an optimized order that still makes sure there is a maximum time window a request can take (example).
WRITE operations are not crash-safe by default! The operating system does provide a way of syncing a file to make sure all of the buffers are flushed down to the disk; an fsync.
An fsync is usually very expensive because it forces the queue to empty, and reduces the amount of request reordering and merging. Sequential IO is really important for hard drives.
So now lets look at IO created by a MySQL Server using the InnoDB storage engine (default since MySQL 5.5).
Reading pages into memory
If a page is not located in cache already, InnoDB will load it into memory in the foreground while queries are waiting, unless the page loading was triggered via a read ahead operation in which case it will use one of its innodb_read_io_threads to make this happen in the background.
Writing modified pages back to disk
When you make a modification to an InnoDB page, InnoDB does notwrite it immediately to disk. Instead a delta is written to the transaction log (see below).
These modified-only-in-memory pages are typically reffered to as dirty pages. Writing down dirty pages happens as part of InnoDB's background process which continually performs work every 1 second, and it adjusts well to peaks and troughs in load with a feature introduced in MySQL 5.5 and further improved in MySQL 5.6 calledadaptive flushing. However, if there are too many dirty pages and there is not enough free space, InnoDB may be forced to synchronously flush a dirty page to make free space.
This delaying allows InnoDB to perform fewer random writes, since there will usually be multiple changes to the same page, or by default pages in the same extent (1MB allocation unit on disk). MySQL also 5.6 allows you to disable this for SSDs.
(Note: Domas makes a comment about the doublewrite buffer below, and how I might be over-selling request merging :) It's outside of the scope covered here, but described in Facebook's blog and the MySQL manual).
Writing the transaction log
Any time you modify an InnoDB page a record of this modification is made to InnoDB's transaction log system (ib_logfile1 and ib_logfile0on disk). This transaction log is designed to be sequentially written, and unless the server crashes the server will only ever write and not read from it.
The log files are cyclical by design. You can think of them as a concatentation of two (by default) that behave similar to tread on a tank. So the first one is filled, then the second, then InnoDB will start filling the first again. The writes to the transaction log will be 512B aligned and using the operating system's buffered IO. InnoDB actually relies on the operating system here to provide a cache of the log (which is not guaranteed). Since these writes are 512B - and a typical page is 4K what will happen without enough cache, is that the page will neeed to be read first, to make the partial-modification, then written back.
To reduce log file IO, InnoDB also has a log buffer (configured byinnodb_log_buffer_size) that is filled with pending modifications which will be written and synced on any COMMIT by default.
Writing the slow log and general log
The general log is written out as each event is generated. It will be a sequential write, and is never synced or never read back (should be fairly low cost).
The slow query log is written out after query execution has finished. Similiar to the general log, it should also be very log cost.
Why I say "should" is that this also depends on filesystem choice. Anfsync under ext3 does not flush one file, but all files. This has become known as the great fsync() bug. Also, the operating system will usually have a limit the amount of modifications queued up waiting to be written, so too much log activity could cause synchronous writing and impact other operations (see Domas' comment below).
IO on a Replication Master (aka binary log enabled)
The binary log is sequential IO written to as part of a COMMIToperation, but by default it is never flushed, so it is not crash-safe! It requires setting sync_binlog=1.
The binary log does not have its own in memory buffers, so it's possible if an out of date slave came online that the master server may need to read old binary log files in order to send previous server events. However in practice the master pushes changes to online slaves as they are committed so it should be write-only.
The server maps changes in the binary log to InnoDB's transaction log to ensure consistency by default.
IO on a Replication Slave
The relay logs are in the same format as the binary logs, but the IO semantics are a little different. The slave's IO_THREAD retrieves new events from the master and writes sequential IO relay log files on the slave. Then the SQL_THREAD then reads the changes from the relay logs and applies them. This read operation does not have any caches inside of MySQL to ensure no IO is performed, and instead relies on the operating system's buffered IO to assist. It's possible to decrease the amount of relay logs kept on the slave to assist in a better 'cache fit', but this also means that if the master fails there may be changes the slave was not aware of.
Writing the relay logs is not crash-safe by default, and requires settingsync_relay_log=1.
Also, the status files which maintain a mapping between the relay logs and master's binary logs (which are not a 1:1) are also not crash-safe. A new option in MySQL 5.6 allows you to use an internal table to maintain these status files for added safety, but it is not enabled by default. The new options are master-info-repository and relay-log-info-repository.
Summary
I am sure I made a couple of simplifications (for example not describing the doublewrite buffer), but hopefully it's a good start. There are a couple of key take away points I want to make:
Reads are foregrounded (except read-ahead) and don't provide the same opportunity reorder and merge - so that makes them typically random IO and very expensive. If you run a diagnostic command like iostat and you see a lot of reads on a warmed up server - this is something adding memory can usually solve.
Most writes are sequential or backgrounded. Both InnoDB and the operating system try to produce sequential IO and merge requests.
While InnoDB has always been crash safe by default, MySQL has not. There are new features in MySQL 5.6 which makes replication more reliable
https://blogs.oracle.com/MySQL/entry/comparing_innodb_to_myisam_performance
http://www.tocker.ca/2013/05/06/when-does-mysql-perform-io.html
https://www.percona.com/blog/2011/03/31/innodb-flushing-a-lot-of-memory-and-slow-disk/
https://www.percona.com/blog/2011/04/04/innodb-flushing-theory-and-solutions/
When does MySQL data get loaded in and out of cache?
A cold cache, or a poorly tuned cache can be responsible for a number of performance problems. If we look at the data and indexes of InnoDB, the cache responsible is called the InnoDB buffer pool.
In earlier versions of MySQL the default value for the settinginnodb_buffer_pool_size was 8M - which is a little out of date when you consider the recommended value to be 50-80% of system memory. In MySQL 5.5 the default value was increased to 128M, which is a comprimise made for users that may install MySQL on a development machine and not have it running as a dedicated server. In production, it is unlikely that you will buy a new server with less than 64GB of RAM, so it is quite typical that this setting is 50GB+
So lets talk about the behaviour of the InnoDB buffer pool -
Up until and including MySQL 5.5
When MySQL starts up, the buffer pool is completely empty. As queries are executed, MySQL will determine which pages are required - and if they are not in memory, they will be loaded from disk.
Initially, performance will be very poor - since there will be 100% cache misses, but over time as the buffer pool fills this should reduce.
Provided there is enough memory - MySQL will just keep loading pages into cache, and warm to a state where it will not have to perform any reads to the disk at all. Only writes will go to disk.
From MySQL 5.6 onwards
Because server warm time is becoming a more serious problem (it always existed, but it is exacerbated by us now having an abundance of RAM, but if we are using hard drives, they are not really any faster), Oracle introduced a feature in MySQL 5.6 - buffer pool warming.
What it does is on demand or on shutdown saves the addresses (space_id + page_id) of InnoDB pages to permanent storage.
Upon startup, these pages can then automatically be loaded back into memory straight away so that we can have cache misses for less time.
This feature is not turned on by default, but I suspect in a future version it may be. There are a number of other advantages to pre-warming such as being able to sort and merge read requests and load the data in much faster. Also, since it is only the addresses of pages being saved it only takes 8 bytes to point to each 16KB page, and there are no risks if there have been modifications since the last address saving operation ran.
Cache evictions
So we've described the "best case" so far, which is that data only gets loaded into cache and performance keeps getting better and better. However in practice, our cache is never unlimited. When our buffer pool gets to the point of being completely full it will need to free space in order to load new pages into memory. The behavior of this 'eviction' is version specific.
Up until MySQL 5.5
InnoDB previously used a classic Least Recently Used (LRU) algorithm. What this means is that each page has an order in a list. I like to think of it as a "Hot or not" score. Each time a page is accessed it gets promoted up the list to be considered "more hot". When it comes to freeing space, InnoDB just picks the least hot page and frees it from memory to make space for the next page.
In typical operation MySQL will not free pages from memory unless it needs to make space for another page. I say 'typical', because pages will be freed if a table is dropped for example.
MySQL 5.5 ONWARDS
There are a number of operational limitations with using a classic LRU implementation on a database which has many users, and typically more than one workload. For example lets say that everything is working fine and we've figured out what is "hot or not", noting that we do not need as much memory as we do data because in most cases there will be pages that are not accessed frequently. Now imagine that a series of queries come in from mysqldump that want to run tablescans to export the data. What can happen, is the pages loaded in from the tablescans push out some of the good pages in our buffer pool, and even worse, as soon as the mysqldump operation is complete, they will no longer be required. So now post-mysqldump we have random IO as we try and re-settle cache-contents again.
So in MySQL 5.5 the LRU was split into two sublists:
- A 'young' sublist for our frequently accessed pages (default: 63%)
- An 'old' sublist for our table scan page accesses (default: 37%)
The configuration variable innodb_old_blocks_pct was introduced to configure the old/new split, and a variable innodb_old_blocks_time(default in 5.5: 0, in 5.6: 1000) was introduced to specify a minimum amount of milliseconds that a freshly loaded page must stay in the old sublist before it is ellible to be promoted to the young sublist.
As mentioned in the manual, and in blog posts it frequently makes sense to configure the innodb_old_blocks_time to a larger value, for example 1000 (ms).
A note on page churn
If you do not have enough memory to hold all of your working set in memory, what will happen is that the buffer pool will start juggling as it churns pages out of memory only to load them back in soon after. A small amount of this is probably okay, but it can start to degrade performance. The traditional rule of thumb is called "the 5 minute rule". This means that if you load a page into memory and are going to need it again in the next five minutes - it should not need to be churned out.
The goal of caching is to avoid having to perform disk IO, which if we are talking about hard drives, each operation is about 20 million times slower than CPUs or about 100 thousand times slower than memory.
So today I want to cover the subject of when are we required to do IO?But before I get there I first have to describe how IO works on all our modern operating systems.
An Introduction to Buffered IO
When you read or write to a file, by default you are speaking to a layer in between you and your disks called buffered IO. This layer is designed to increase performance and adds important features such as caching. Without going into this in detail, it's important to note that:
When you READ data, you may be reading from the disk or a cache provided by the operating system.
When you WRITE data you are not writing to the disks, but to a queue which will be flushed in the background. This queue is a little bit different to how a message queue in an application may behave: it usually has a hard limit to the number of outstanding requests, and it does not always complete requests in purely FIFO order - but an optimized order that still makes sure there is a maximum time window a request can take (example).
WRITE operations are not crash-safe by default! The operating system does provide a way of syncing a file to make sure all of the buffers are flushed down to the disk; an fsync.
An fsync is usually very expensive because it forces the queue to empty, and reduces the amount of request reordering and merging. Sequential IO is really important for hard drives.
So now lets look at IO created by a MySQL Server using the InnoDB storage engine (default since MySQL 5.5).
Reading pages into memory
If a page is not located in cache already, InnoDB will load it into memory in the foreground while queries are waiting, unless the page loading was triggered via a read ahead operation in which case it will use one of its innodb_read_io_threads to make this happen in the background.
Writing modified pages back to disk
When you make a modification to an InnoDB page, InnoDB does notwrite it immediately to disk. Instead a delta is written to the transaction log (see below).
These modified-only-in-memory pages are typically reffered to as dirty pages. Writing down dirty pages happens as part of InnoDB's background process which continually performs work every 1 second, and it adjusts well to peaks and troughs in load with a feature introduced in MySQL 5.5 and further improved in MySQL 5.6 calledadaptive flushing. However, if there are too many dirty pages and there is not enough free space, InnoDB may be forced to synchronously flush a dirty page to make free space.
This delaying allows InnoDB to perform fewer random writes, since there will usually be multiple changes to the same page, or by default pages in the same extent (1MB allocation unit on disk). MySQL also 5.6 allows you to disable this for SSDs.
(Note: Domas makes a comment about the doublewrite buffer below, and how I might be over-selling request merging :) It's outside of the scope covered here, but described in Facebook's blog and the MySQL manual).
Writing the transaction log
Any time you modify an InnoDB page a record of this modification is made to InnoDB's transaction log system (ib_logfile1 and ib_logfile0on disk). This transaction log is designed to be sequentially written, and unless the server crashes the server will only ever write and not read from it.
The log files are cyclical by design. You can think of them as a concatentation of two (by default) that behave similar to tread on a tank. So the first one is filled, then the second, then InnoDB will start filling the first again. The writes to the transaction log will be 512B aligned and using the operating system's buffered IO. InnoDB actually relies on the operating system here to provide a cache of the log (which is not guaranteed). Since these writes are 512B - and a typical page is 4K what will happen without enough cache, is that the page will neeed to be read first, to make the partial-modification, then written back.
To reduce log file IO, InnoDB also has a log buffer (configured byinnodb_log_buffer_size) that is filled with pending modifications which will be written and synced on any COMMIT by default.
Writing the slow log and general log
The general log is written out as each event is generated. It will be a sequential write, and is never synced or never read back (should be fairly low cost).
The slow query log is written out after query execution has finished. Similiar to the general log, it should also be very log cost.
Why I say "should" is that this also depends on filesystem choice. Anfsync under ext3 does not flush one file, but all files. This has become known as the great fsync() bug. Also, the operating system will usually have a limit the amount of modifications queued up waiting to be written, so too much log activity could cause synchronous writing and impact other operations (see Domas' comment below).
IO on a Replication Master (aka binary log enabled)
The binary log is sequential IO written to as part of a COMMIToperation, but by default it is never flushed, so it is not crash-safe! It requires setting sync_binlog=1.
The binary log does not have its own in memory buffers, so it's possible if an out of date slave came online that the master server may need to read old binary log files in order to send previous server events. However in practice the master pushes changes to online slaves as they are committed so it should be write-only.
The server maps changes in the binary log to InnoDB's transaction log to ensure consistency by default.
IO on a Replication Slave
The relay logs are in the same format as the binary logs, but the IO semantics are a little different. The slave's IO_THREAD retrieves new events from the master and writes sequential IO relay log files on the slave. Then the SQL_THREAD then reads the changes from the relay logs and applies them. This read operation does not have any caches inside of MySQL to ensure no IO is performed, and instead relies on the operating system's buffered IO to assist. It's possible to decrease the amount of relay logs kept on the slave to assist in a better 'cache fit', but this also means that if the master fails there may be changes the slave was not aware of.
Writing the relay logs is not crash-safe by default, and requires settingsync_relay_log=1.
Also, the status files which maintain a mapping between the relay logs and master's binary logs (which are not a 1:1) are also not crash-safe. A new option in MySQL 5.6 allows you to use an internal table to maintain these status files for added safety, but it is not enabled by default. The new options are master-info-repository and relay-log-info-repository.
Summary
I am sure I made a couple of simplifications (for example not describing the doublewrite buffer), but hopefully it's a good start. There are a couple of key take away points I want to make:
Reads are foregrounded (except read-ahead) and don't provide the same opportunity reorder and merge - so that makes them typically random IO and very expensive. If you run a diagnostic command like iostat and you see a lot of reads on a warmed up server - this is something adding memory can usually solve.
Most writes are sequential or backgrounded. Both InnoDB and the operating system try to produce sequential IO and merge requests.
While InnoDB has always been crash safe by default, MySQL has not. There are new features in MySQL 5.6 which makes replication more reliable
linux, web, ispconfig3, python, bash, apache
mysql,
mysql optimization
setup sftp only user for web
Step 1: Create a dedicated sFTP group and a dedicated sFTP user
groupadd sftpusers
useradd -G sftpusers -s /sbin/nologin user1
passwd user1
Here, the group sftpusers is a dedicated sFTP group, the user user1 is a dedicated sFTP user which is forbidden to log in using SSH.Step 2: Modify the configuration of the sshd service
Open the configuration file of the sshd service:vi /etc/ssh/sshd_config
Find the line:Subsystem sftp /usr/libexec/openssh/sftp-server
Replace it with:Subsystem sftp internal-sftp
Append the following lines to the end of the file. The group name sftpusers should be the same as the one you specified earlier.Subsystem sftp internal-sftp
Match Group sftpuser
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
AllowAgentForwarding no
Save and quit::wq
Restart the sshd service to put your changes into effect.systemctl restart sshd.service
Step 3: Create a dedicated directory for the sFTP-only user
You need to specify a directory for the sFTP-only user and make sure that this user can only play around in this directory:chown -R root /home/user1
chmod -R 755 /home/user1
mkdir /home/user1/files
chown user1. /home/user1/files
Now, the user user1 can only upload and/or download files in the directory /home/user1/files, he or she can never touch other users' files.Step 4: Create more sFTP-only users
If you need more sFTP-only users, you can create them in the same fashion:useradd -G sftpusers -s /sbin/nologin user2
passwd user2
chown -R root /home/user2
chmod -R 755 /home/user2
mkdir /home/user2/files
chown user2. /home/user2/files
That's it. Each user account created in this fashion will be denied
if you use it to log in the system. These user accounts can be used only
in sFTP programs.send mail attachment with mutt from terminal
echo "body part" | mutt -s "subject header file" -a radius.tar.gz -- ndgen@qmail.com
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com
echo "This is the message body" | mutt -s "subject of message" -e 'my_hdr From:sender@company.com' -- rcv1@exg.org,jack@abc.com
#!/bin/bash
bounced='/var/log/bouncedmail/bouncedlog.txt'
filteredlist='/var/log/bouncedmail/bounced-maillist.txt'
rm -f $bounced
rm -f $filteredlist
curmonth=`date | cut -d' ' -f 2`
for var in `ls /var/log/maillog*`
do
if [ $# -eq 3 ]
then
echo "Script error please supply log filename and month For Example. scanmaillog.sh maillog-20170130 "; exit 1;
else
grep "status=bounced" $var | grep -v classic.com.np | grep $curmonth | awk '{ print $1" " $2 " "$7; }' | sed -e 's/to=<//g' -e 's/>,//g' >> /var/log/bouncedmail/bouncedlog.txt
fi
cat /var/log/bouncedmail/bouncedlog.txt | cut -d' ' -f 3 | sort | uniq >> /var/log/bouncedmail/bounced-maillist.txt
done
cat $filteredlist | grep -v "axiata" | sort | uniq > /var/log/bouncedmail/filtered.txt
cat /var/log/bouncedmail/filtered.txt | mail -s "Total: `wc -l $bounced | cut -d' ' -f1` emails bounced for month of `date | cut -d' ' -f2` 2017" -S smtp="mail.classic.com.np:25" urgen@classic.com.np,wilson@classic.com.np,jayesh@classic.com.np,manu@classic.com.np;
git for managing web public html directory
On GitServer [ ip:192.168.0.123 ]
useradd gituser1 -m
-s /bin/bash
mkdir -p
/project/ecommerceweb
chown -R
gituser1:gituser1 /project
cd
/project/ecommerceweb
git init --bare
Note:-To have
separate worktree
vim
/project/ecommerceweb/hooks/post-receive
#!/bin/bash
GIT_WORK_TREE=/webdir/web
git checkout -f
#<save/exit>
chmod +x
/project/ecommerceweb/hooks/post-receive
On git client [ ip:192.168.0.123 ]
#copy your ssh
public key to git server for user "gituser1" for
passwordless ssh and public/private key based authentication
ssh-copyid
gituser1@192.168.0.239
git clone
ssh://gituser1@192.168.0.239/project/ecommerceweb
cd ecommerceweb
vim index.php
... < add your
code /save/exit> ..
git add .
# add files to index
git commit -m
"initial commit added index page" #Record changes to
the repository
git push origin
master #push changes to git server
git status
git remote show
origin #shows your remote gitserver url OR use
git config --get
remote.origin.url
View changed
files in your working repository
## git status
Git log
show all git
commits
## git log
Git diff
made changes to
tracked files
## git diff
Git branch
list all branches
## git branch
Subscribe to:
Posts (Atom)