November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Nginx server 10000 concurrent optimization test (ab test tool)

1.nginx monitoring module

1) Compile nginx with the parameter –with-http_stub_status_module

#/usr/local/nginx/sbin/nginx -V
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_mo

./configure --prefix=/usr/local
    --user=nginx 
    --group=nginx
    --with-http_ssl_module
    --with-http_realip_module
    --http-client-body-temp-path=/usr/local/var/tmp/nginx/client 
    --http-proxy-temp-path=/usr/local/var/tmp/nginx/proxy 
    --http-fastcgi-temp-path=/usr/local/var/tmp/nginx/fcgi 
    --http-scgi-temp-path=/usr/local/var/tmp/nginx/scgi 
    --http-uwsgi-temp-path=/usr/local/var/tmp/nginx/uwsgi 
    --with-http_geoip_module 
    --with-http_stub_status_module

2) Modify the nginx configuration file and add the monitoring status configuration

Add the following code to the server block of nginx.conf

location /nginx_status {
    # Turn on nginx stats
    stub_status on;
    # I do not need logs for stats
    access_log   off;
    # Security: Only allow access from 192.168.1.100 IP #
    #allow 192.168.1.100;
    # Send rest of the world to /dev/null #
    #deny all;
}
xplanation:
   Active connections: The number of active connections initiated by the backend. 
  Server accepted handling requests: Nginx handled a total of 655 connections, successfully created 655 times handshake (proved no failure in the middle), handled a total of 1985 requests. 
  Reading: Nginx Number of Header messages read to the client. 
  Writing: Nginx Number of Header messages returned to the client. 
  Waiting: In the case of keep-alive, this value is equal to active - (reading + writing), meaning that Nginx 
 
/usr/local/nginx/sbin/nginx -t  
/usr/local/nginx/sbin/nginx -s reload
 2. Set the maximum number of connections (50000) / tcp speed up the recovery of the number of conn


echo 50000 > /proc/sys/net/core/somaxconn

echo 1 > /proc/sys/net/ipv4/tcp_tw/recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 0 > /proc/sys/net/ipv4/tcp_syncookies

 

3. set to open more files

ulimit -n 50000

vim /etc/nginx/nginx.conf
worker_rlimit_nofile 10000;
events{

worker_connections 10240;
}

/usr/sbin/nginx -t
/usr/sbin/nginx -s reload

 

 

4.ab -c 5000 -n 100000 http://192.168.1.129/index.html 

erver Software: nginx/1.4.6
Server Hostname: 192.168.63.129
Server Port: 80

Document Path: /index.html
Document Length: 65 bytes

