如何在 CentOS 7 上安装 Percona Server
1、安装数据库源
# yum install percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm1
2、安装Percona 5.7
# yum install Percona-Server-server-571
3、启动数据库并设置开机启动
# service mysqld restart
# chkconfig mysqld on12
4、初始化数据库
[root@localhost Percona-db]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
1. 为centos配置yum源, 可以使用网易、aliyun或sohu的 2. 配置epel源 /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://centos.ustc.edu.cn/epel/6/$basearch failovermethod=priority enabled=1 gpgcheck=0 注: 选择其他的epel源也可以 3. 使配置生效 yum clean all yum makecache 三 安装docker并启动 A)安装 Yum install docker-io B)启动 Service dokcer start C)检查 Ps aux |grep docker ,查看是否有 "/usr/bin/docker -d"进程存在 执行Docker images 没有报错 D) 把dokcer的数据目录转移到大的磁盘分区上, 不是必须的,视自己的机器分区而定 Service docker stop Mkdir /data/dockerData/ Mv /var/lib/docker /data/dockerData/ ln -s /data/dockerData/docker /var/lib/dockerService docker start Service docker start 四 搭建docker私有仓库并制作centos镜像 1. 搭建docker私有仓库 安装并启动 Yum install docker-registry 修改配置 把/var/lib/docker-registry 软连接到 大的磁盘分区, 不是必须的,视自己的机器分区而定 修改配置/etc/sysconfig/docker-registry, 只监听内网的5000端口 修改配置/etc/docker-registry.yml 中search_backend和 sqlalchemy_index_database,修改目的是可以通过 curl "x.x.x.x:5000/v1/search?q=xxx" 查询仓库镜像。 #search_backend: _env:SEARCH_BACKEND search_backend: sqlalchemy #sqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db sqlalchemy_index_database: sqlite:////tmp/docker-registry.db 启动 Service docker-registry restart 检查下端口5000是否启动起来 netstat -ntlp 2. 制作centos镜像 这一步不是必须的,可用如下方案替换: 1)从docker的官方镜像库拉取contos的镜像, 然后再import到自己搭建的私有仓库。但docker的官方镜像库被墙了,需要自备梯子。 2)Docker官方镜像的临时解决方案 使用 index.dockboard.org 下载 Docker 官方镜像的临时解决方案 https://gist.github.com/genedna/6e552ab4c117f7ba8af4 除了上述两种方案, 这里讲如何定制自己centos镜像,仅供测试docker使用。 A) 安装软件 yum -y install febootstrap B)下载镜像 febootstrap -i bash -i wget -i yum -i iputils -i iproute -i man -i vim-minimal -i openssh-server -i openssh-clients centos6 centos6-image http://mirrors.aliyun.com/centos/6/os/x86_64/ C) 生成镜像 cd centos6-image && tar -c . |docker import - xxx/centos-base 查看镜像是否已经有xxx/centos-base docker images D) 运行测试 测试镜像是否正常 docker run -i -t xx/centos-base /bin/bash E) 把制作的镜像添加到私有的docker仓库 Docker image 获取IMAGE ID 使用私有的docker仓库的ip:端口给该镜像打tag docker tag 1920ceab1c8b xx.xx.xx.xx:5000/xxx/centos-base 推送该镜像到仓库 docker push xx.xx.xx.xx:5000/xxx/centos-base F) 在另一台机器上可以拉取该镜像并运行 docker pull xx.xx.xx.xx:5000/xxx/centos-base docker images docker run -t -i xx.xx.xx.xx:5000/xxx/centos-base /bin/bash 五 简单测试 1. 从私有仓库拉取镜像 Docker pull xx.xx.xx.xx:5000/xxx/centos-base 查看镜像ID docker images 根据ID给该镜像起一个简短名字 Docker tag 1920ceab1c8b xxx/centos-base 运行一个简单的container, 并把container ID传给变量JOB, 后续操作都依赖于该container ID JOB=$(docker run -d xxx/centos-base /bin/bash -c "while true; do /bin/echo Hello world; /bin/sleep 1; done") 查看container 是否正常启动 Docker ps 查看运行日志 Docker logs $JOB 停止进程 Docker stop $JOB 查看container 是否已停止 Docker ps
1.备份你的数据库接下来,在命令行下使用SQL命令创建一个mydatabases.sql文件,来重建或恢复salesdb和employeedb数据库,根据你的设置替换数据库名称,如果没有安装MySQL则跳过此步:
mysqldump -u root -p --databases employeedb salesdb > mydatabases.sql
2.复制当前的配置文件,如果你没有安装MYSQL也可跳过:
cp my.cnf my.cnf.bkp
3.删除之前的SQL服务器
停止MYSQL/MariaDB,如果它们还在运行:
systemctl stop mysql.service
3.卸载MariaDB和MYSQL:
yum remove MariaDB-server MariaDB-client MariaDB-shared mysql mysql-server
移动重命名放在/var/lib/mysql当中的MariaDB文件。这比仅仅只是移除更为安全快速,这就像2级即时备份。:)
mv /var/lib/mysql /var/lib/mysql_mariadb
4.使用二进制包安装Percona
你可以在众多Percona安装方法中选择,在CentOS中使用Yum或者RPM包安装通常是更好的主意,所以这些是本文介绍的方式,下载源文件编译后安装在本文中并没有介绍。
从Yum仓库中安装:
首先,你需要设置Percona的Yum库:
yum install http://www.percona.com/downloads/percona-release/RedHat/0.1-3/percona-release-0.1-3.noarch.rpm
接下来安装Percona:
yum install Percona-Server-client-56 Percona-Server-server-56
上面的命令安装Percona的服务器和客户端、共享库,可能需要Perl和Perl模块,以及其他依赖的需要,如DBI::MySQL。如果这些尚未安装,可能需要安装更多的依赖包。
使用RPM包安装:
我们可以使用wget命令下载所有的rpm包:
wget -r -l 1 -nd -A rpm -R "*devel*,*debuginfo*" \
http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.42-37.1/binary/redhat/7/x86_64/
使用rpm工具,一次性安装所有的rpm包:
rpm -ivh Percona-Server-server-55-5.5.42-rel37.1.el7.x86_64.rpm \
Percona-Server-client-55-5.5.42-rel37.1.el7.x86_64.rpm \
Percona-Server-shared-55-5.5.42-rel37.1.el7.x86_64.rpm
注意在上面命令语句中最后的反斜杠'\'(只是为了换行方便)。如果您安装单独的软件包,记住要解决依赖关系,在安装客户端之前要先安装共享包,在安装服务器之前请先安装客户端。
5.配置Percona服务器
恢复之前的配置
当我们从MariaDB迁移过来时,你可以将之前的my.cnf的备份文件恢复回来。
cp /etc/my.cnf.bkp /etc/my.cnf
创建一个新的my.cnf文件
如果你需要一个适合你需求的新的配置文件或者你并没有备份配置文件,你可以使用以下方法,通过简单的几步生成新的配置文件。
下面是Percona-server软件包自带的my.cnf文件
# Percona Server template configuration
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
根据你的需要配置好my.cnf后,就可以启动该服务了:
systemctl restart mysql.service
1、安装数据库源
# yum install percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm1
2、安装Percona 5.7
# yum install Percona-Server-server-571
3、启动数据库并设置开机启动
# service mysqld restart
# chkconfig mysqld on12
4、初始化数据库
[root@localhost Percona-db]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
邢肾长天: 软件centos7安装步骤:1、U盘安装的用户,也是一样的安装步骤.选择install centos 7.2、选择安装语言,也是用户安装完成后的系统语言.3、进入软件选择,选择GNOME桌面,否则用户无法使用可视化界面进行操作,而只能够使用命令行操作.4、选择完了以后用户可以根据自身需求添加各种附加软件.5、在进入系统安装位置,进行确认.详细可以看安装教程.centos 7 64位 http://www.3322.cc/soft/12676.html
德清县13613349992: 如何重新安装centos 7 系统 - ?
邢肾长天: 说明:截止目前CentOS 7.x最新版本为CentOS 7.0,下面介绍CentOS 7.0的具体安装配置过程 服务器相关设置如下:操作系统:CentOS 7.0 64位 IP地址:192.168.21.128 网关:192.168.21.2 DNS:8.8.8.8 8.8.4.4 备注:生产服务器如果是大内...
德清县13613349992: 怎样用u盘安装centos7 - ?
邢肾长天: 请准备好一个大于4G的U盘2 请自行百度下载Centos7操作系统的DVD装3 请自行下载安装UltraISO软件4 安装完成之后运行UltraISO软件5 选择文件---打开6 找到你下载的Centos7的DVD文件 是ISO格式的7 加载完成之后可以看到UltraISO中的...
德清县13613349992: 如何在虚拟机安装centos7 - ?
邢肾长天: 方法/步骤 1 打开虚拟机软件“VMware”,选择“创建新的虚拟机”;2 选择“自定义(高级)”选项,点击“下一步”;3 在“硬件兼容性”处选择最高的版本,我这里是“Workstation 10.0”,点击“下一步”;4 选择“稍后安装操作系统”,...
德清县13613349992: centos 7怎么安装??
邢肾长天: centos 7怎么安装?或许还有好多人都不了解centos7怎么安装.下文提供了centos 7安装的一些技巧,希望对大家有所帮助.CentOS 提供了不同的安装映像.你所需的映像视乎你的安装环境.这些映像都可以烧录在 DVD 上或用 dd 写在 USB ...
德清县13613349992: centos7 vmtools怎么安装 - ?
邢肾长天: centos安装教程1、小编使用虚拟机安装系统,如果用户想要将自己的计算机重装成centos,那么可以下载软碟通(ultraiso)来进行启动盘的制作,再通过U盘安装系统.打开虚拟机后选择典型安装系统.2、如果用户觉得安装麻烦,且英语水平...
德清县13613349992: 如何在CentOS 7中安装Git - ?
邢肾长天: 前期准备 请确保机器上安装有CentOS 7系统以及一个帐户具有root权限.因为需要在系统上安装软件.1、安装Git - 从源代码编译 从源代码编译和安装软件并不是很难,但是可以肯定它需要一些知识,仔细地按照本教程的每个步骤.这个方法可...
德清县13613349992: 如何在CentOS 7中安装或升级到最新的内核版本 - ?
邢肾长天: 安装教程1、小编使用虚拟机安装系统,如果用户想要将自己的计算机重装成centos,那么可以下载软碟通(ultraiso)来进行启动盘的制作,再通过U盘安装系统.打开虚拟机后选择典型安装系统.2、如果用户觉得安装麻烦,且英语水平没问题...
德清县13613349992: 如何用U盘安装CentOS7系统 - ?
邢肾长天: 1.准备一个使用u大侠软件制作好的启动u盘一个(最好1G以上的空的U盘),关于如何使用u大侠制作u盘启动盘;2.下载CentOS7系统 【第一步】将CentOS7系统镜像包复制到U盘GHO文件夹内 .注意:有时制作完成后,打开U盘找不到GHO...
德清县13613349992: 如何centos7.1安装系统 - ?
邢肾长天: 一、安装CentOS 7.1 服务器开机,设成光驱启动,成功引导系统后 界面说明:Install CentOS 7 //安装CentOS 7 Test this media & install CentOS 7 //测试安装文件并安装CentOS 7 Troubleshooting //修复故障 这里选择第一项,安装CentOS 7,回...