cmake编译安装mysql多实例
1.简介
一台机器开启多个不同的端口,运行多个mysql服务进程,通过不同的soccer监听服务端口来提供各自的服务,使用不同的my.cnf 配置文件、启动程序。
2.作用:充分利用资源,节省资源(类似合租房)。
3.多实例应用场景:资源紧张型公司;并发量不是很特别大的业务、门户网站。
门户网站使用多实例的目的是配硬件好的服务器,节省IDC机柜空间,充分利用硬件资源。
4.安装mysql多实例
1)安装mysql数据库
写在前面:/server/tools/ 是存放安装包的目录
检查环境
[[email protected] tools]# /etc/init.d/iptables status iptables: Firewall is not running. [[email protected] tools]# getenforce Disabled
安装依赖包
yum -y install ncurces-devel libaio-devel
准备安装包
-rw-r--r-- 1 root root 5691656 Jul 23 11:24 cmake-2.8.8.tar.gz -rw-r--r-- 1 root root 3374 Jul 23 14:57 data.zip -rw-r--r-- 1 root root 24596474 Jul 23 11:25 mysql-5.5.32.tar.gz
安装cmake编译工具
cd /server/tools/ tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure gmake gmake install cd ../
创建mysql用户和组
groupadd mysql useradd mysql -s /sbin/nologin -M -g mysql
编译安装mysql数据库
tar xf mysql-5.5.32.tar.gz cd mysql-5.5.32
编译过程中报错:
[[email protected] 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 > -DDEFAULT_CHARSET=utf8 > -DDEFAULT_COLLATION=utf8_general_ci > -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 -- Running cmake version 2.8.8 -- MySQL 5.5.32 -- Packaging as: mysql-5.5.32-Linux-x86_64 -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:83 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:118 (FIND_CURSES) cmake/readline.cmake:214 (MYSQL_USE_BUNDLED_READLINE) CMakeLists.txt:269 (MYSQL_CHECK_READLINE) -- Configuring incomplete, errors occurred!
解决方法:安装gcc编译工具,然后再编译安装
yum -y install gcc gcc-c++ find / -type f -name "rm CMakeCache.txt" #有网友建议需要删掉CMakeCache.txt,我找了一下,没找到 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 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -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
-- Build files have been written to: /server/tools/mysql-5.5.32 #表示编译成功
安装
make && make install
ln -s /application/mysql-5.5.32/ /application/mysql
如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。
配置环境变量
echo export ‘PATH=/application/mysql/bin:$PATH‘ >>/etc/profile [[email protected] mysql-5.5.32]# tail -1 /etc/profile export PATH=/application/mysql/bin:$PATH
2)配置mysql多实例
[[email protected] tools]# cp /server/tools/data.zip / [[email protected] tools]# cd / [[email protected] /]# unzip data.zip Archive: data.zip creating: data/ creating: data/3306/ inflating: data/3306/my.cnf inflating: data/3306/mysql creating: data/3307/ inflating: data/3307/my.cnf inflating: data/3307/mysql [[email protected] /]# tree data data ├── 3306 │?? ├── my.cnf │?? └── mysql └── 3307 ├── my.cnf └── mysql 2 directories, 4 files
未完,待续
时间: 2024-12-06 08:24:14