November 2018
M T W T F S S
« Oct    
 1234
567891011
12131415161718
19202122232425
2627282930  

Categories

WordPress Quotes

A real decision is measured by the fact that you've taken a new action. If there's no action, you haven't truly decided.
Tony Robbins

Recent Comments

November 2018
M T W T F S S
« Oct    
 1234
567891011
12131415161718
19202122232425
2627282930  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (34)
Ansibile (18)
Apache (133)
Asterisk (2)
cassandra (2)
Centos (209)
Centos RHEL 7 (258)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (28)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (2)
Ldap (5)
Linux (189)
Linux Commands (167)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (22)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (30)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (34)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (60)
Uncategorized (29)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

19 visitors online now
4 guests, 15 bots, 0 members

Hit Counter provided by dental implants orange county

MySQL InnoDB engine B + tree index simple finishing instructions

There are several types of InnoDB engine tables in MySQL (the following index, no special instructions, refers to the InnoDB engine table index.)
0 = Secondary Index, 2-level index,
1 = Clustered Index, clustered index
2 = Unique Index, Unique Index
3 = Primary Index, Primary Key Index
32 = Full-text Index, Full Index
64 = Spatial Index
128 = A secondary index that includes a virtual generated column.

The second-level index, the clustered index, the unique index, the primary key index, the second-level computed column index, and the logical storage structure, are all stored in the B + tree to store
this point with the B + tree index logical storage structure of the other database Not too different, the above several indexes are divided from the logical point of view.

If the physical storage from the point of view, MySQL in these types of index can be divided into clustered index and secondary index (or non-clustered index)
Among them, the primary key index and clustered index, can be classified as clustered index, Unique index, secondary computed column index data nonclustered index.

The clustered index in MySQL

MySQL clustered index is based on the primary key, the entire table of data, logically organized into a B + tree, so a table can only be a clustered index.
The non-leaf node stores the clustered index key value, and the leaf node stores the data itself in the table, and the leaf node and the leaf node are connected together by a two-way list.

Know the MySQL clustering index before the first look at the MySQL primary key generation mechanism.
MySQL InnoDB must have a primary key,
if the time specified in the construction of the primary key, then the primary key is the main key of the table (sounds so awkward, mainly with the primary key is not specified, the automatic generation of the main key for comparison)
If the primary key is not specified, the storage engine will automatically create a primary key column for the table.
1) For the table that specifies the primary key, the primary key is the primary key index.
2) For tables that do not specify a primary key, If there is a unique index (one or more) that is not empty, the (first) non-null unique constraint is the primary key.
3) For a table that does not specify a primary key and there is no unique constraint, a primary key is generated by default. The index is “clustered index”, in
fact, the former “primary key index” and the latter “clustered index”, the physical storage can be attributed to clustered index

1, explicit primary key index (clustered index)

In the following screenshot, the test_index_type_1 is created
when the primary key is specified in the table, the primary key defaults to the primary key index. The index type is 3 (from the physical storage point of view, the index is
created ) Level index, the index type is 0 (from the physical storage point of view, is non-clustered index)

 

 

2, non-empty unique constraints generated by the primary key index (clustered index)

The following screenshot, created test_index_type_2,
did not specify the primary key when the table was created , but specified a unique non-null constraint, then the field would be used as the primary key, and the resulting index type would be 3 (from the physical storage point of view index)

 

 

 

3, the system default primary key generated clustered index (clustered index)

In the following screenshot, the test_index_type_3 table was created,
the primary key was not specified at the time of the table, and the unique non-null constraint was specified. The InnoDB engine automatically generates a 6-byte pointer. The generated index type is a clustered index, (From the physical storage point of view, is the clustered index)

 

 

Nonclustered index

The non-clustered index, the nonclustered index is also the structure of the B + tree to store the data.
The difference from the clustered index is that the leaf node of the nonclustered cable stores only the key value of the index + the key value of the clustered index, but does not include All non-index key values.

1, unique index generated by the unique index (non-clustered index)

The following screenshot, created the test_index_type_4 table,
specify the id as unique, then the id will automatically create a unique index.

 

 

 

 

2, the manual creation of a unique index (non-clustered index) The
following screenshot, created test_index_type5 table,
manually create a unique index, then the index type is unique index

 

 

3, manually created secondary index (non-clustered index) The
following screenshot, created test_index_type6 table,
that manually create an index (not specified unique), then the index type for the secondary index

 

4, the calculation of the column index, in the calculation of the column manually create the index (non-clustered index) The
following screenshot, created test_index_type7 table,

test_index_type7 there is a calculation column, after the completion of the calculation column in the calculation of the index,

 

to sum up:

Overall, MySQL several types of B + tree index is still relatively easy to understand, with the SQL Server index is also similar.
MySQL’s InnoDB engine table, the primary key index, non-null unique constraint generated by the clustered index, clustered index, from the physical storage point of view are data clustered index.
Primary key index, non-empty unique constraint generated clustered index, clustered index, the three have a distinct feature, all require that the column is non-empty and unique.
The other is that MySQL can not explicitly create a clustered index, that is, create clustered index.

This is very different from SQL Server,
1, in SQL Server, if you do not specify the primary key, or specify the primary key is not specified but nonclustered, then the table is for the heap table, the system will not add the default field as a clustered index
2 , SQL Server primary key can only be the primary key, you can not clustered index (by default the primary key is clustered index).

The clustered index can be specified on any column, either a non-primary key column, a non-unique, nullable, repeatable column, such as

 

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% ' ;