MySQL编译安装(多实例)
来源:互联网 发布:淘宝信用支付什么意思 编辑:程序博客网 时间:2024/06/05 07:06
CentOS6.5编译安装Mysql5.5.32(多实例)
1. 网络配置
[root@mysql ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0HWADDR=08:00:27:b8:ed:81TYPE=EthernetUUID=e70002ef-8582-4e24-bf8a-76f34cf7ad3fONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=noneIPADDR=10.0.0.12NETMASK=255.255.255.0GATEWAY=10.0.0.1[root@mysql ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1DEVICE=eth1HWADDR=08:00:27:80:af:45TYPE=EthernetUUID=3f89d03c-fcf9-465c-806b-bc5d3dd33b58ONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=noneIPADDR=192.168.0.12NETMASK=255.255.255.0service network restartroute add default gw 10.0.0.1 ##重启网卡后失效 ##永久方式 网卡添加GATEWAY=10.0.0.1##DNS配置[root@mysql ~]# cat /etc/resolv.conf nameserver 10.0.0.1
2. 防火墙设置
[root@mysql ~]#chkconfig iptables off[root@mysql ~]#service iptables stop[root@mysql ~]#service iptables status[root@mysql ~]#sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config[root@mysql ~]#setenforce 0
3. 安装环境
[root@mysql ~]# cat /etc/redhat-release CentOS release 6.5 (Final)[root@mysql ~]# uname -r2.6.32-431.el6.x86_64 [root@mysql ~]# uname -m x86_64 [root@mysql ~]# uname -a Linux mysql 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
4.yum源配置
##网络yum源[root@mysql ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup[root@mysql ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo[root@mysql ~]# yum makecache##本地yum源[root@mysql repodata]# cd /etc/yum.repos.d/[root@mysql yum.repos.d]# vi CentOS-Base.repo[base]name=CentOS-$releasever - Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=file:///mnt/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6[root@mysql yum.repos.d]# yum clean all
http://mirrors.aliyun.com/help/centos
5.软件包安装
**选择最小化安装CentOS**http://blog.csdn.net/lt53130640688/article/details/49638381##上传下载软件包[root@mysql yum.repos.d]# yum install lrzsz -y##tree命令包[root@mysql yum.repos.d]# yum install tree -y##Mysql依赖包(重要)[root@mysql yum.repos.d]# yum install ncurses-devel -y
6.上传cmake-2.8.8.tar.gz 和mysql-5.5.32.tar.gz
[root@mysql tools]# rz -yrz waiting to receive.Starting zmodem transfer. Press Ctrl+C to cancel.Transferring cmake-2.8.8.tar.gz... 100% 5558 KB 5558 KB/sec 00:00:01 0 Errors Transferring mysql-5.5.32.tar.gz... 100% 24019 KB 12009 KB/sec 00:00:02 0 Errors
7.安装Cmake 编译工具
[root@mysql tools]# tar xf cmake-2.8.8.tar.gz [root@mysql tools]# cd cmake-2.8.8[root@mysql tools]# ./configure [root@mysql tools]# gmake[root@mysql tools]# gmake install
8.安装MySQL
[root@mysql tools]# groupadd mysql[root@mysql tools]# useradd mysql -s /sbin/nologin -M -g mysql[root@mysql tools]# tar zxf mysql-5.5.32.tar.gz[root@mysql tools]# cd mysql-5.5.32[root@mysql mysql-5.5.32]# cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \-DMYSQL_DATADIR=/application/mysql-5.5.32/data \-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0##-DDEFAULT_CHARSET=utf8 \##-DDEFAULT_COLLATION=utf8_general_ci \[root@mysql mysql-5.5.32]# make && make install
9.配置MySQL
[root@mysql tools]# ln -s /application/mysql-5.5.32 /application/mysql[root@mysql tools]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile[root@mysql tools]# tail -1 /etc/profile[root@mysql tools]# source /etc/profile[root@mysql tools]# echo $PATH
10.脚本参数文件
[root@mysql /]# cd /[root@mysql /]# rz -y[root@mysql /]# unzip -o data.zip Archive: data.zip creating: data/ creating: data/3306/ creating: data/3306/data/ inflating: data/3306/my.cnf inflating: data/3306/mysql creating: data/3307/ creating: data/3307/data/ inflating: data/3307/my.cnf inflating: data/3307/mysql [root@mysql /]# chmod -R 1777 /tmp[root@mysql /]# chown -R mysql.mysql /data[root@mysql67 /]# find /data/ -type f -name "mysql"|xargs ls -l-rw-r--r-- 1 mysql mysql 1140 Nov 3 18:19 /data/3306/mysql-rw-r--r-- 1 mysql mysql 1140 Nov 3 18:19 /data/3307/mysql[root@mysql /]# find /data/ -type f -name "mysql"|xargs chmod +x [root@mysql /]# find /data/ -type f -name "mysql"|xargs ls -l-rwxr-xr-x. 1 mysql mysql 1202 Nov 4 11:13 /data/3306/mysql-rwxr-xr-x. 1 mysql mysql 1202 Nov 4 11:12 /data/3307/mysql[root@mysql 3306]# find /data/ -type f -name "mysql"|xargs dos2unixdos2unix: converting file /data/3307/mysql to UNIX format ...dos2unix: converting file /data/3306/mysql to UNIX format ..
10.初始化MySQL
[root@mysql /]# cd /application/mysql/scripts/[root@mysql scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/ --user=mysqlWARNING: The host 'mysql' could not be looked up with resolveip.This probably means that your libc libraries are not 100 % compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/application/mysql/bin/mysqladmin -u root password 'new-password'/application/mysql/bin/mysqladmin -u root -h mysql password 'new-password'Alternatively you can run:/application/mysql/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /application/mysql ; /application/mysql/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /application/mysql/mysql-test ; perl mysql-test-run.plPlease report any problems with the /application/mysql/scripts/mysqlbug script![root@mysql scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data/ --user=mysqlWARNING: The host 'mysql' could not be looked up with resolveip.This probably means that your libc libraries are not 100 % compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/application/mysql/bin/mysqladmin -u root password 'new-password'/application/mysql/bin/mysqladmin -u root -h mysql password 'new-password'Alternatively you can run:/application/mysql/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /application/mysql ; /application/mysql/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /application/mysql/mysql-test ; perl mysql-test-run.plPlease report any problems with the /application/mysql/scripts/mysqlbug script!
11.启动MySQL
[root@mysql 3306]# cd /data/3306[root@mysql 3306]# ./mysql startStarting MySQL ...[root@mysql 3306]# netstat -lntupActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6363/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6459/master tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7502/mysqld tcp 0 0 :::22 :::* LISTEN 6363/sshd tcp 0 0 ::1:25 :::* LISTEN 6459/master [root@mysql 3307]# cd /data/3307/[root@mysql 3307]# ./mysql startStarting MySQL ...[root@mysql 3307]# netstat -lntnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 8373/mysqld tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6363/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6459/master tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7502/mysqld tcp 0 0 :::22 :::* LISTEN 6363/sshd tcp 0 0 ::1:25 :::* LISTEN 6459/master ##密码设置[root@mysql 3307]# /application/mysql/bin/mysqladmin -u root password '123456' -S /data/3306/mysql.sock [root@mysql 3307]# /application/mysql/bin/mysqladmin -u root password '123456' -S /data/3307/mysql.sock [root@mysql 3307]# ./mysql stopStoping MySQL...[root@mysql 3307]# netstat -lntupActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6363/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6459/master tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7502/mysqld tcp 0 0 :::22 :::* LISTEN 6363/sshd tcp 0 0 ::1:25 :::* LISTEN 6459/master [root@mysql data]# cd ../3306[root@mysql 3306]# ./mysql stopStoping MySQL...[root@mysql 3306]# netstat -lntupActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6363/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6459/master tcp 0 0 :::22 :::* LISTEN 6363/sshd tcp 0 0 ::1:25 :::* LISTEN 6459/master
my.cnf参数文件
[client]port = 3306socket = /data/3306/mysql.sock[mysqld]datadir=/data/3306/dataport = 3306socket = /data/3306/mysql.sockskip-name-resolvelower_case_table_names=1innodb_file_per_table=1back_log = 50max_connections = 300max_connect_errors = 1000table_open_cache = 2048max_allowed_packet = 16Mbinlog_cache_size = 2Mmax_heap_table_size = 64Msort_buffer_size = 2Mjoin_buffer_size = 2Mthread_cache_size = 64thread_concurrency = 8query_cache_size = 64Mquery_cache_limit = 2Mft_min_word_len = 4default-storage-engine = innodbthread_stack = 192Ktransaction_isolation = REPEATABLE-READfederatedtmp_table_size = 64Mlong_query_time = 1slow-query-log = 1 binlog_format=mixedlog-bin = /data/3306/mysql-binslow-query-log-file = /data/3306/slow.log log-error = /data/3306/error.logpid-file = /data/3306/mysql.pidrelay-log = /data/3306/relay-binrelay-log-info-file = /data/3306/relay-log.infobinlog_cache_size = 2Mmax_binlog_cache_size = 2Mmax_binlog_size = 3Mexpire_logs_days = 7server-id = 1key_buffer_size = 4Mread_buffer_size = 2Mread_rnd_buffer_size = 8Mbulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G myisam_repair_threads = 1myisam_recover innodb_additional_mem_pool_size = 4Minnodb_buffer_pool_size = 32Minnodb_data_file_path = ibdata1:10M:autoextendinnodb_read_io_threads = 8innodb_write_io_threads = 8innodb_thread_concurrency = 16innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16Minnodb_log_file_size = 8Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120[mysqldump]quickmax_allowed_packet = 256M[mysql]no-auto-rehash[myisamchk]key_buffer_size = 512Msort_buffer_size = 512Mread_buffer = 8Mwrite_buffer = 8M[mysqlhotcopy]interactive-timeout[mysqld_safe]open-files-limit = 8192log-error = /data/3306/mysql_3306.errpid-file = /data/3306/mysqld.pid##3307参数文件只需将3306替换成3307即可
mysql启停脚本
#!/bin/sh##############################################this scripts is created by LT#3307起停脚本只需将3306替换成3307即可#############################################port=3306mysql_user="root"mysql_pwd="123456"CmdPath="/application/mysql/bin"mysql_sock="/data/${port}/mysql.sock"#startup functionfunction_start_mysql(){ if [ ! -e "$mysql_sock" ]; then printf "Starting MySQL ...\n" /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 >/dev/null & else printf "MySQL is running ...\n" exit fi}#stop functionfunction_stop_mysql(){ if [ ! -e "$mysql_sock" ]; then printf "MySQL is stopped ...\n" exit else printf "Stoping MySQL...\n" ${CmdPath}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown fi}#restart functionfunction_restart_mysql(){ printf "Restarting MySQL...\n" function_stop_mysql sleep 2 function_start_mysql}case $1 instart) function_start_mysql;;stop) function_stop_mysql;;restart) function_restart_mysql;;*) printf"Usage: /data/${port}/mysql {start|stop|restart}\n"esac
因参数设置报错
--启动错误[root@mysql 3306]# cat mysql_3306.err 151105 10:49:10 mysqld_safe Starting mysqld daemon with databases from /data/3306/data151105 10:49:10 [Warning] The syntax '--log-slow-queries' is deprecated and will be removed in a future release. Please use '--slow-query-log'/'--slow-query-log-file' instead.151105 10:49:10 InnoDB: The InnoDB memory heap is disabled151105 10:49:10 InnoDB: Mutexes and rw_locks use GCC atomic builtins151105 10:49:10 InnoDB: Compressed tables use zlib 1.2.3151105 10:49:10 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead151105 10:49:10 InnoDB: Initializing buffer pool, size = 32.0M151105 10:49:10 InnoDB: Completed initialization of buffer poolInnoDB: The first specified data file ./ibdata1 did not exist:InnoDB: a new database to be created!151105 10:49:10 InnoDB: Setting file ./ibdata1 size to 10 MBInnoDB: Database physically writes the file full: wait...151105 10:49:10 InnoDB: Log file ./ib_logfile0 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile0 size to 8 MBInnoDB: Database physically writes the file full: wait...151105 10:49:10 InnoDB: Log file ./ib_logfile1 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile1 size to 8 MBInnoDB: Database physically writes the file full: wait...151105 10:49:10 InnoDB: Log file ./ib_logfile2 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile2 size to 8 MBInnoDB: Database physically writes the file full: wait...InnoDB: Doublewrite buffer not found: creating newInnoDB: Doublewrite buffer createdInnoDB: 127 rollback segment(s) active.InnoDB: Creating foreign key constraint system tablesInnoDB: Foreign key constraint system tables created151105 10:49:10 InnoDB: Waiting for the background threads to start151105 10:49:11 InnoDB: 5.5.32 started; log sequence number 0151105 10:49:11 [ERROR] /application/mysql-5.5.32/bin/mysqld: unknown variable 'myisam_max_extra_sort_file_size=10G'151105 10:49:11 [ERROR] Aborting151105 10:49:11 InnoDB: Starting shutdown...151105 10:49:12 InnoDB: Shutdown completed; log sequence number 1595675151105 10:49:12 [Note] /application/mysql-5.5.32/bin/mysqld: Shutdown complete151105 10:49:12 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended**可以看出当前版本参数log-slow-queries,innodb_file_io_threads已经无效**
登陆及优化mysql详看
http://blog.csdn.net/lt53130640688/article/details/49639363
快速安装命令整合:
cat /etc/redhat-release uname -avi /etc/sysconfig/network-scripts/ifcfg-eth0vi /etc/sysconfig/network-scripts/ifcfg-eth1service network restartecho 'nameserver 10.0.0.1'>> /etc/resolv.conf chkconfig iptables offservice iptables stopservice iptables statussetenforce 0sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/configmv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoyum makecacheyum install lrzsz -yyum install tree -yyum install ncurses-devel -ytar xf cmake-2.8.8.tar.gz cd cmake-2.8.8./configure gmakegmake installgroupadd mysqluseradd mysql -s /sbin/nologin -M -g mysqltar zxf mysql-5.5.32.tar.gzcd mysql-5.5.32cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \-DMYSQL_DATADIR=/application/mysql-5.5.32/data \-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0make && make installln -s /application/mysql-5.5.32 /application/mysqlecho 'export PATH=/application/mysql/bin:$PATH' >>/etc/profiletail -1 /etc/profilesource /etc/profilecd /rz -yunzip -o data.zip chmod -R 1777 /tmpchown -R mysql.mysql /datafind /data/ -type f -name "mysql"|xargs chmod +x find /data/ -type f -name "mysql"|xargs ls -lfind /data/ -type f -name "mysql"|xargs dos2unixcd /application/mysql/scripts/./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/ --user=mysql./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data/ --user=mysqlcd /data/3306/./mysql startnetstat -lntupcd /data/3307/./mysql startnetstat -lntnp/application/mysql/bin/mysqladmin -u root password '123456' -S /data/3306/mysql.sock /application/mysql/bin/mysqladmin -u root password '123456' -S /data/3307/mysql.sock cd /data/3306/./mysql stopnetstat -lntupcd /data/3307/./mysql stopnetstat -lntup
0 0
- MySQL编译安装(多实例)
- MySQL编译安装(单实例)
- Cmake编译安装MySQL&mysqld_multi部署MySQL多实例方案
- mysql-5.5.34源码编译安装,多实例配置
- MySql(单实例-非编译)安装及使用说明
- centos编译安装mysql 5.6及安装多个mysql实例
- mysql 多实例安装
- mysql多实例安装
- mysql多实例安装
- Mysql多实例安装
- Mysql 多实例安装
- Mysql多实例安装
- Mysql多实例安装
- MySQL多实例安装
- 多实例MySQL安装
- MySQL 多实例安装
- mysql多实例安装
- MySQL多实例安装
- 【总结】10月训练赛第7场
- 仿美团下拉
- 最优程序
- 《C Primer Plus》学习笔记之 C数据的属性(三)类型限定词
- 前端数字显示的格式
- MySQL编译安装(多实例)
- SpringBoot学习(一)入门
- OS作业调度中HRN的模拟实现
- 修改私有成员(类成员)/只读成员的属性
- matlab中lsim和lqr的使用
- IOS疯狂基础之UIImage
- jQuery中attr()和prop()在修改checked属性时的区别
- Android5.0平台架构及特性
- maven 私服setting.xml配置