Linux production environment configured MySQL binary installation

Linux production environment configured MySQL binary installation


First, the environmental inspection
rpm -qa | grep libaio # libaio if not installed you need to install.
-H DF
Mount / dev / SR0 / mnt
Second, the installation procedure
1) Upload Setup
via FTP / SFTP upload the installation package
2) creators to create users, groups, create directory
the groupadd MySQL
the useradd -g -R & lt MySQL -s / bin / to false mysql
mkdir -p / mysql / data / 3306 / data
where 3306 is the default port number MySQL, / mysql / data directory mysql installation directory,
/ mysql / data / 3306 / data is mysql data directory.
mkdir -p / mysql / log / 3306

3) extracting installer package
CD / MySQL / App
the tar-zxvf MySQL 5.7.20-Linux-glibc2.12-x86_64.tar.gz
LN -s /mysql/app/mysql-5.7.20-linux-glibc2.12- x86_64.tar.gz / MySQL / App / MySQL
. 4) to modify permissions
chown -R mysql: mysql / mysql

5) configuration environment variable
VI ~ / .bash_profile
the PATH = $ the PATH: / MySQL / App / MySQL / bin: $ the HOME / bin

Testing
[root @ db1 ~] # mysql --version
unloading system comes with mysql
yum the Remove mysql
[root @ db1 ~] # Which mysql
/ mysql / App / mysql / bin / mysql
6) prepare parameter file
mysql default read this . /etc/my.cnf path profile
CD / MySQL / Data / 3306 /
Touch /mysql/log/3306/itpuxdb-error.err
chown -R & lt MySQL: MySQL /mysql/log/3306/itpuxdb-error.err

we /mysql/data/3306//my.cnf

[client]
port = 3306
socket = /mysql/data/3306/mysql.sock

[mysql]
no-beep
prompt="\u@db1 \R:\m:\s [\d]> "
#no-auto-rehash
auto-rehash
default-character-set=utf8

[mysqld]
########basic settings########
server-id=3306
port=3306
user = mysql
bind_address= 192.168.1.51
basedir=/mysql/app/mysql
datadir=/mysql/data/3306/data
socket= /mysql/data/3306/mysql.sock
pid-file=/mysql/data/3306/mysql.pid
character-set-server=utf8
skip-character-set-client-handshake=1
autocommit = 0
#skip_name_resolve = 1
max_connections = 800
max_connect_errors = 1000
default-storage-engine=INNODB
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
sort_buffer_size = 32M
join_buffer_size = 128M
tmp_table_size = 72M
max_allowed_packet = 16M
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
interactive_timeout = 1800
wait_timeout = 1800
read_buffer_size = 16M
read_rnd_buffer_size = 32M

query_cache_type = 1
query_cache_size=1M
table_open_cache=2000
thread_cache_size=768
myisam_max_sort_file_size=10G
myisam_sort_buffer_size=135M
key_buffer_size=32M
read_buffer_size=8M
read_rnd_buffer_size=4M

back_log=1024
#flush_time=0
open_files_limit=65536
table_definition_cache=1400
#binlog_row_event_max_size=8K
#sync_master_info=10000
#sync_relay_log=10000
#sync_relay_log_info=10000

########log settings########
log-output=FILE
general_log = 0
general_log_file=/mysql/log/3306/db1.err
slow_query_log = ON
slow_query_log_file=/mysql/log/3306/db1.err
long_query_time=10
log-error=/mysql/log/3306/db1-error.err

log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 90
min_examined_row_limit = 100
#log_bin = "/log/bin_log/binlog"

########replication settings########
#master_info_repository = TABLE
#relay_log_info_repository = TABLE
#log_bin = bin.log
#sync_binlog = 1
#gtid_mode = on
#enforce_gtid_consistency = 1
#log_slave_updates
#binlog_format = row
#relay_log = relay.log
#relay_log_recovery = 1
#binlog_gtid_simple_recovery = 1
#slave_skip_errors = ddl_exist_errors

########innodb settings########

innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_buffer_pool_size = 500M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
#innodb_flush_method = O_DIRECT

innodb_log_file_size = 200M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M

innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G

innodb_flush_neighbors = 1
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 64M
innodb_flush_log_at_trx_commit=1
innodb_autoextend_increment=64
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=65536
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
innodb_data_file_path=ibdata1:200M;ibdata2:200M;ibdata3:200M:autoextend:max:5G
innodb_temp_data_file_path = ibtmp1:200M:autoextend:max:20G

innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
#transaction_write_set_extraction=MURMUR32
show_compatibility_56=on

7)初始化MySQL
mysqld --defaults-file=/mysql/data/3306/my.cnf --initialize --datadir=/mysql/data/3306/data --basedir=/mysql/app/mysql --user=mysql

CD / MySQL / log / 3306
More DB1-error.err
initialization random password
ifyicOu0au + Y
. 8) arranged startup script
CD / MySQL / App / MySQL / Support Files-
CP MySQL the mysql.server

vi mysql
first to change at:
# basedir to appear in front of all, datadir, bindir, sbindir modify
basedir = / MySQL / App / MySQL
DATADIR = / MySQL / Data / 3306 / Data
BINDIR = / MySQL / App / MySQL / bin
= sbindir / MySQL / App / MySQL / bin
libexecdir The = / MySQL / App / MySQL / bin

To change the second:
mysqld_pid_file_path = / MySQL / Data / 3306 / mysql.pid

Third place to change:
# startup items start scripts, add-File = --defaults / MySQL / the Data / 3306 / my.cnf
$ bindir / mysqld_safe --defaults-File = / MySQL / the Data / 3306 / my.cnf --datadir = "$ datadir" --pid- file = "$ mysqld_pid_file_path" $ other_args> / dev / null &

my.cnf inspection sequence of
[@ itpux the root-Support Files] # MySQL --help | grep my.cnf
Order by the preference of, my.cnf, the MYSQL_TCP_PORT $,
/etc/my.cnf /etc/mysql/my.cnf / usr / local / mysql / etc / my.cnf ~ / .my.cnf

# Rename the /etc/my.cnf

Finally the edited script into mysql under /etc/init.d/ directory.

mv /mysql/app/mysql/support-files/mysql /etc/init.d/

9) start and stop verification, log viewer
start
/etc/init.d/mysql start or service mysql start
stop
/etc/init.d/mysql stop or service mysql stop

10) the latter configuration (change your password, start the Remote Access)
login
mysql -uroot -pxjl61l / J_tp9 -S /mysql/data/3306/mysql.sock
change the password
the SET password = password ( "rootroot");
11) remote connectivity test
root user remote login
Grant All privileges ON . to 'root' @ '%' IDENTIFIED by 'rootroot' with Grant the Option;
flush privileges;
create database
create database db1
create user
the create the user dbuser IDENTIFIED by "dbuser";
MySQL> Grant All privileges dbuser ON. to 'dbuser' @ 'localhost' IDENTIFIED by 'dbuser';
MySQL> Grant All privileges ON
. to 'dbuser' @ '%' IDENTIFIED by 'dbuser' with the Option Grant;
MySQL>
grant all privileges on dbuser. to 'dbuser'@'%' identified by 'dbuser';
mysql> flush privileges;

Create a table and add test data
use DB1
Create Table Dept (
DEPTNO AUTO_INCREMENT int Primary Key,
DNAME VARCHAR (15),
LOC VARCHAR (50)
) = InnoDB Engine;

insert into dept values(1,'it','gz');
insert into dept values(2,'cw','sh');
insert into dept values(3,'hr','sz');
commit;

select * from dept;
desc dept;

Question 1:
ERROR 2002 (HY000): of Can not Connect to local MySQL Server through socket '/var/lib/mysql/mysql.sock'(2)
to solve the problem:
the above error, indicating install MySQL, need to uninstall now some installation package
RPM -qa | grep MySQL
yum the Remove MySQL
simply delete mysql, mysql-devel package.

问题2:
mysqld: [ERROR] Could not open required defaults file: /mysql/data/3306/my.cnf
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

Solutions:
Tips not find my.cnf file, check whether the path initialization commands stored in the same path my.cnf.

问题3:[root@itpuxdb 3306]# /etc/init.d/mysql start
Starting MySQL..The server quit without updating PID file ([FAILED]ata/3306/mysql.pid).

Such problems can lead not generate pid, sock file.

Solution:
The /etc/my.cnf file, rename my.cnf.bak, so you can at / mysql / data / 3306 / directory can generate the corresponding files.

Guess you like

Origin blog.51cto.com/520527/2420986