CentOS 7 安装Percona Server+Mysql
程序员文章站
2023-11-27 15:14:16
一、环境说明
(1)centos-7-x86_64,内核版本
uname -r
3.10.0-693.el...
一、环境说明
(1)centos-7-x86_64,内核版本
uname -r 3.10.0-693.el7.x86_64
(2)mysql版本
percona-server-5.6.29
(3)文件存放路径
/home/soft
二、安装前准备
(1)配置权限
groupadd mysql useradd -r -g mysql mysql
(2)创建安装目录
mkdir /usr/local/mysql #mysql安装目录 chown -r mysql:mysql /usr/local/mysql mkdir /usr/local/mysql/dataconf #数据库配置存放目录 chown -r mysql:mysql /usr/local/mysql/dataconf mkdir /usr/local/mysql/sock #运行mysql时mysql.sock存放目录 chown -r mysql:mysql /usr/local/mysql/sock mkdir /var/log/mysql #创建日志存放目录 touch /var/log/mysql/mysql.log chown -r mysql:mysql /var/log/mysql/mysql.log touch /usr/local/mysql/my.cnf #创建mysql配置文件
三、安装编译环境
yum install readline-devel git gcc gcc-c++ make cmake bison bison-devel ncurses-devel libaio-devel perl zlib1g-dev autoconf
四、编译安装percona
cd /home/soft/ tar zxvf percona-server-5.6.29-76.2.tar.gz cd percona-server-5.6.29-76.2 cmake -dcmake_install_prefix=/usr/local/mysql #需要使用cmake进行安装,这里表示的是文件安装目录 -dsysconfdir=/usr/local/mysql #存放配置文件的目录 -dmysql_datadir=/usr/local/mysql/dataconf #存放数据库的目录 -dmysql_unix_addr=/usr/local/mysql/sock/mysqld.sock #存放mysql.sock文件的目录 -dmysql_tcp_port=3306 -dwith_myisam_storage_engine=1 #配置端口 -dwith_innobase_storage_engine=1 -dwith_partition_storage_engine=1 -dextra_charsets=all -ddefault_charset=utf8 #配置默认的字符编码格式 -ddefault_collation=utf8_general_ci -denabled_local_infile=1 -dwith_editline=bundled -dcmake_build_type=relwithdebinfo -dbuild_config=mysql_release -dfeature_set=community -dwith_embedded_server=off
之后,继续编译安装。
make -j 8 #大概需要30-40分钟左右。如果报错,请使用make clean , rm -rf cmakecache.txt make install
五、配置percona参数
cat /usr/local/mysql/my.cnf [mysqld] # disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 explicit_defaults_for_timestamp=true federated # settings user and group are ignored when systemd is used. # if you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/systemd basedir=/usr/local/mysql datadir=/usr/local/mysql/dataconf port=3306 socket=/usr/local/mysql/sock/mysql.sock symbolic-links=0 character_set_server=utf8 pid-file=/usr/local/mysql/mysql.pid skip-grant-tables [mysqld_safe] log-error=/var/log/mysql/mysql.log pid-file=/usr/local/mysql/mysql.pid socket=/usr/local/mysql/sock/mysql.sock [client] socket=/usr/local/mysql/mysql.sock [mysql.server] user=mysql basedir=/usr/local/mysql socket=/usr/local/mysql/sock/mysql.sock [mysql] socket=/usr/local/mysql/sock/mysql.sock
六、配置mysql访问权限
chown -r mysql:mysql /usr/local/mysql/bin chown -r mysql:mysql /usr/local/mysql/mysql.pid
七、初始化mysql服务器
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/dataconf --user=mysql
八、配置环境变量
为了能直接调用mysql命令,需要配置环境变量 vi /etc/profile 在/etc/profile文件末尾添加 export path=/usr/local/mysql/bin:$path 使环境变量立即生效 source /etc/profile
九、配置启动脚本
cp /home/soft/percona-server-5.6.29-76.2/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql chkconfig mysql on service mysql start/stop
十、后言
此方法我也不知道为什么在centos7里面安装之后可以用,在debian服务器里面无法进行编译安装使用。另外在使用的过程中,有时候可能也需要percona-server-client的支持。针对这个问题,可以使用以下方法解决:将文件上传到/home/soft/目录下,然后进行安装。安装方法如下:
rpm -ivh percona-server-shared-compat-5.5.35-rel33.0.611.rhel6.x86_64.rpm rpm -ivh percona-server-shared-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm rpm -ivh percona-server-devel-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm rpm -ivh percona-server-client-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm
或者使用rpm -ivh * 即可安装
推荐阅读
-
CentOS7下二进制安装mysql 5.7.23
-
Linux centos7环境下MySQL安装教程
-
CentOS 7 安装Percona Server+Mysql
-
CentOS7下二进制安装mysql 5.7.23
-
CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
-
详解Linux(centos7)下安装OpenSSL安装图文方法
-
Centos7安装swoole扩展操作示例
-
64位CentOs7源码安装mysql-5.6.35过程分享
-
VMware10安装CentOS7
-
详解centos7上elastic search安装及填坑记