Linux下 Mysql 安装以及优化
2015-03-02 10:25
351 查看
系统环境:CentOS 6.5
mysql版本:mysql-5.6.19.tar.gz
软件上传路径:/doiido/soft
一、Mysql安装
1:防火墙打开相应端口
# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
# /etc/rc.d/init.d/iptables save
2:安装相关依赖包
# yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel cmake perl lsof bison
3:删除自带的mysql
# rpm -qa|grep mysql
# rpm -e --allmatches --nodeps mysql-libs-5.1.71-1.el6.x86_64
4:创建相关目录
# mkdir /doiido/soft
# mkdir -p /doiido/mysql/data/
5:创建mysql用户
# /usr/sbin/groupadd mysql
# /usr/sbin/useradd -s /sbin/nologin -M -g mysql mysql
# chown -R mysql:mysql /doiido/mysql/
6:安装mysql
# cd /doiido/soft
# tar -zxvf mysql-5.6.19.tar.gz
# cd mysql-5.6.19
# cmake -DCMAKE_INSTALL_PREFIX=/doiido/server/mysql -DMYSQL_DATADIR=/doiido/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DWITH_READLINE=on
# make && make install
7:修改相关目录权限并创建软连接
# chmod +w /doiido/server/mysql
# chown -R mysql:mysql /doiido/server/mysql/
# ln -s /doiido/server/mysql/lib/lib* /usr/lib/
# ln -s /doiido/server/mysql/bin/mysql /usr/bin
8:修改配置文件
# cp /doiido/server/mysql/support-files/my-default.cnf /etc/my.cnf
# vi /etc/my.cnf
[mysqld]
character-set-server = utf8
default-storage-engine = MyISAM
basedir = /doiido/server/mysql
datadir = /doiido/mysql/data
log-error = /doiido/mysql/mysql_error.log
pid-file = /doiido/mysql/mysql.pid
max_allowed_packet = 32M
explicit_defaults_for_timestamp = true
9:安装mysql数据库
# /doiido/server/mysql/scripts/mysql_install_db --basedir=/doiido/server/mysql --datadir=/doiido/mysql/data --user=mysql
10:设置mysql开机自动启动服务
# cp /doiido/server/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
11:修改mysqld文件并启动mysql
# vi /etc/init.d/mysqld
#修改mysqld文件中的下面两项
basedir=/doiido/server/mysql
datadir=/doiido/mysql/data
# service mysqld start
二、mysql优化
软件版本
libunwind:libunwind-1.1.tar.gz
google-perftools:gperftools-2.2.tar.gz
1:安装libunwind(基于64位)
# cd /doiido/soft
# tar zxvf libunwind-1.1.tar.gz
# cd libunwind-1.1
# CFLAGS=-fPIC ./configure
# make CFLAGS=-fPIC
# make CFLAGS=-fPIC install
2:安装google-perftools:
# cd /doiido/soft
# tar zxvf gperftools-2.2.tar.gz
# cd gperftools-2.2/
# ./configure
# make && make install
# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
# /sbin/ldconfig
3:修改MySQL启动脚本(根据MySQL安装位置而定):
# vi /doiido/server/mysql/bin/mysqld_safe
在# executing mysqld_safe的下面加上:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
# service mysqld restart
4:查看tcmalloc是否起效:
# /usr/sbin/lsof -n | grep tcmalloc
如果发现以下信息,说明tcmalloc已经起效:
mysqld 11227 mysql mem REG 8,1 2171746 18287 /usr/local/lib/libtcmalloc.so.4.1.2
mysql版本:mysql-5.6.19.tar.gz
软件上传路径:/doiido/soft
一、Mysql安装
1:防火墙打开相应端口
# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
# /etc/rc.d/init.d/iptables save
2:安装相关依赖包
# yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel cmake perl lsof bison
3:删除自带的mysql
# rpm -qa|grep mysql
# rpm -e --allmatches --nodeps mysql-libs-5.1.71-1.el6.x86_64
4:创建相关目录
# mkdir /doiido/soft
# mkdir -p /doiido/mysql/data/
5:创建mysql用户
# /usr/sbin/groupadd mysql
# /usr/sbin/useradd -s /sbin/nologin -M -g mysql mysql
# chown -R mysql:mysql /doiido/mysql/
6:安装mysql
# cd /doiido/soft
# tar -zxvf mysql-5.6.19.tar.gz
# cd mysql-5.6.19
# cmake -DCMAKE_INSTALL_PREFIX=/doiido/server/mysql -DMYSQL_DATADIR=/doiido/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DWITH_READLINE=on
# make && make install
7:修改相关目录权限并创建软连接
# chmod +w /doiido/server/mysql
# chown -R mysql:mysql /doiido/server/mysql/
# ln -s /doiido/server/mysql/lib/lib* /usr/lib/
# ln -s /doiido/server/mysql/bin/mysql /usr/bin
8:修改配置文件
# cp /doiido/server/mysql/support-files/my-default.cnf /etc/my.cnf
# vi /etc/my.cnf
[mysqld]
character-set-server = utf8
default-storage-engine = MyISAM
basedir = /doiido/server/mysql
datadir = /doiido/mysql/data
log-error = /doiido/mysql/mysql_error.log
pid-file = /doiido/mysql/mysql.pid
max_allowed_packet = 32M
explicit_defaults_for_timestamp = true
9:安装mysql数据库
# /doiido/server/mysql/scripts/mysql_install_db --basedir=/doiido/server/mysql --datadir=/doiido/mysql/data --user=mysql
10:设置mysql开机自动启动服务
# cp /doiido/server/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
11:修改mysqld文件并启动mysql
# vi /etc/init.d/mysqld
#修改mysqld文件中的下面两项
basedir=/doiido/server/mysql
datadir=/doiido/mysql/data
# service mysqld start
二、mysql优化
软件版本
libunwind:libunwind-1.1.tar.gz
google-perftools:gperftools-2.2.tar.gz
1:安装libunwind(基于64位)
# cd /doiido/soft
# tar zxvf libunwind-1.1.tar.gz
# cd libunwind-1.1
# CFLAGS=-fPIC ./configure
# make CFLAGS=-fPIC
# make CFLAGS=-fPIC install
2:安装google-perftools:
# cd /doiido/soft
# tar zxvf gperftools-2.2.tar.gz
# cd gperftools-2.2/
# ./configure
# make && make install
# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
# /sbin/ldconfig
3:修改MySQL启动脚本(根据MySQL安装位置而定):
# vi /doiido/server/mysql/bin/mysqld_safe
在# executing mysqld_safe的下面加上:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
# service mysqld restart
4:查看tcmalloc是否起效:
# /usr/sbin/lsof -n | grep tcmalloc
如果发现以下信息,说明tcmalloc已经起效:
mysqld 11227 mysql mem REG 8,1 2171746 18287 /usr/local/lib/libtcmalloc.so.4.1.2
相关文章推荐
- Linux下 Mysql 安装以及优化
- linux 下mysql安装配置管理以及优化
- linux 下mysql安装配置管理以及优化
- MySQL安装(Linux)以及Navicat(Windows)连接
- linux下mysql的安装以及环境变量的配置
- linux下给php安装pdo_mysql和zlib以及测试模式的选择(禅道安装过程中遇到的问题)
- linux(centOS6) 安装Mysql 5.6.19数据库步骤、 问题以及相应的解决办法
- Windows7下MySQL5.5.20免安装版的配置 - (补上了我遇到的几个问题,以及mysql启动优化)
- DBdesigner在LINUX下的安装以及MYSQL的连接
- Mysql 在linux下的安装以及卸载(redhat)
- Linux下通过yum来安装 mysql 5.1,以及以前的旧版本(因服务器网络问题,安装后无法连接,无法验证正确性)
- linux下安装mysql以及php的mysql扩展
- linux下给php安装pdo_mysql和zlib以及测试模式的选择(禅道安装过程中遇到的问题)
- Linux安装MySQL后找不到my.cnf原因以及从sql语句文件恢复数据库
- linux mysql proxy 的安装,配置,以及读写分离
- Linux安装ProFTPd、MySQL以及Apache后有感
- linux mysql proxy 的安装,配置,以及读写分离
- Red Hat Enterprise Linux AS release 4 apache+MYsql+PHP的安装和优化
- linux安装mysql(源码)以及cmake编译
- linux下安装配置zabbix以及配置mysql监控