MySQL 5.7 Make RPM installation package
%define mysql_user mysql%define Mysql_group mysqlname:mysqlversion:5.7.18release:msxf_v2summary:mysql-5 .7.18 RPMGROUP:APPLICATIONS/DATABASELICENSE:GPL Url:http://www.mysql.comsource0:mysql-5.7.18.tar. Gzpackager: [Email protected]buildroot:%{_topdir}/%{name}-%{version}-msxfbuildrequires:cmakeautoreqprov:no %descriptionmysql 5.7.18%prep%setup-n Mysql-%{version}%buildcmake. -dcmake_install_prefix=/usr/local/mysql57-dmysql_datadir=/home/mysql/mysql3306/data-dsysconf Dir=/home/mysql/mysql3306-dwith_innobase_storage_engine=1-dwith_federated_storage_engine=1 -dwith_blackhole_storage_engine=1-dwith_example_storage_engine=1-dwith_partitio n_storage_engine=1-dwith_perfschema_storage_engine=1-dmysql_unix_addr=/home/mysql/mysql3306/ Mysql3306.sock-ddefault_charset=utf8-ddefault_collatiOn=utf8_general_ci-denabled_local_infile=on-ddownload_boost=1-dwith_boost=. /boost_1_59_0/make%{?_smp_mflags}%installrm-rf%{buildroot}make Install destdir= $RPM _build_root%preis_config=$ ( cat/etc/security/limits.conf | grep MySQL | WC-L) If [$IS _config-lt 1];then cat >>/etc/security/limits.conf << eofmysql soft Nproc 2047my SQL hard Nproc 16384mysql soft nofile 1024mysql hard nofile 65536EOFfiecho 0 >/proc/sys/vm/ Swappinessmkdir-p/home/mysql/mysql3306/{data,log,binlog}total_size=$ (free-g | grep Mem | awk ' {print $} ') alloc_size= $ (($TOTAL _size * 64/100)) buffer_size=$ (echo $ALLOC _size | awk-f. ' {print $} ') ' G ' server_id=$ (IP addr | grep inet | grep "255 Scope global" |head-1|awk ' {print $} ' |cut-d '. "-F 4|cut-d"/"-F 1)" 3306 "Cat >/home/mysql/mysql3306/my . CNF <<eof[mysql]default-character-set=utf8mb4[mysqld]socket=/home/mysql/mysql3306/mysql3306.sock# DisabLing Symbolic-links is recommended to prevent assorted security Riskssymbolic-links=0port = 3306#extra_port=13306basedir =/usr/local/mysql57datadir =/home/mysql/mysql3306/datapid-file =/home/mysql/mysql3306/mysql.piduser = Mysqlserver-id = $SERVER _id#rpl_semi_sync_master_enabled=1#rpl_semi_sync_master_timeout=1000#rpl_semi_sync_slave _enabled=1relay_log_purge=0read_only=0super_read_only=0slave-skip-errors=1396binlog_row_image=full# Parallel Replicationbinlog_group_commit_sync_delay=10binlog_group_commit_sync_no_delay_count=1000master_info_repository = ' table ' #slave_parallel_type = logical_clock slave_parallel_workers = 10relay_log_info_repository= ' table ' #log_slave _updates=1lower_case_table_names = 1character-set-server=utf8mb4skip-name-resolveskip-external-lockingback_log = 500max_connections = 2000max_connect_errors = 2000open_files_limit = 65535table_open_cache = Max_allowed_packet = 64M Key_buffer_size = 128mread_buffer_size = 64mread_rnd_buffer_size = 16msort_buffer_size = 32MjoiN_buffer_size = 32mtmp_table_size = 96mmax_heap_table_size = 96mquery_cache_size = 16mquery_cache_limit = 16Mthread_ Cache_size = 64log_bin =/home/mysql/mysql3306/binlog/mysql-binbinlog_format = Rowbinlog_cache_size = 16Msync_binlog = 1max_binlog_cache_size = 1000mmax_binlog_size = 1gexpire_logs_days = 10log_error =/home/mysql/mysql3306/log/ Mysql-error.logslow_query_log = 1long_query_time = 0.1slow_query_log_file =/home/mysql/mysql3306/log/ mysql-slow.logrelay_log=/home/mysql/mysql3306/binlog/slave-relay-binrelay_log_index= Slave-relay-bin.indexdefault_storage_engine = Innodbinnodb_buffer_pool_size = $BUFFER _sizeinnodb_file_per_table = 1innodb_data_home_dir =/home/mysql/mysql3306/datainnodb_data_file_path = Ibdata1:500m;ibdata2:1g:autoextendinnodb _log_group_home_dir =/home/mysql/mysql3306innodb_log_file_size = 500minnodb_log_buffer_size = 96Minnodb_flush_log_ At_trx_commit = 1innodb_print_all_deadlocks = 1skip-slave-start=1gtid-mode=onenforce-gtid-consistency= Trueslave-parallel-workerS=8sql_mode= ' no_engine_substitution ' Log_timestamps=systemeofuseradd mysqlchown-r mysql:mysql/home/mysql/ Mysql3306%post/usr/local/mysql57/bin/mysqld--defaults-file=/home/mysql/mysql3306/my.cnf--initialize-insecure-- user=mysqlhave_profile_path=$ (cat/etc/profile | grep/usr/local/mysql57 | wc-l) If [$HAVE _profile_path-lt 1];then echo "Export path=/usr/local/mysql57/bin:\ $PATH" >>/etc/profilefihave_self_path=$ (cat ~/.bash_profile | grep/ usr/local/mysql57 | WC-L) If [$HAVE _self_path-lt 1];then echo "Export path=/usr/local/mysql57/bin:\ $PATH" >> ~/.bash_profilefi/us R/local/mysql57/bin/mysqld_safe--defaults-file=/home/mysql/mysql3306/my.cnf &IP_ADDR=$ (IP ADDR | grep inet | grep "255 Scope Global" |head-1|awk ' {print $} ' | Cut-d "/"-F 1) sleep 10/usr/local/mysql57/bin/mysql-uroot-s/home/mysql/mysql3306/mysql3306.sock <<EOFcreate da Tabase if not exists temp_dba_db;alter user ' root ' @ ' localhost ' identified by ' [email protected] '; Flush PRIvileges;reset master; Eofsource ~/.bash_profile%preun%postunrm-rf/usr/local/mysql57%cleanrm-rf%{buildroot}%files%defattr (-,%{MYSQL_ USER},%{mysql_group})%attr (755,%{mysql_user},%{mysql_group})/usr/local/mysql57/*%changelog
mysql5.7 making rpm package spec file