1、关闭防火墙
service iptables stop
chkconfig iptables off
setenforce 0
vi /etc/selinux/config
SELINUX=permissive
2、配置sysctl.conf
主要配置shmmax共享内存类参数,最大设置为50%-60%系统物理内存。
3、检查操作系统是否安装了MysqL
rpm -e MysqL-libs-5.1.66-2.el6_3.x86_64
如果因为依赖删不掉,则可以用yum来删:
yum remove MysqL-libs-5.1.66-2.el6_3.x86_64
再检查一下MysqL的安装包是否存在:
4、下载MysqL源码包
[root@MysqL yum.repos.d]# mkdir /u01
[root@MysqL yum.repos.d]# cd /u01
[root@MysqL u01]#
配置ftp,上传源码
a、配置源http://blog.csdn.net/kadwf123/article/details/78231694
b、配置ftp服务
yum -y install vsftpd
chkconfig vsftpd on
cd /etc/vsftpd
vi ftpusers
把root用户注释掉
vi user_list
把root用户注释掉
groupadd MysqL
创建MysqL组
6、配置MysqL环境变量
su - MysqL
vi .bash_profile
修改path变量:
使之生效
7、创建目录及授权
[root@MysqL vsftpd]# mkdir -p /u01/my3306/data
[root@MysqL vsftpd]# mkdir -p /u01/my3306/log/iblog
[root@MysqL vsftpd]# mkdir -p /u01/my3306/log/binlog
[root@MysqL vsftpd]# mkdir -p /u01/my3306/run
[root@MysqL vsftpd]# mkdir -p /u01/my3306/tmp
[root@MysqL vsftpd]#
授权:
[root@MysqL vsftpd]# chown -R MysqL:MysqL /u01/my3306
[root@MysqL vsftpd]# chmod -R 755 /u01/my3306
[root@MysqL vsftpd]#
8、解压MysqL5.6
tar -xzvf MysqL-5.6.39.tar.gz
9、配置yum源,安装cmake
yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib libxml openssl openssl-devel ncurses
安装上面的所有的依赖包,确保安装成功。
10、编译并安装
进入MysqL源码包的解压目录
执行如下命令:
cmake \
-DCMAKE_INSTALL_PREFIX=/u01/my3306 \
-DINSTALL_DATADIR=/u01/my3306/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=yes \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMysqL_UNIX_ADDR=/u01/my3306/run/MysqL.sock \
-DMysqL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on
失败,老是报错: CMake Error at cmake/ssl.cmake:167 (FILE): file STRINGS file "/u01/MysqL-5.6.39/OPENSSL_INCLUDE_DIR-NOTFOUND/openssl/opensslv.h" cannot be read. Call Stack (most recent call first): CMakeLists.txt:446 (MysqL_CHECK_SSL) -- OPENSSL_INCLUDE_DIR = OPENSSL_INCLUDE_DIR-NOTFOUND -- OPENSSL_LIBRARY = OPENSSL_LIBRARY-NOTFOUND -- CRYPTO_LIBRARY = CRYPTO_LIBRARY-NOTFOUND -- OPENSSL_MAJOR_VERSION = CMake Error at cmake/ssl.cmake:247 (MESSAGE): Cannot find appropriate system libraries for SSL. Make sure you've specified a supported SSL version. Consult the documentation for WITH_SSL alternatives Call Stack (most recent call first): CMakeLists.txt:446 (MysqL_CHECK_SSL) -- Using cmake version 2.8.12.2 -- Not building NDB -- Library MysqLclient depends on OSLIBS -lpthread;m;rt;dl -- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source. -- If you are inside a firewall,you may need to use an https proxy: export https_proxy=http://example.com:80 -- Library MysqLserver depends on OSLIBS -lpthread;m;rt;crypt;dl -- Skipping deb packaging on unsupported platform . -- CMAKE_BUILD_TYPE: RelWithDebInfo -- COMPILE_DEFINITIONS: HAVE_CONFIG_H -- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- Configuring incomplete,errors occurred! See also "/u01/MysqL-5.6.39/CMakeFiles/CMakeOutput.log". See also "/u01/MysqL-5.6.39/CMakeFiles/CMakeError.log". [root@MysqL MysqL-5.6.39]# ll 注意这个地方:
怀疑是openssl导致的,但是我的openssl检查却装了。
没办法,下一个在装,然后指定:
-DOPENSSL_ROOT_DIR=/usr/local/openssl \
-DOPENSSL_LIBRARIES=/usr/local/openssl/lib \
这两项。完整命令如下:
cmake \
-DCMAKE_INSTALL_PREFIX=/u01/my3306 \
-DMysqL_DATADIR=/u01/my3306/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=yes \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMysqL_UNIX_ADDR=/u01/my3306/run/MysqL.sock \
-DMysqL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DOPENSSL_ROOT_DIR=/usr/local/openssl \
-DOPENSSL_LIBRARIES=/usr/local/openssl/lib \
-DWITH_READLINE=on
下面说明使用二进制包安装openssl:
a、下载新版openssl安装包:https://www.openssl.org/source/
b、把安装文件openssl-1.0.2n.tar.gz上传到虚拟机。
c、tar -xzvf openssl-1.0.2n.tar.gz
d、cd openssl-1.0.2n
e、执行命令:./config --prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlib
注意,如果不指定 -fPIC选项,可能会出现如下错误:
Scanning dependencies of target clientlib [ 82%] Building C object libMysqL/CMakeFiles/clientlib.dir/get_password.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/libMysqL.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/errmsg.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/__/sql-common/client.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/__/sql-common/my_time.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/__/sql-common/client_plugin.c.o [ 83%] Building CXX object libMysqL/CMakeFiles/clientlib.dir/__/sql-common/client_authentication.cc.o [ 83%] Building CXX object libMysqL/CMakeFiles/clientlib.dir/__/sql/net_serv.cc.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/__/sql-common/pack.c.o [ 83%] Building C object libMysqL/CMakeFiles/clientlib.dir/__/sql/password.c.o Linking CXX static library libclientlib.a [ 83%] Built target clientlib Scanning dependencies of target libMysqL [ 83%] Building CXX object libMysqL/CMakeFiles/libMysqL.dir/libMysqL_exports_file.cc.o Linking CXX shared library libMysqLclient.so /usr/bin/ld: /usr/local/openssl/lib/libssl.a(t1_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/openssl/lib/libssl.a: could not read symbols: Bad value collect2: ld 返回 1 make[2]: *** [libMysqL/libMysqLclient.so.18.1.0] 错误 1 make[1]: *** [libMysqL/CMakeFiles/libMysqL.dir/all] 错误 2 make: *** [all] 错误 2 [root@MysqL MysqL-5.6.39]#
主要注意:
f、执行命令:make depend
g、执行命令:./config -t
h、执行make,编译openssl。注意执行make要有gcc编译器。
i、执行make install进行安装。
j、执行cd /usr/local
k、执行ldd /usr/local/openssl/bin/openssl
l、配置环境变量:PATH=/usr/local/openssl/bin:$PATH:$HOME/bin
m、使环境变量生效source /root/.bash_profile
n、which openssl
o、查看版本:openssl version
然后就可以执行cmake成功了:
cd/u01/MysqL-5.6.39/
rm -fCMakeCache.txt
下面直接进行make编译:
make
然后还需要执行make install安装到指定目录/u01/my3306中。
11、MysqL参数配置
把my.cnf参数文件直接传到/u01/my3306/目录下面去。
也可以直接建一个my.cnf,内容如下:
[client] port=3306 socket=/u01/my3306/MysqL.sock [MysqL] pid_file=/u01/my3306/run/MysqLd.pid [MysqLd] autocommit=1 general_log=off explicit_defaults_for_timestamp=true # system basedir=/u01/my3306 datadir=/u01/my3306/data max_allowed_packet=1g max_connections=3000 max_user_connections=2800 open_files_limit=65535 pid_file=/u01/my3306/run/MysqLd.pid port=3306 server_id=101 skip_name_resolve=ON socket=/u01/my3306/run/MysqL.sock tmpdir=/u01/my3306/tmp #binlog log_bin=/u01/my3306/log/binlog/binlog binlog_cache_size=32768 binlog_format=row expire_logs_days=7 log_slave_updates=ON max_binlog_cache_size=2147483648 max_binlog_size=524288000 sync_binlog=100 #logging log_error=/u01/my3306/log/error.log slow_query_log_file=/u01/my3306/log/slow.log log_queries_not_using_indexes=0 slow_query_log=1 log_slave_updates=ON log_slow_admin_statements=1 long_query_time=1 #relay relay_log=/u01/my3306/log/relaylog relay_log_index=/u01/my3306/log/relay.index relay_log_info_file=/u01/my3306/log/relay-log.info #slave slave_load_tmpdir=/u01/my3306/tmp slave_skip_errors=OFF #innodb innodb_data_home_dir=/u01/my3306/log/iblog innodb_log_group_home_dir=/u01/my3306/log/iblog innodb_adaptive_flushing=ON innodb_adaptive_hash_index=ON innodb_autoinc_lock_mode=1 innodb_buffer_pool_instances=8 #default innodb_change_buffering=inserts innodb_checksums=ON innodb_buffer_pool_size= 128M innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend innodb_doublewrite=ON innodb_file_format=Barracuda innodb_file_per_table=ON innodb_flush_log_at_trx_commit=1 innodb_flush_method=O_DIRECT innodb_io_capacity=1000 innodb_lock_wait_timeout=10 innodb_log_buffer_size=67108864 innodb_log_file_size=1048576000 innodb_log_files_in_group=4 innodb_max_dirty_pages_pct=60 innodb_open_files=60000 innodb_purge_threads=1 innodb_read_io_threads=4 innodb_stats_on_Metadata=OFF innodb_support_xa=ON innodb_use_native_aio=OFF innodb_write_io_threads=10 [MysqLd_safe] datadir=/u01/my3306/data
然后把/u01/my3306目录属主改成MysqL
chown -R MysqL:MysqL /u01/my3306
12、初始化MysqL脚本
cd /u01/my3306/scripts
./MysqL_install_db --help
./scripts/MysqL_install_db --defaults-file=/u01/my3306/my.cnf --datadir=/u01/my3306/data --user=MysqL
注意此命令要在/u01/my3306目录下执行。
13、启动MysqL
/u01/my3306/bin
[MysqL@MysqL bin]$ ./MysqLd_safe --defaults-file=/u01/my3306/my.cnf --user=MysqL &
检查MysqL进程: