Ubuntu 14.04 MySQL 安装配置 For Cloudera Manages 5

本文详细介绍如何在Ubuntu系统中安装MySQL服务器,并配置相关参数以优化性能。包括安装过程、配置文件编辑、服务管理及创建必要的数据库和用户权限设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MySQL 安装配置




1.1 安装MySQL

使用root用户安装 mysql,命令如下:

root@CDH-01:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 464 not upgraded.
root@CDH-01:~# 


1.2 停 MySQL 服务

安装MySql成功后,mysql服务会自动启动,接下来我们将要配置mysql,则需要停止mysql服务。
root@CDH-01:~# service mysql stop

1.3 配置MySQL

1,Move old InnoDB log files /var/lib/mysql/ib_logfile0 and/var/lib/mysql/ib_logfile1 out of/var/lib/mysql/ to a backup location (移除旧的日志文件到备份目录)

2,添加配置文件

root@CDH-01:~# vi /etc/mysql/conf.d/mysql_cloudera_manager.cnf

写入:
[mysqld]
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links = 0

key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1

max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M

#log_bin should be on a disk with enough free space. Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your system
#and chown the specified folder to the mysql user.
log_bin=/var/lib/mysql/mysql_binary_log

# For MySQL version 5.1.8 or later. Comment out binlog_format for older versions.
binlog_format = mixed

read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M

# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit  = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

sql_mode=STRICT_ALL_TABLES


1.4 启动mysql服务

root@CDH-01:~# service mysql start


1.5 安装mysql JDBC驱动

root@CDH-01:~# apt-get install libmysql-java
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libmysql-java is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 464 not upgraded.
root@CDH-01:~# 


1.6 创建Cloudera-Manages-Server 需要用到的数据库表 for MySql。

Creating Databases for Activity Monitor, Reports Manager, Hive Metastore Server, Sentry Server, Cloudera Navigator AuditServer, and Cloudera Navigator Metadata Server


登录mysql

root@CDH-01:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 584
Server version: 5.5.47-0ubuntu0.14.04.1-log (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

执行创建数据库脚本语句。
create database amon DEFAULT CHARACTER SET utf8;
grant all on amon.* TO 'amon'@'localhost' IDENTIFIED BY 'amon_password';
grant all on amon.* TO 'amon'@'%' IDENTIFIED BY 'amon_password';
create database smon DEFAULT CHARACTER SET utf8;
grant all on smon.* TO 'smon'@'localhost' IDENTIFIED BY 'smon_password';
grant all on smon.* TO 'smon'@'%' IDENTIFIED BY 'smon_password';
create database rman DEFAULT CHARACTER SET utf8;
grant all on rman.* TO 'rman'@'localhost' IDENTIFIED BY 'rman_password';
grant all on rman.* TO 'rman'@'%' IDENTIFIED BY 'rman_password';
create database hmon DEFAULT CHARACTER SET utf8;
grant all on hmon.* TO 'hmon'@'localhost' IDENTIFIED BY 'hmon_password';
grant all on hmon.* TO 'hmon'@'%' IDENTIFIED BY 'hmon_password';
create database hive DEFAULT CHARACTER SET utf8;
grant all on hive.* TO 'hive'@'localhost' IDENTIFIED BY 'hive_password';
grant all on hive.* TO 'hive'@'%' IDENTIFIED BY 'hive_password';
create database oozie;
grant all privileges on oozie.* to 'oozie'@'localhost' identified by 'oozie';
grant all privileges on oozie.* to 'oozie'@'%' identified by 'oozie';

至此 MySql安装配置完毕。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值