[root@wallet01 ~]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
[root@wallet01 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.201 wallet01
[root@wallet01 ~]# useradd mysql
[root@wallet01 ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
[root@wallet01 ~]# cat >> /etc/security/limits.conf <<EOF
mysql soft nproc 2048
mysql hard nproc 65535
mysql soft nofile 2048
mysql hard nofile 65535
EOF
[root@wallet01 ~]# yum install -y libaio
[root@wallet01 ~]# rpm -qa | grep libaio
libaio-0.3.107-10.el6.x86_64
[root@wallet01 ~]# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
[root@wallet01 ~]# rpm -ivh mysql-community-release-el6-5.noarch.rpm
[root@wallet01 ~]# yum install -y mysql-community-server
[root@wallet01 ~]# rpm -qa | grep mysql-community
mysql-community-common-5.6.43-2.el6.x86_64
mysql-community-libs-5.6.43-2.el6.x86_64
mysql-community-libs-compat-5.6.43-2.el6.x86_64
mysql-community-server-5.6.43-2.el6.x86_64
mysql-community-devel-5.6.43-2.el6.x86_64
mysql-community-client-5.6.43-2.el6.x86_64
[root@wallet01 ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server = utf8
open-files-limit = 65535
explicit_defaults_for_timestamp
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 2
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_log_buffer_size = 16M
innodb_undo_logs= 128
innodb_undo_tablespaces = 3
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_data_file_path = ibdata1:1024M:autoextend
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
no-auto-rehash
default-character-set=utf8
socket = /var/lib/mysql/mysql.sock
[root@wallet01 ~]# service mysqld start
Initializing MySQL database: 2019-02-13 09:44:49 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-02-13 09:44:49 0 [Note] /usr/sbin/mysqld (mysqld 5.6.43) starting as process 2217 ...
2019-02-13 09:44:49 2217 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-02-13 09:44:49 2217 [Note] InnoDB: The InnoDB memory heap is disabled
2019-02-13 09:44:49 2217 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-13 09:44:49 2217 [Note] InnoDB: Memory barrier is not used
2019-02-13 09:44:49 2217 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-02-13 09:44:49 2217 [Note] InnoDB: Using Linux native AIO
2019-02-13 09:44:49 2217 [Note] InnoDB: Using CPU crc32 instructions
2019-02-13 09:44:49 2217 [Note] InnoDB: Initializing buffer pool, size = 2.0G
2019-02-13 09:44:49 2217 [Note] InnoDB: Completed initialization of buffer pool
2019-02-13 09:44:49 2217 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2019-02-13 09:44:49 2217 [Note] InnoDB: Setting file ./ibdata1 size to 1024 MB
2019-02-13 09:44:49 2217 [Note] InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000
2019-02-13 09:45:15 2217 [Note] InnoDB: Setting log file ./ib_logfile101 size to 256 MB
InnoDB: Progress in MB: 100 200
2019-02-13 09:45:21 2217 [Note] InnoDB: Setting log file ./ib_logfile1 size to 256 MB
InnoDB: Progress in MB: 100 200
2019-02-13 09:45:28 2217 [Note] InnoDB: Setting log file ./ib_logfile2 size to 256 MB
InnoDB: Progress in MB: 100 200
2019-02-13 09:45:34 2217 [Note] InnoDB: Data file ./undo001 did not exist: new to be created
2019-02-13 09:45:34 2217 [Note] InnoDB: Setting file ./undo001 size to 10 MB
2019-02-13 09:45:34 2217 [Note] InnoDB: Database physically writes the file full: wait...
2019-02-13 09:45:34 2217 [Note] InnoDB: Data file ./undo002 did not exist: new to be created
2019-02-13 09:45:34 2217 [Note] InnoDB: Setting file ./undo002 size to 10 MB
2019-02-13 09:45:34 2217 [Note] InnoDB: Database physically writes the file full: wait...
2019-02-13 09:45:35 2217 [Note] InnoDB: Data file ./undo003 did not exist: new to be created
2019-02-13 09:45:35 2217 [Note] InnoDB: Setting file ./undo003 size to 10 MB
2019-02-13 09:45:35 2217 [Note] InnoDB: Database physically writes the file full: wait...
2019-02-13 09:45:35 2217 [Note] InnoDB: Opened 3 undo tablespaces
2019-02-13 09:45:35 2217 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-02-13 09:45:35 2217 [Warning] InnoDB: New log files created, LSN=48425
2019-02-13 09:45:35 2217 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-02-13 09:45:35 2217 [Note] InnoDB: Doublewrite buffer created
2019-02-13 09:45:35 2217 [Note] InnoDB: 128 rollback segment(s) are active.
2019-02-13 09:45:35 2217 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-02-13 09:45:35 2217 [Note] InnoDB: Foreign key constraint system tables created
2019-02-13 09:45:35 2217 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-02-13 09:45:35 2217 [Note] InnoDB: Tablespace and datafile system tables created.
2019-02-13 09:45:35 2217 [Note] InnoDB: Waiting for purge to start
2019-02-13 09:45:35 2217 [Note] InnoDB: 5.6.43 started; log sequence number 0
2019-02-13 09:45:41 2217 [Note] Binlog end
2019-02-13 09:45:41 2217 [Note] InnoDB: FTS optimize thread exiting.
2019-02-13 09:45:41 2217 [Note] InnoDB: Starting shutdown...
2019-02-13 09:45:43 2217 [Note] InnoDB: Shutdown completed; log sequence number 1508992
2019-02-13 09:45:43 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-02-13 09:45:43 0 [Note] /usr/sbin/mysqld (mysqld 5.6.43) starting as process 2239 ...
2019-02-13 09:45:43 2239 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-02-13 09:45:43 2239 [Note] InnoDB: The InnoDB memory heap is disabled
2019-02-13 09:45:43 2239 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-13 09:45:43 2239 [Note] InnoDB: Memory barrier is not used
2019-02-13 09:45:43 2239 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-02-13 09:45:43 2239 [Note] InnoDB: Using Linux native AIO
2019-02-13 09:45:43 2239 [Note] InnoDB: Using CPU crc32 instructions
2019-02-13 09:45:43 2239 [Note] InnoDB: Initializing buffer pool, size = 2.0G
2019-02-13 09:45:43 2239 [Note] InnoDB: Completed initialization of buffer pool
2019-02-13 09:45:43 2239 [Note] InnoDB: Opened 3 undo tablespaces
2019-02-13 09:45:43 2239 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-13 09:45:43 2239 [Note] InnoDB: 128 rollback segment(s) are active.
2019-02-13 09:45:43 2239 [Note] InnoDB: Waiting for purge to start
2019-02-13 09:45:43 2239 [Note] InnoDB: 5.6.43 started; log sequence number 1508992
2019-02-13 09:45:43 2239 [Note] Binlog end
2019-02-13 09:45:43 2239 [Note] InnoDB: FTS optimize thread exiting.
2019-02-13 09:45:43 2239 [Note] InnoDB: Starting shutdown...
2019-02-13 09:45:45 2239 [Note] InnoDB: Shutdown completed; log sequence number 1509009
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h wallet01 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Note: new default config file not created.
Please make sure your config file is current
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[ OK ]
Starting mysqld: [ OK ]
[root@wallet01 ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@wallet01 ~]# service mysqld status
mysqld (pid 29008) is running...
[root@wallet01 ~]# netstat -tunlp | grep mysqld
tcp 0 0 :::3306 :::* LISTEN 29008/mysqld
[root@wallet01 ~]# mysql -uroot -pabcd.1234
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 1140
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> select version();
+-----------+
| version() |
+-----------+
| 5.6.43 |
+-----------+
1 row in set (0.00 sec)
创建测试数据库
[root@wallet01 ~]# yum update -y nss curl libcurl
[root@wallet01 ~]# git clone https://github.com/Percona-Lab/tpcc-mysql.git
Initialized empty Git repository in /root/tpcc-mysql/.git/
remote: Enumerating objects: 392, done.
remote: Total 392 (delta 0), reused 0 (delta 0), pack-reused 392
Receiving objects: 100% (392/392), 202.81 KiB | 179 KiB/s, done.
Resolving deltas: 100% (216/216), done.
[root@wallet01 ~]# cd tpcc-mysql/src
[root@wallet01 src]# make
cc -w -O3 -g -I. `mysql_config --include` -c load.c
cc -w -O3 -g -I. `mysql_config --include` -c support.c
cc load.o support.o `mysql_config --libs_r` -lrt -o ../tpcc_load
cc -w -O3 -g -I. `mysql_config --include` -c main.c
cc -w -O3 -g -I. `mysql_config --include` -c spt_proc.c
cc -w -O3 -g -I. `mysql_config --include` -c driver.c
cc -w -O3 -g -I. `mysql_config --include` -c sequence.c
cc -w -O3 -g -I. `mysql_config --include` -c rthist.c
cc -w -O3 -g -I. `mysql_config --include` -c sb_percentile.c
cc -w -O3 -g -I. `mysql_config --include` -c neword.c
cc -w -O3 -g -I. `mysql_config --include` -c payment.c
cc -w -O3 -g -I. `mysql_config --include` -c ordstat.c
cc -w -O3 -g -I. `mysql_config --include` -c delivery.c
cc -w -O3 -g -I. `mysql_config --include` -c slev.c
cc main.o spt_proc.o driver.o support.o sequence.o rthist.o sb_percentile.o neword.o payment.o ordstat.o delivery.o
slev.o `mysql_config --libs_r` -lrt -o ../tpcc_start
[root@wallet01 src]# cd ..
[root@wallet01 tpcc-mysql]# ls -l
total 280
-rw-r--r-- 1 root root 1621 Feb 13 10:17 add_fkey_idx.sql
-rw-r--r-- 1 root root 317 Feb 13 10:17 count.sql
-rw-r--r-- 1 root root 3105 Feb 13 10:17 create_table.sql
-rw-r--r-- 1 root root 194 Feb 13 10:17 Dockerfile
-rw-r--r-- 1 root root 763 Feb 13 10:17 drop_cons.sql
-rw-r--r-- 1 root root 1079 Feb 13 10:17 load_multi_schema.sh
-rw-r--r-- 1 root root 573 Feb 13 10:17 load.sh
-rw-r--r-- 1 root root 2302 Feb 13 10:17 README.md
drwxr-xr-x 2 root root 4096 Feb 13 10:17 schema2
drwxr-xr-x 5 root root 4096 Feb 13 10:17 scripts
drwxr-xr-x 2 root root 4096 Feb 13 10:18 src
-rwxr-xr-x 1 root root 68248 Feb 13 10:18 tpcc_load
-rwxr-xr-x 1 root root 171254 Feb 13 10:18 tpcc_start
[root@wallet01 tpcc-mysql]# mysql -uroot -pabcd.1234
mysql> create database tpcc100;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on tpcc100.* to 'tpcc'@'%' identified by 'tpcc';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@wallet01 tpcc-mysql]# mysql -uroot -p tpcc100 < create_table.sql
[root@wallet01 tpcc-mysql]#./tpcc_load -h 192.168.1.201 -d tpcc100 -u tpcc -p "tpcc" -w 100
[root@wallet01 tpcc-mysql]# mysql -uroot -p tpcc100 < add_fkey_idx.sql
[root@wallet01 tpcc-mysql]# mysql -uroot -pabcd.1234
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| tpcc100 |
+--------------------+
4 rows in set (0.32 sec)
mysql> select count(*) from tpcc100.customer;
+----------+
| count(*) |
+----------+
| 1500000 |
+----------+
1 row in set (0.47 sec)
转载于:https://blog.51cto.com/13598811/2349351