Concurrency Level: 5000
Time taken for tests: 46.416 seconds
Complete requests: 100000
Failed requests: 90202
(Connect: 0, Receive: 0, Length: 90202, Exceptions: 0)
Write errors: 0
Non-2xx responses: 90282
Total transferred: 36624606 bytes
HTML transferred: 18815922 bytes
Requests per second: 2154.42 [#/sec] (mean)
Time per request: 2320.813 [ms] (mean)
Time per request: 0.464 [ms] (mean, across all concurrent requests)
Transfer rate: 770.55 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 18 1251 2273.8 824 31950
Processing: 298 839 299.1 855 6307
Waiting: 1 648 298.8 651 6194
Total: 408 2090 2323.2 1697 36083

Percentage of the requests served within a certain time (ms)
50% 1697
66% 1758
75% 1802
80% 1843
90% 2583
95% 4601
98% 8399
99% 8807
100% 36083 (longest request)

 

Linux server found strange port handling methods

Generally in the beginning of the need for their own company’s IT environment to have a general understanding of 1-2 months after the need to open the port has a clear understanding of what the port is used to do, whether it is illegal open port , Their own mind to be the number of unknown Trojans through a strange port to the black out on the embarrassment. So as the operation and maintenance personnel need to open the port of each company has a clear understanding of the port, at the same time have to face the strange port how to determine the port corresponding to what kind of service, the service is illegal and so on.

Need to use the command :

Ss -tnl       shows all tcp has been listening on the port

 Lsof -i : The port   displays all the processes that open the port

 

Working example:

One day through ss -tnl found that do not know the port is being monitored

 

For the port 49994 I do not know why it is doing, so use the lsof-i command to see which ports are open

It is found here that the port corresponds to the rpc.statd command.

(If prompted not to remember the command yum install-y lsof)

If you do not know rpc.statd, a very simple way is baidu

Through the baidu can know that the order is nfslock service of a process, if you want to close the port only need to close nfslock service

Service nfslock stop

And then perform ss-tnl found 49994 port disappeared

In the future if you encounter an unknown port can use the above method to judge.

Garbage Priority Garbage Collector

Garbage Priority Garbage Collector (G1 GC) Use notes

G1 GC is a new garbage collection strategy, starting with JDK7, mainly for server-side JVM, and large memory applications, the goal is to achieve similar high-throughput CMS. G1 is still the idea of ??sub-management, the main use of the idea of ??block management, through the memory is divided into no more than 2048 blocks, each size between 1M-32M, Eden, Survivor space and old generation are one Series of discontinuous logical regions.

Here do not talk about the concrete realization of G1 ideas, only record how to configure and use.

Start the G1 GC

-XX: + UseG1GC

Several parameters and default values

  • -XX:MaxGCPauseMillis=200 Maximum pause time, which is a target value, JVM will try to close to this target, the default value of 200.
  • -XX:G1HeapRegionSize=n G1 area block size, 1M-32M, must be a power of 2, G1 will be based on the size of the block plan is not more than 2048 blocks.
  • -XX:G1NewSizePercent=5 Young generation in the heap in the smallest percentage, the default value is 5%
  • -XX:G1MaxNewSizePercent=60 The maximum percentage of young generations in the heap, the default is 60%
  • -XX:ParallelGCThreads=nSets the value of the STW worker thread. Set the value of n to the number of logical processors. The value of n is the same as the number of logical processors, up to 8. If there are more than eight logical processors, set the value of n to about 5/8 of the number of logical processors. This applies to most cases unless it is a larger SPARC system, where the value of n can be about 5/16 of the number of logical processors.
  • -XX:ConcGCThreads=nSets the number of threads that are marked in parallel. Set n to 1/4 of the amount of parallel garbage collection threads (ParallelGCThreads).
  • -XX:InitiatingHeapOccupancyPercent=45 Mark the garbage threshold, the default 45%
  • -XX:G1ReservePercent=10Set the percentage of reserved memory as free space to reduce the risk of target space spillovers. The default value is 10%.

Suggest

  • Avoid using the -Xmn option or other related options such as -XX: NewRatio to explicitly set the young generation size. Fixed young generation size will cover the pause time target.
  • Pause time goals are not too small, because pause time and throughput are a contradictory indicator.

example

This is a simple configuration of tomcat startup

Export CATALINA_OPTS = “$ CATALINA_OPTS -Xms10g”
Export CATALINA_OPTS = “$ CATALINA_OPTS -Xmx10g”
Export CATALINA_OPTS = “$ CATALINA_OPTS -Xss512k”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + DisableExplicitGC”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + HeapDumpOnOutOfMemoryError”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + UnlockExperimentalVMOptions”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + UseG1GC”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: MaxGCPauseMillis = 200”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: G1NewSizePercent = 40”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: G1MaxNewSizePercent = 80”

G1NewSizePercentAnd G1MaxNewSizePercentexperimental properties, so please through the -XX:+UnlockExperimentalVMOptionsopen test option.

Done.

tomcat monitor script

#!/bin/bash
echo $(date ‘+%Y-%m-%d %H:%M:%S’)
whoami
JAVA_HOME=/opt/java/jdk1.8.0_40
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
port=8086
sn=“tomcat-image-$port
th=“/home/dev/tomcat/$sn
url=“http://you-app-server/”
tomcat=`ps -ef | grep java | grep $sn | grep $port | wc -l`
if [ $tomcat -eq 0 ]
then
echo $sn stoped.
echo starting $sn ……
$th/bin/startup.sh
fi
if [ $tomcat -ge 1 ]
then
tpid=`ps -ef | grep java | grep $sn | grep $port | awk ‘{print $2}’`
echo $sn is running, pid = $tpid
httpStatus=`curl -I $url 2>/dev/null | grep HTTP | awk ‘{print $2}’`
echo $httpStatus
if [[ -z $httpStatus || $httpStatus -ge 500 ]]
then
echo killing $sn ……
kill -9 $tpid
echo starting $sn ……
$th/bin/startup.sh
fi
fi
crontab -e
*/5 * * * * /tomcat-inspector/image.sh >> /logs/image.log 2>&1

How To Configure a Redis Cluster on CentOS 7

yum install gcc make
cd ~
mkdir init
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar -zxvf redis-3.2.3.tar.gz 
cd redis-3.2.3
make 
make install

#cd utils
#./install_server.sh

cd src/
cp redis-server redis-cli /usr/local/bin
cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump /usr/local/bin

mkdir /etc/redis
mkdir -p /var/lib/redis/6379

Set the vm.overcommit_memory to 1, which means always, this will avoid data to be truncated, take a look here for more.

sysctl -w vm.overcommit_memory=1

Change the maximum of backlog connections some value higher than the value on tcp-backlog option of redis.conf, which defaults to 511. You can find more on sysctl based ip networking “tunning” on kernel.org website.

sysctl -w net.core.somaxconn=512

Disable transparent huge pages support, that is known to cause latency and memory access issues with Redis.

echo never > /sys/kernel/mm/transparent_hugepage/enabled

Redis.conf is the Redis configuration file, however you will see the file named as 6379.conf here, where the number is the same as the network port is listening to. This name is recommended if you are going to run more than one Redis instance.

cp redis.conf /etc/redis/6379.conf
vim /etc/redis/6379.conf

daemonize yes #note
pidfile /var/run/redis_6379.pid
port 6379
loglevel notice
logfile /var/log/redis_6379.log
dir /var/lib/redis/6379

Starting at boot

cp utils/redis_init_script /etc/init.d/redis_6379
vim /etc/systemd/system/redis_6379.service

[Unit]
Description=Redis on port 6379

[Service]
Type=forking
ExecStart=/etc/init.d/redis_6379 start
ExecStop=/etc/init.d/redis_6379 stop

[Install]
WantedBy=multi-user.target

vim /etc/sysctl.conf

vm.overcommit_memory = 1
net.core.somaxconn=512

For the transparent huge pages support there is no sysctl directive, so you can put the command at the end of /etc/rc.local

echo never > /sys/kernel/mm/transparent_hugepage/enabled

 

Configure Redis Master

vi /etc/redis.conf

daemonize yes #note
tcp-keepalive 60
#bind 127.0.0.1
requirepass your_redis_master_password
maxmemory-policy noeviction
appendonly yes
appendfilename "appendonly.aof"

restart if makeinstall
redis-server /etc/redis/6379.conf

Configure Redis Slave

daemonize yes #note
#bind 127.0.0.1
requirepass your_redis_slave_password
slaveof your_redis_master_ip 6379
masterauth your_redis_master_password

Realize MySQL database automatic backup under Linux

1.Linux under MySQL to create a user backup role, and granted the role of SELECT, RELOAD, SHOW DATABASES, LOCK TABLES and other permissions.

 

mysql> create user 'backuper'@'localhost' identified by '********';
Query OK, 0 rows affected (0.00 sec)

mysql> grant SELECT, RELOAD, SHOW DATABASES, LOCK TABLES on *.* to backuper@localhost;
Query OK, 0 rows affected (0.00 sec)

2. In the system to find a relatively large hard disk to create a backup directory, and create a shell script

vim backup_mohan_db.sh

#!/bin/bash
mysqldump -ubackuper -p******** qianyu_veeker_db > /home/mysql/backup/mohan_db_$(date +%Y%m%d_%H%M%S)

3. To add the scheduled task, you need to install the crontab 
vixie-cron package is the main program for cron; the 
crontabs package is the program used to install, uninstall, or list the tables used to drive the cron daemon.

[root@~]# yum -y install vixie-cron
[root@~]# yum -y install crontabs

4. Set boot to start

[root@ ~]# chkconfig --level 345 crond on

[root@linuxidc etc]# vim crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
#|  .------------- hour (0 - 23)
#|  |  .---------- day of month (1 - 31)
#|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
#|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
#|  |  |  |  |
#*  *  *  *  * user-name command to be executed
0 0 * * * /home/mysql/backup/mohan_db.sh

MySQL 5.7 forget the root password

surroundings

CentOS 6.6 X86_64

background

Forget how to do root, forget to initialize MySQL generated when the random password how to do, or simply did not register that random password, do not tell me to clear all the data under data, reinitialize, of course, you have to be so wayward can also be.
Do not pull, the following is the title.

reference

Http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

operating

There are several ways in the official document, I read the next, you remember the following I said a bar, the other you try it, so good to make me no matter

Use –skip-grant-tables to start mysql server
bin / mysqld_safe –user = mysql01 –skip-grant-tables – skip-networking &

Two options are meaning –
skip-grant-tables skip authorization –
skip-networking does not allow remote network connection

Skip-networking can not, to prevent other users to connect the remote operation of the database, do not look at the actual situation. Just learn an option.

Client login
bin / mysql -uroot -p
update mysql.user set authentication_string = password (‘root’), password_expired = ‘N’ where user = ‘root’;
flush privileges;

Change the password if you still remember ALTER USER ‘root’ @ ‘localhost’ IDENTIFIED BY ‘root’;
it is best not to use, it may prompt anonymous users do not allow to change the password and the like.

Description

All relevant directories, links, parameters, etc., please adjust according to the actual situation.

MySQL 5.7 multi-instance installation deployment instance

1. Background
MySQL database centralized operation and maintenance, through a server, the deployment of running multiple MySQL service process, through a different socket to monitor different service ports to provide their services. Each instance is independent of each other, each instance of the datadir, port, socket, pid are different.

2. Multi-instance features
* Effective use of server resources, when a single server resources are left, you can make full use of the remaining resources to provide more services.
* Resources to each other to seize the problem, when a service instance service is high or open slow query, it will consume more memory, CPU, disk IO resources, resulting in other instances of the server to provide services to reduce the quality.

 

[root@MySQL ~]# cat /etc/RedHat-release
CentOS release 6.9 (Final)

[root@MySQL ~]# uname -r
2.6.32-696.3.2.el6.x86_64

[root@MySQL ~]# getenforce
Disabled

[root@MySQL ~]# tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

[root@MySQL ~]# ln -s /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql

[root@MySQL ~]# useradd -r -s /sbin/nologin mysql

[root@MySQL ~]# mkdir -v /usr/local/mysql/mysql-files
mkdir: created directory `/usr/local/mysql/mysql-files’

[root@MySQL ~]# mkdir -vp /data/mysql_data{1..4}
mkdir: created directory `/data’
mkdir: created directory `/data/mysql_data1′
mkdir: created directory `/data/mysql_data2′
mkdir: created directory `/data/mysql_data3′
mkdir: created directory `/data/mysql_data4′

1 [root@MySQL ~]# chown root.mysql -R /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64

[root@MySQL ~]# chown mysql.mysql -R /usr/local/mysql/mysql-files /data/mysql_data{1..4}

/etc/my.cnf
[mysqld_multi]
mysqld    = /usr/local/mysql/bin/mysqld
mysqladmin = /usr/local/mysql/bin/mysqladmin
log        = /tmp/mysql_multi.log

 

[mysqld1]

datadir = /data/mysql_data1

socket = /tmp/mysql.sock1

port = 3306

user = mysql

performance_schema = off

innodb_buffer_pool_size = 32M

bind_address = 0.0.0.0

skip-name-resolve = 0

[mysqld2]
datadir = /data/mysql_data2
socket = /tmp/mysql.sock2
port = 3307
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0

[mysqld3]
datadir = /data/mysql_data3
socket = /tmp/mysql.sock3
port = 3308
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0

[mysqld4]
datadir = /data/mysql_data4
socket = /tmp/mysql.sock4
port = 3309
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0

 

 

[root@MySQL ~]# /usr/local/mysql/bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql_data1
[root@MySQL ~]# /usr/local/mysql/bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql_data2
[root@MySQL ~]# /usr/local/mysql/bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql_data3
[root@MySQL ~]# /usr/local/mysql/bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql_data4

 

[root@MySQL ~]# cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi

 

[root@MySQL ~]# chmod +x /etc/init.d/mysqld_multi

 

[root@MySQL ~]# chkconfig –add mysqld_multi

 

[root@MySQL ~]# /etc/init.d/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
MySQL server from group: mysqld3 is not running
MySQL server from group: mysqld4 is not running

 

[root@MySQL ~]# /etc/init.d/mysqld_multi start

 

Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running

 

[root@MySQL ~]# netstat -lntp | grep mysqld
tcp        0      0 0.0.0.0:3306        0.0.0.0:*                LISTEN      2673/mysqld
tcp        0      0 0.0.0.0:3307        0.0.0.0:*                LISTEN      2676/mysqld
tcp        0      0 0.0.0.0:3308        0.0.0.0:*                LISTEN      2679/mysqld
tcp        0      0 0.0.0.0:3309        0.0.0.0:*                LISTEN      2682/mysqld

 

[root@MySQL ~]# /usr/local/mysql/bin/mysql -S /tmp/mysql.sock1  -p’z+Ilo*>s:3kw’
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> set password = ‘123456’;
Query OK, 0 rows affected (0.00 sec)

[root@MySQL ~]# /usr/local/mysql/bin/mysql -S /tmp/mysql.sock2  -p’b*AHUrTgu1rl’
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> set password = ‘123456’;
Query OK, 0 rows affected (0.00 sec)

CentOS 7 rpm installed under the MySQL 5.6.36

CentOS 7 under the local installation of MySQL 5.7, but the springboot integration jpa will appear hibernateException, do not know why, for a MySQL5.6 version of MySQL, source installation, cmake has been through, and later into rpm installation.

Local installation of mysql5.7, but the integration of springboot jpa will appear hibernateException, do not know why, for a mysql5.6 version of the mysql, source installation, cmake has been through, and later changed to rpm installation

1, get mysql5.6

Ftp://ftp.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.6/

download: 

Where el6 identifies centos 6, el7 identifies centos 7

2, installation

Rpm -ivh MySQL- *

3, start

Systemctl start mysql

4, view the initial password

Cat /root/.mysql_secret

5, change the password

Mysql -uroot -pKAKt5JmEjm6B8omV
SET PASSWORD = PASSWORD('root');

6, remote login settings

Mysql> user mysql;
Mysql > select host, user, password from user;
Mysql > update user set password = password ( ' root ' ) where user = ' root ' ;
MySQL > Update the User the SET Host = ' % '  the WHERE the User = ' root ' and Host = ' localhost ' ; 

authorized 
GRANT  ALL  PRIVILEGES  . ON * *  the TO  'root' @ '%' IDENTIFIED  BY  'Here is your password'  the WITH  GRANT

7, set the boot start

[Root @ localhost ~ ] # chkconfig mysql on
[Root @ localhost ~] # chkconfig --list | grep mysql

8, MySQL default installation location

/ Var / lib / mysql /                # database directory
 / usr / share / mysql # configuration file directory
 / usr / bin # related command directory
 /etc/init.d/mysql # start script

9, modify the default character set and so on

Vim /etc/my.cnf

[client] 
password        = root
port            = 3306 
default-character-set=utf8 
[mysqld] 
port            = 3306 
character_set_server=utf8 
character_set_client=utf8 
collation-server=utf8_general_ci 
lower_case_table_names=1 
max_connections=1000 
[mysql] 
default-character-set = utf8 

10, view the character set

Show variables like ' % collation% ' ;  
Show variables like ' % char% ' ;

MySQL index conditions push a simple test

Since MySQL 5.6, there have been some improvements in the index, such as the index condition pushdown (ICP), strictly speaking, the optimizer level improvement.

If it is simple to understand, that is, the optimizer will try to index the treatment from the Server layer to the storage engine layer. As an example, there is a table containing the combined index idx_cols containing (c1, c2, …, cn) n columns, if there is a range scan on the where1 condition, then the remaining c2, …, cn this n-1 On the index can not be used to extract and filter data, and ICP is to optimize this thing.

We are in the MySQL 5.6 environment to a simple test.

We create the table emp, which contains a primary key, a combined index to illustrate.

Create Table EMP (
EMPNO smallint The (. 5) unsigned Not null AUTO_INCREMENT,
ename VARCHAR (30) Not null,
DEPTNO smallint The (. 5) unsigned Not null,
Job VARCHAR (30) Not null,
Primary Key (EMPNO),
Key idx_emp_info (DEPTNO, Ename)
) engine = InnoDB charset = utf8;

Of course, I also randomly inserted a few data, meaning that

Insert the emp values ??(1, ‘zhangsan’, 1, ‘CEO’), (2, ‘lisi’, 2, ‘CFO’), (3, ‘wangwu’, 3, ‘CTO’), (4, Jeanron100 ‘, 3,’ Enginer ‘);

ICP control in the database parameters have an optimizer parameter optimizer_switch to unified management, I think this is the MySQL optimizer from our closest time. You can use the following way to view.

Show variables like ‘optimizer_switch’;

Of course, in the previous version of 5.6, you can not see the index condition pushdown this kind of words. The results in the 5.6 version are as follows:

In the same way as in the case of the following event: index_merge_switch = on, mrr = on, mrr_cost_based = on, block_nested_loop = on, batched_key_access = off, materialization = On, semijoin = on, loosescan = on, firstmatch = on, subquery_materialization_cost_based_ed, use_index_extensions = on Here we use two statements to compare the description, through the implementation of the plan to contrast.

Set optimizer_switch = “index_condition_pushdown = off”

> Explain select * from emp where deptno between 1 and 100 and ename = ‘jeanron100’;
+ —- + ————- + ——- + — — + ————— + —— + ——— + —— + —— +
| __- + | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+ —- + ——– —– + ——- + —— + ————— + —— + —— —
| + + + + + _— + | 1 | SIMPLE | emp | ALL | idx_emp_info | NULL | NULL | NULL | 4 | Using where |
+ —- + ————- + ——- + —— + ———– —- + —— + ——— + —— + —— + ————- +

And if it is turned on, see if ICP is enabled.
Set optimizer_switch = “index_condition_pushdown = on”;> explain select * from emp where deptno between 10 and 3000 and ename = ‘jeanron100’;

> Explain select * from emp where deptno between 1 and 300 and ename = ‘jeanron100’;
+ —- + ————- + ——- + — — + ————— + —— + ——— + —— + —— +
| __- + | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+ —- + ——– —– + ——- + —— + ————— + —— + —— —
| + + + + + _— + | 1 | SIMPLE | emp | ALL | idx_emp_info | NULL | NULL | NULL | 4 | Using where |
+ —- + ————- + ——- + —— + ———– —- + —— + ——— + —— + —— + ————- +
1 row in set (0.00 sec) This place is worth considering.