“Mysqlrpm”的版本间的差异
跳到导航
跳到搜索
docker>Evan |
小 (导入1个版本) |
2019年10月14日 (一) 13:52的最新版本
mysql.spec
cat mysql.spec Name:ops_mysql #rpm的版本号,不允许出现连接符 - Version: 5.7.18 Release: 1.0 License: GPL # yum install ncurses-devel # cp -a boost_1_59_0/ rpmbuild/BUILD/ #需要在一个存在的组中,通过/usr/share/doc/rpm-*/GROUPS查看完整的组列表 Group: Applications/Databases URL: linuxchina.net BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: cmake Requires: coreutils,shadow-utils Packager: [email protected] Autoreq: no Source: mysql-5.7.18.tar.gz Source4: dbbackup.sh #Source5: mysqld.service prefix: /data/apps/mysql #prefix: /data/apps/%{name} Summary: mysql server 5.7.18 %description ops_mysql %define MYSQL_USER mysql %define MYSQL_GROUP mysql %define __os_install_post %{nil} %prep #20180807 #mkdir -p /data %setup -n mysql-%{version} #%setup -n %{name}-%{version} %build # by evan 20180824pm #CFLAGS="-O3 -g -fno-exceptions -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing" #CXX=g++ #CXXFLAGS="-O3 -g -fno-exceptions -fno-rtti -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing" #export CFLAGS CXX CXXFLAGS # ok cmake option 20160824pm #cmake . \ # -DSYSCONFDIR:PATH=%{prefix} \ # -DCMAKE_INSTALL_PREFIX:PATH=%{prefix} \ # -DCMAKE_BUILD_TYPE:STRING=Release \ # -DDEFAULT_CHARSET=utf8 \ # -DDEFAULT_COLLATION=utf8_general_ci \ # -DWITH_EXTRA_CHARSETS=complex \ # -DWITH_READLINE=1 \ # -DENABLED_LOCAL_INFILE=1 \ # -DWITH_SSL=system \ # -DWITH_ZLIB=system \ # -DWITH_EMBEDDED_SERVER=1; #201808 # 和别人 不一样的 # -DWITH_MYISAM_STORAGE_ENGINE=ON # -DENABLED_LOCAL_INFILE:BOOL=ON # -DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON # -DEXTRA_CHARSETS=all 我没有 # cmake . -LH # help #20180809 #cmake . \ # -DSYSCONFDIR:PATH=%{prefix} \ # -DCMAKE_INSTALL_PREFIX:PATH=%{prefix} \ # -DCMAKE_BUILD_TYPE:STRING=Release \ # -DENABLE_PROFILING:BOOL=ON \ # -DWITH_DEBUG:BOOL=OFF \ # -DWITH_VALGRIND:BOOL=OFF \ # -DENABLE_DEBUG_SYNC:BOOL=OFF \ # -DWITH_EXTRA_CHARSETS:STRING=all \ # -DWITH_SSL:STRING=bundled \ # -DWITH_UNIT_TESTS:BOOL=OFF \ # -DWITH_ZLIB:STRING=bundled \ # -DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \ # -DWITH_INNOBASE_STORAGE_ENGINE=1 \ # -DWITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON \ # -DWITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON \ # -DWITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON \ # -DDEFAULT_CHARSET=utf8 \ # -DDEFAULT_COLLATION=utf8_general_ci \ # -DENABLED_LOCAL_INFILE:BOOL=ON \ # -DINSTALL_LAYOUT:STRING=STANDALONE \ # -DCOMMUNITY_BUILD:BOOL=ON \ # -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ # -DWITHOUT_NDBCLUSTER_STORAGE_ENGINE=1 \ # -DENABLED_PROFILING=1 \ # -DINNODB_PAGE_ATOMIC_REF_COUNT=1 \ # -DMYSQL_DATADIR=/data/apps/mysql/data \ # -DWITH_BOOST=../boost_1_59_0 \ # -DSYSCONFDIR=/etc \ # -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ # -DWITH_MEMORY_STORAGE_ENGINE=1 \ # -DWITH_MYISAM_STORAGE_ENGINE=ON \ # -DWITH_READLINE=1 \ # -DMYSQL_TCP_PORT=3306; # cmake . \ -DSYSCONFDIR:PATH=/data/apps/mysql \ -DCMAKE_INSTALL_PREFIX:PATH=/data/apps/mysql \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DENABLE_PROFILING:BOOL=ON \ -DWITH_DEBUG:BOOL=OFF \ -DWITH_VALGRIND:BOOL=OFF \ -DENABLE_DEBUG_SYNC:BOOL=OFF \ -DWITH_EXTRA_CHARSETS:STRING=all \ -DWITH_SSL:STRING=bundled \ -DWITH_UNIT_TESTS:BOOL=OFF \ -DWITH_ZLIB:STRING=bundled \ -DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON \ -DWITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON \ -DWITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DENABLED_LOCAL_INFILE:BOOL=ON \ -DINSTALL_LAYOUT:STRING=STANDALONE \ -DCOMMUNITY_BUILD:BOOL=ON \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITHOUT_NDBCLUSTER_STORAGE_ENGINE=1 \ -DENABLED_PROFILING=1 \ -DINNODB_PAGE_ATOMIC_REF_COUNT=1 \ -DMYSQL_DATADIR=/data/apps/mysql/data \ -DWITH_BOOST=../boost_1_59_0 \ -DSYSCONFDIR=/etc \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=ON \ -DWITH_READLINE=1 \ -DWITH_SYSTEMD=1 \ -DMYSQL_TCP_PORT=3306; # boost_1_59_0 on BUILD dir make -j `cat /proc/cpuinfo | grep processor| wc -l` #make -j3 %install make DESTDIR=$RPM_BUILD_ROOT install %{__mkdir} -p $RPM_BUILD_ROOT/data/mon/ %{__mkdir} -p $RPM_BUILD_ROOT/data/logs/ %{__mkdir} -p $RPM_BUILD_ROOT/data/backup/ cp %{_sourcedir}/my.cnf $RPM_BUILD_ROOT%{prefix}/ %{__install} -m755 %{SOURCE4} $RPM_BUILD_ROOT/data/mon/dbbackup.sh #%{__install} -m622 %{SOURCE5} /usr/lib/systemd/system #evan 2019 #cp %{_sourcedir}/mysqld.service /usr/lib/systemd/system #cp %{_sourcedir}/dbbackup.sh $RPM_BUILD_ROOT/data/mon/dbbackup.sh %clean #rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_DIR/* %files %defattr(-, %{MYSQL_USER}, %{MYSQL_GROUP}) %attr(755, %{MYSQL_USER}, %{MYSQL_GROUP}) %{prefix}/* /data/mon/dbbackup.sh %pre #by evan 20160826 if [ -f %{_sysconfdir}/my.cnf ];then mv %{_sysconfdir}/my.cnf %{_sysconfdir}/my.cnf.sysold fi if ! id %{MYSQL_USER} > /dev/null 2>&1;then useradd -M -s /sbin/nologin %{MYSQL_USER} mkdir -p /data/apps/mysql/data/ mkdir -p /data/logs/mysql/binlog/ mkdir -p /data/logs/mysql/errlog/ mkdir -p /data/logs/mysql/slowlog/ #mkdir -p /data/apps/mysql/logs/ #mkdir -p /data/logs/mysql #touch /data/logs/mysql/mysqld-error.log chown -R mysql:mysql /data/logs/mysql chown -R mysql:mysql /data/apps/mysql fi ##这个post 的好像全部没有效果 %post if [[ ! -f %{_sysconfdir}/my.cnf ]];then yes|cp -f %{prefix}/my.cnf %{_sysconfdir}/my.cnf else yes|cp -f %{prefix}/my.cnf %{_sysconfdir}/my.cnf.rpmnew fi #/data/apps/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/apps/mysql/data/ cd /data/apps/mysql/ #here2016 #scripts/mysql_install_db --user=mysql --datadir=/data/apps/mysql/data/ > /dev/null 2>&1 #bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql --datadir=/data/apps/mysql/data/ > /dev/null 2>&1 /data/apps/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/apps/mysql/ --datadir=/data/apps/mysql/data/ #cp /data/apps/mysql/support-files/mysql.server /etc/init.d/mysqld #sysv cp /data/apps/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system #sysd centos7 /bin/sed -i 's!/var/run/mysqld/mysqld.pid!/data/apps/mysql/data/mysqld.pid!' /usr/lib/systemd/system/mysqld.service systemctl enable mysqld.service systemctl daemon-reload systemctl start mysqld.service #cp %{prefix}/support-files/mysql.server %{_initddir}/mysqld #chmod +x %{_initddir}/mysqld #chkconfig mysqld on #chkconfig --level 2345 %{_initddir}/mysqld on #/etc/init.d/mysqld start echo 'export PATH=/data/apps/mysql/bin/:$PATH' >> /etc/profile source /etc/profile systemctl start mysqld.service #/etc/init.d/mysqld start /data/apps/mysql/bin/mysqladmin password 'opsmysql!q$EWQ23FD23'; rm -rf /data/apps/mysql/data/test; #by evan 20160912 mv /data/apps/mysql/my.cnf /data/apps/mysql/my.cnfdkmbak ln -s /data/apps/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.16 #add mysqlback crontab /usr/bin/crontab -l > /tmp/crontab_list echo '0 4 * * * /data/mon/dbbackup.sh >/dev/null 2>&1 ' >> /tmp/crontab_list /usr/bin/crontab /tmp/crontab_list rm -f /tmp/crontab_list # grant by evan 20160826 /data/apps/mysql/bin/mysql -uroot -p'opsmysql!q$EWQ23FD23' -e 'grant select,insert,update,delete on *.* to [email protected] identified by "opsmysql!q$EWQ23FD23"'; /data/apps/mysql/bin/mysql -uroot -p'opsmysql!q$EWQ23FD23' -e 'grant select,insert,update,delete on *.* to xkmweb@localhost identified by "opsmysql!q$EWQ23FD23"'; #20170517 root on 127.0.0.1 /data/apps/mysql/bin/mysql -uroot -p'opsmysql!q$EWQ23FD23' -e 'grant all on *.* to [email protected] identified by "opsmysql!q$EWQ23FD23"'; #/data/apps/mysql/bin/mysql -uroot -p'dkmwebmysql!q$EWQ23FD23' -e 'grant select,insert,update,delete, create *.* to [email protected] identified by "dkmrw!q$EWQ23FD23"'; #/data/apps/mysql/bin/mysql -uroot -p'dkmwebmysql!q$EWQ23FD23' -e 'grant select,insert,update,delete, create *.* to dkmweb@localhost identified by "dkmrw!q$EWQ23FD23"'; #/data/apps/mysql/bin/mysql -uroot -p'dkmwebmysql!q$EWQ23FD23' -e 'grant all on *.* to [email protected] identified by "dkmrw!q$EWQ23FD23"'; #/data/apps/mysql/bin/mysql -uroot -p'dkmwebmysql!q$EWQ23FD23' -e 'grant all on *.* to dkmweb@localhost identified by "dkmrw!q$EWQ23FD23"'; /data/apps/mysql/bin/mysql -uroot -p'opsmysql!q$EWQ23FD23' -e 'flush privileges'; #%{_sysconfdir} /etc #%{_initddir} %{_sysconfdir}/rc.d/init.d #if [ ! -f %{_sysconfdir}/my.cnf ];then #cp %{prefix}/my.cnf %{_sysconfdir}/my.cnf #else #cp %{prefix}/my.cnf %{_sysconfdir}/my.cnf.rpmnew #fi %preun /etc/init.d/mysqld stop if [ -f %{_sysconfdir}/my.cnf ];then mv %{_sysconfdir}/my.cnf %{_sysconfdir}/my.cnf.rpmold fi if [ -f %{_initddir}/mysql ];then mv %{_initddir}/mysql %{_initddir}/mysql.rpmold fi %postun rm -rf %{prefix} rm -rf /etc/rc.d/init.d/mysqld userdel -r %{MYSQL_USER} >/dev/null 2>&1 #del mysqlback crontab /usr/bin/crontab -l > /tmp/crontab_list sed -i '/0 4 \* \* \* \/data\/mon\/dbbackup.sh >\/dev\/null 2>\&1/'d /tmp/crontab_list /usr/bin/crontab /tmp/crontab_list rm -f /tmp/crontab_list %changelog * Tue Aug 07 2018 evan * Tue May 07 2019 evan - mysql 5.7.18 evan@latop:~/rpm/rpmbuild2019/mysql20190506/SPECS$ evan@latop:~/rpm/rpmbuild2019/mysql20190506/SPECS$ ls 5.6spec '#mysql.spec#' mysql.spec evan@latop:~/rpm/rpmbuild2019/mysql20190506/SPECS$ cd .. evan@latop:~/rpm/rpmbuild2019/mysql20190506$ ls boost_1_59_0.tar.gz BUILD BUILDROOT note rm RPMS SOURCES SPECS SRPMS evan@latop:~/rpm/rpmbuild2019/mysql20190506$ ls SOURCES/ 20161111dbbackup.sh dbbackup.sh my.cnf~ my.cnf20180808 my.cnfbak mysql-5.6.32.tar.gz mysql-5.7.18.tar.gz mysqld.service '#dbbackup.sh#' my.cnf my.cnf2015 my.cnf33066 my-medium.c