1.安装MySQL
[root@ip-172-31-30-175 mysql]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm MySQL-client-5.6.27-1.el6.x86_64.rpm warning: MySQL-server-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.27-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
发生错误,原因在于之前的版本与要安装的版本有冲突,
[root@ip-172-31-30-175 mysql]# yum -y remove mysql-libs-5.1.73* Loaded plugins: fastestmirror, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 will be erased --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64 --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64 --> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64 --> Running transaction check ---> Package postfix.x86_64 2:2.6.6-6.el6_5 will be erased --> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-7.el6.centos.x86_64 --> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-12.el6.x86_64 --> Running transaction check ---> Package cronie.x86_64 0:1.4.4-12.el6 will be erased --> Processing Dependency: cronie = 1.4.4-12.el6 for package: cronie-anacron-1.4.4-12.el6.x86_64 ---> Package redhat-lsb-core.x86_64 0:4.0-7.el6.centos will be erased --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-printing-4.0-7.el6.centos.x86_64 --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0-7.el6.centos for package: redhat-lsb-4.0-7.el6.centos.x86_64 --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-graphics-4.0-7.el6.centos.x86_64 --> Running transaction check ---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be erased ---> Package redhat-lsb.x86_64 0:4.0-7.el6.centos will be erased --> Processing Dependency: redhat-lsb(x86-64) = 4.0-7.el6.centos for package: redhat-lsb-compat-4.0-7.el6.centos.x86_64 ---> Package redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos will be erased ---> Package redhat-lsb-printing.x86_64 0:4.0-7.el6.centos will be erased --> Running transaction check ---> Package redhat-lsb-compat.x86_64 0:4.0-7.el6.centos will be erased --> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch --> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-27.el6.x86_64 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package crontabs.noarch 0:1.10-33.el6 will be erased ---> Package sysstat.x86_64 0:9.0.4-27.el6 will be erased --> Processing Dependency: /usr/bin/run-parts for package: cloud-init-0.7.4-2.el6.noarch --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package cloud-init.noarch 0:0.7.4-2.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================== Removing: mysql-libs x86_64 5.1.73-3.el6_5 @updates 4.0 M Removing for dependencies: cloud-init noarch 0.7.4-2.el6 installed 1.7 M cronie x86_64 1.4.4-12.el6 @anaconda-CentOS-201311272149.x86_64/6.5 174 k cronie-anacron x86_64 1.4.4-12.el6 @anaconda-CentOS-201311272149.x86_64/6.5 43 k crontabs noarch 1.10-33.el6 @anaconda-CentOS-201311272149.x86_64/6.5 2.4 k postfix x86_64 2:2.6.6-6.el6_5 @updates 9.7 M redhat-lsb x86_64 4.0-7.el6.centos @base 0.0 redhat-lsb-compat x86_64 4.0-7.el6.centos @base 0.0 redhat-lsb-core x86_64 4.0-7.el6.centos @base 22 k redhat-lsb-graphics x86_64 4.0-7.el6.centos @base 0.0 redhat-lsb-printing x86_64 4.0-7.el6.centos @base 0.0 sysstat x86_64 9.0.4-27.el6 @base 825 k Transaction Summary =============================================================================================================================================================================================================== Remove 12 Package(s) Installed size: 16 M Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : redhat-lsb-compat-4.0-7.el6.centos.x86_64 1/12 Erasing : redhat-lsb-4.0-7.el6.centos.x86_64 2/12 Erasing : redhat-lsb-graphics-4.0-7.el6.centos.x86_64 3/12 Erasing : redhat-lsb-printing-4.0-7.el6.centos.x86_64 4/12 Erasing : redhat-lsb-core-4.0-7.el6.centos.x86_64 5/12 Erasing : cloud-init-0.7.4-2.el6.noarch 6/12 /var/tmp/rpm-tmp.VN9AWo: line 1: lsb_release: command not found warning: /etc/cloud/cloud.cfg.d/05_logging.cfg saved as /etc/cloud/cloud.cfg.d/05_logging.cfg.rpmsave warning: /etc/cloud/cloud.cfg saved as /etc/cloud/cloud.cfg.rpmsave Erasing : sysstat-9.0.4-27.el6.x86_64 7/12 Erasing : crontabs-1.10-33.el6.noarch 8/12 Erasing : cronie-anacron-1.4.4-12.el6.x86_64 9/12 Erasing : cronie-1.4.4-12.el6.x86_64 10/12 Erasing : 2:postfix-2.6.6-6.el6_5.x86_64 11/12 Erasing : mysql-libs-5.1.73-3.el6_5.x86_64 12/12 Verifying : redhat-lsb-printing-4.0-7.el6.centos.x86_64 1/12 Verifying : cronie-anacron-1.4.4-12.el6.x86_64 2/12 Verifying : mysql-libs-5.1.73-3.el6_5.x86_64 3/12 Verifying : redhat-lsb-4.0-7.el6.centos.x86_64 4/12 Verifying : redhat-lsb-core-4.0-7.el6.centos.x86_64 5/12 Verifying : sysstat-9.0.4-27.el6.x86_64 6/12 Verifying : cloud-init-0.7.4-2.el6.noarch 7/12 Verifying : crontabs-1.10-33.el6.noarch 8/12 Verifying : redhat-lsb-compat-4.0-7.el6.centos.x86_64 9/12 Verifying : cronie-1.4.4-12.el6.x86_64 10/12 Verifying : 2:postfix-2.6.6-6.el6_5.x86_64 11/12 Verifying : redhat-lsb-graphics-4.0-7.el6.centos.x86_64 12/12 Removed: mysql-libs.x86_64 0:5.1.73-3.el6_5 Dependency Removed: cloud-init.noarch 0:0.7.4-2.el6 cronie.x86_64 0:1.4.4-12.el6 cronie-anacron.x86_64 0:1.4.4-12.el6 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-6.el6_5 redhat-lsb.x86_64 0:4.0-7.el6.centos redhat-lsb-compat.x86_64 0:4.0-7.el6.centos redhat-lsb-core.x86_64 0:4.0-7.el6.centos redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos redhat-lsb-printing.x86_64 0:4.0-7.el6.centos sysstat.x86_64 0:9.0.4-27.el6 Complete! [root@ip-172-31-30-175 mysql]#
再次安装就没有问题了:
[root@ip-172-31-30-175 mysql]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm MySQL-client-5.6.27-1.el6.x86_64.rpm warning: MySQL-server-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MySQL-client ########################################### [ 50%] 2:MySQL-server ########################################### [100%] warning: user mysql does not exist - using root warning: group mysql does not exist - using root 2015-12-01 08:53:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2015-12-01 08:53:50 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 12164 ... 2015-12-01 08:53:50 12164 [Note] InnoDB: Using atomics to ref count buffer pool pages 2015-12-01 08:53:50 12164 [Note] InnoDB: The InnoDB memory heap is disabled 2015-12-01 08:53:50 12164 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2015-12-01 08:53:50 12164 [Note] InnoDB: Memory barrier is not used 2015-12-01 08:53:50 12164 [Note] InnoDB: Compressed tables use zlib 1.2.3 2015-12-01 08:53:50 12164 [Note] InnoDB: Using Linux native AIO 2015-12-01 08:53:50 12164 [Note] InnoDB: Using CPU crc32 instructions 2015-12-01 08:53:50 12164 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2015-12-01 08:53:50 12164 [Note] InnoDB: Completed initialization of buffer pool 2015-12-01 08:53:51 12164 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2015-12-01 08:53:51 12164 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 2015-12-01 08:53:51 12164 [Note] InnoDB: Database physically writes the file full: wait... 2015-12-01 08:53:51 12164 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2015-12-01 08:53:51 12164 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2015-12-01 08:53:51 12164 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2015-12-01 08:53:51 12164 [Warning] InnoDB: New log files created, LSN=45781 2015-12-01 08:53:51 12164 [Note] InnoDB: Doublewrite buffer not found: creating new 2015-12-01 08:53:51 12164 [Note] InnoDB: Doublewrite buffer created 2015-12-01 08:53:51 12164 [Note] InnoDB: 128 rollback segment(s) are active. 2015-12-01 08:53:51 12164 [Warning] InnoDB: Creating foreign key constraint system tables. 2015-12-01 08:53:51 12164 [Note] InnoDB: Foreign key constraint system tables created 2015-12-01 08:53:51 12164 [Note] InnoDB: Creating tablespace and datafile system tables. 2015-12-01 08:53:51 12164 [Note] InnoDB: Tablespace and datafile system tables created. 2015-12-01 08:53:51 12164 [Note] InnoDB: Waiting for purge to start 2015-12-01 08:53:51 12164 [Note] InnoDB: 5.6.27 started; log sequence number 0 A random root password has been set. You will find it in '/root/.mysql_secret'. 2015-12-01 08:53:52 12164 [Note] Binlog end 2015-12-01 08:53:52 12164 [Note] InnoDB: FTS optimize thread exiting. 2015-12-01 08:53:52 12164 [Note] InnoDB: Starting shutdown... 2015-12-01 08:53:53 12164 [Note] InnoDB: Shutdown completed; log sequence number 1625977 2015-12-01 08:53:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2015-12-01 08:53:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 12186 ... 2015-12-01 08:53:53 12186 [Note] InnoDB: Using atomics to ref count buffer pool pages 2015-12-01 08:53:53 12186 [Note] InnoDB: The InnoDB memory heap is disabled 2015-12-01 08:53:53 12186 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2015-12-01 08:53:53 12186 [Note] InnoDB: Memory barrier is not used 2015-12-01 08:53:53 12186 [Note] InnoDB: Compressed tables use zlib 1.2.3 2015-12-01 08:53:53 12186 [Note] InnoDB: Using Linux native AIO 2015-12-01 08:53:53 12186 [Note] InnoDB: Using CPU crc32 instructions 2015-12-01 08:53:53 12186 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2015-12-01 08:53:53 12186 [Note] InnoDB: Completed initialization of buffer pool 2015-12-01 08:53:53 12186 [Note] InnoDB: Highest supported file format is Barracuda. 2015-12-01 08:53:53 12186 [Note] InnoDB: 128 rollback segment(s) are active. 2015-12-01 08:53:53 12186 [Note] InnoDB: Waiting for purge to start 2015-12-01 08:53:53 12186 [Note] InnoDB: 5.6.27 started; log sequence number 1625977 2015-12-01 08:53:53 12186 [Note] Binlog end 2015-12-01 08:53:53 12186 [Note] InnoDB: FTS optimize thread exiting. 2015-12-01 08:53:53 12186 [Note] InnoDB: Starting shutdown... 2015-12-01 08:53:55 12186 [Note] InnoDB: Shutdown completed; log sequence number 1625987 A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'. You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag. Also, the account for the anonymous user has been removed. In addition, you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test database. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings [root@ip-172-31-30-175 mysql]#
mysql5.6对为root用户生产了一个随机密码,这个随机密码存放在/root/.mysql_secret中
[root@ip-172-31-30-175 mysql]# cat /root/.mysql_secret # The random password set for the root user at Tue Dec 1 08:53:51 2015 (local time): 6yoMKdmnzyIfvZA3
[root@ip-172-31-30-175 mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1 Server version: 5.6.27 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并修改掉这个随机生产的密码,上面的提示符后面应该输入/root/.mysql_secret中的随机密码,登录后,用SET PASSWORD修改密码:
mysql> SET PASSWORD = PASSWORD('123456'); Query OK, 0 rows affected (0.00 sec) mysql>
注意命令的大小写!
2.设置开机启动mysql并启动服务:
[root@ip-172-31-30-175 mysql]# chkconfig mysql on [root@ip-172-31-30-175 mysql]# service mysql start Starting MySQL. SUCCESS! [root@ip-172-31-30-175 mysql]#
3.安装MySQL JDBC Driver
在需要访问MySQL的机器上(比如CMS,MGMT角色)安装jdbc driver
[root@ip-172-31-30-175 mysql]# unzip mysql-connector-java-5.1.37.zip [root@ip-172-31-30-175 mysql]# cp mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar /usr/share/java
[root@ip-172-31-30-175 java]# ln -s mysql-connector-java-5.1.37-bin.jar mysql-connector-java.jar
[root@ip-172-31-30-175 mysql]# cd /usr/share/java [root@ip-172-31-30-175 java]# pwd /usr/share/java [root@ip-172-31-30-175 java]# ls gcj-endorsed jline-0.9.94.jar jline.jar js-1.7.jar js.jar libgcj-4.4.4.jar libgcj-4.4.7.jar mysql-connector-java-5.1.37-bin.jar rhino-1.7.jar rhino-examples-1.7.jar rhino-examples.jar rhino.jar [root@ip-172-31-30-175 java]# ln -s mysql-connector-java-5.1.37.jar mysql-connector-java.jar [root@ip-172-31-30-175 java]# ll total 11772 drwxr-xr-x 2 root root 4096 Oct 14 2014 gcj-endorsed -rw-r--r-- 1 root root 84746 Aug 22 2010 jline-0.9.94.jar lrwxrwxrwx 1 root root 16 Feb 21 2014 jline.jar -> jline-0.9.94.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 js-1.7.jar -> rhino-1.7.jar lrwxrwxrwx 1 root root 10 Feb 21 2014 js.jar -> js-1.7.jar -rw-r--r-- 1 root root 10143547 Oct 14 2014 libgcj-4.4.4.jar lrwxrwxrwx 1 root root 16 Dec 16 2014 libgcj-4.4.7.jar -> libgcj-4.4.4.jar -rw-r--r-- 1 root root 985603 Dec 1 09:09 mysql-connector-java-5.1.37-bin.jar lrwxrwxrwx 1 root root 31 Dec 1 09:10 mysql-connector-java.jar -> mysql-connector-java-5.1.37.jar -rw-r--r-- 1 root root 807405 Aug 21 2010 rhino-1.7.jar -rw-r--r-- 1 root root 18260 Aug 21 2010 rhino-examples-1.7.jar lrwxrwxrwx 1 root root 22 Feb 21 2014 rhino-examples.jar -> rhino-examples-1.7.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 rhino.jar -> rhino-1.7.jar [root@ip-172-31-30-175 java]#
3.为Cloudera管理器配置外部数据库
为了保证在生产环境的安全,禁止远程机器以root用户登录,禁止匿名登录。这步在POC环境下可选。注意root的密码为上一步中设置的123456
[root@ip-172-31-30-175 ec2-user]# /usr/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. 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? [Y/n] 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? [Y/n] n ... skipping. 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? [Y/n] 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? [Y/n] Y ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up... [root@ip-172-31-30-175 ec2-user]#
建立CDH各组件需要的数据库:
mysql -u root --password=123456 -e "create user 'hive'@'%' identified by '123456'"
mysql -u root --password=123456 -e 'create database metastore default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on metastore.* to 'hive'@'%'"
mysql -u root --password='123456' -e "create user 'amon'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database amon default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on amon.* to 'amon'@'%'"
mysql -u root --password='123456' -e "create user 'rman'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database rman default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on rman.* to 'rman'@'%'"
mysql -u root --password='123456' -e "create user 'sentry'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database sentry default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on sentry.* to 'sentry'@'%'"
mysql -u root --password='123456' -e "create user 'nav'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database nav default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on nav.* to 'nav'@'%'"
mysql -u root --password='123456' -e "create user 'navms'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database navms default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on navms.* to 'navms'@'%'"
mysql -u root --password='123456' -e "create user 'cm'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database cm default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on cm.* to 'cm'@'%'"
mysql -u root --password='123456' -e "create user 'oozie'@'%' identified by '123456'"
mysql -u root --password='123456' -e 'create database oozie default character set utf8'
mysql -u root --password='123456' -e "grant all privileges on oozie.* to 'oozie'@'%'"
执行结果如下:
[root@ip-172-31-30-175 ec2-user]# mysql -u root --password=123456 -e "create user 'hive'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password=123456 -e 'create database metastore default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on metastore.* to 'amon'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'amon'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'amon'@'%' [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database amon default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on amon.* to 'amon'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'rman'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database rman default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on rman.* to 'rman'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'sentry'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database sentry default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on sentry.* to 'sentry'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'nav'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database nav default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on nav.* to 'nav'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'navms'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database navms default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on navms.* to 'navms'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'cm'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database cm default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on cm.* to 'cm'@'%'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "create user 'oozie'@'%' identified by '123456'" Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e 'create database oozie default character set utf8' Warning: Using a password on the command line interface can be insecure. [root@ip-172-31-30-175 ec2-user]# mysql -u root --password='123456' -e "grant all privileges on cm.* to 'oozie'@'%'" Warning: Using a password on the command line interface can be insecure.
最后还需要运行如下脚本:
[root@ip-172-31-30-175 ec2-user]# /usr/share/cmf/schema/scm_prepare_database.sh -h localhost mysql cm cm 123456 JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera Verifying that we can write to /etc/cloudera-scm-server Creating SCM configuration file in /etc/cloudera-scm-server Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db. log4j:ERROR Could not find value for key log4j.appender.A log4j:ERROR Could not instantiate appender named "A". [2015-12-01 13:00:03,471] INFO 0[main] - com.cloudera.enterprise.dbutil.DbCommandExecutor.testDbConnection(DbCommandExecutor.java:247) - Successfully connected to database. All done, your SCM database is configured correctly!
4.搭建内部的http源服务器,将下载的介质上传
先安装createrepo这个工具:
[root@ip-172-31-30-175 cloudera]# yum install createrepo Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile * base: centos.sonn.com * extras: mirror.web-ster.com * updates: mirror.supremebytes.com Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-22.el6 will be installed --> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-22.el6.noarch --> Running transaction check ---> Package python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed --> Processing Dependency: deltarpm = 3.5-0.5.20090913git.el6 for package: python-deltarpm-3.5-0.5.20090913git.el6.x86_64 --> Running transaction check ---> Package deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================== Installing: createrepo noarch 0.9.9-22.el6 base 96 k Installing for dependencies: deltarpm x86_64 3.5-0.5.20090913git.el6 base 71 k python-deltarpm x86_64 3.5-0.5.20090913git.el6 base 27 k Transaction Summary =============================================================================================================================================================================================================== Install 3 Package(s) Total download size: 194 k Installed size: 520 k Is this ok [y/N]: y Downloading Packages: (1/3): createrepo-0.9.9-22.el6.noarch.rpm | 96 kB 00:00 (2/3): deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm | 71 kB 00:00 (3/3): python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm | 27 kB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 735 kB/s | 194 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3 Installing : python-deltarpm-3.5-0.5.20090913git.el6.x86_64 2/3 Installing : createrepo-0.9.9-22.el6.noarch 3/3 Verifying : python-deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3 Verifying : createrepo-0.9.9-22.el6.noarch 2/3 Verifying : deltarpm-3.5-0.5.20090913git.el6.x86_64 3/3 Installed: createrepo.noarch 0:0.9.9-22.el6 Dependency Installed: deltarpm.x86_64 0:3.5-0.5.20090913git.el6 python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 Complete! [root@ip-172-31-30-175 cloudera]#
在安装http服务器:
[root@ip-172-31-30-175 cloudera]# yum install httpd Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile * base: centos.sonn.com * extras: mirror.web-ster.com * updates: mirror.supremebytes.com Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-39.el6.centos will be updated ---> Package httpd.x86_64 0:2.2.15-47.el6.centos will be an update --> Processing Dependency: httpd-tools = 2.2.15-47.el6.centos for package: httpd-2.2.15-47.el6.centos.x86_64 --> Running transaction check ---> Package httpd-tools.x86_64 0:2.2.15-39.el6.centos will be updated ---> Package httpd-tools.x86_64 0:2.2.15-47.el6.centos will be an update --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================== Updating: httpd x86_64 2.2.15-47.el6.centos updates 830 k Updating for dependencies: httpd-tools x86_64 2.2.15-47.el6.centos updates 77 k Transaction Summary =============================================================================================================================================================================================================== Upgrade 2 Package(s) Total download size: 907 k Is this ok [y/N]: y Downloading Packages: (1/2): httpd-2.2.15-47.el6.centos.x86_64.rpm | 830 kB 00:00 (2/2): httpd-tools-2.2.15-47.el6.centos.x86_64.rpm | 77 kB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.8 MB/s | 907 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : httpd-tools-2.2.15-47.el6.centos.x86_64 1/4 Updating : httpd-2.2.15-47.el6.centos.x86_64 2/4 Cleanup : httpd-2.2.15-39.el6.centos.x86_64 3/4 Cleanup : httpd-tools-2.2.15-39.el6.centos.x86_64 4/4 Verifying : httpd-tools-2.2.15-47.el6.centos.x86_64 1/4 Verifying : httpd-2.2.15-47.el6.centos.x86_64 2/4 Verifying : httpd-2.2.15-39.el6.centos.x86_64 3/4 Verifying : httpd-tools-2.2.15-39.el6.centos.x86_64 4/4 Updated: httpd.x86_64 0:2.2.15-47.el6.centos Dependency Updated: httpd-tools.x86_64 0:2.2.15-47.el6.centos Complete! [root@ip-172-31-30-175 cloudera]#
把安装文件拷贝到源服务器上并建立repo:
[root@ip-172-31-30-175 cloudera]# pwd /root/cloudera [root@ip-172-31-30-175 cloudera]# ll total 12 drwxr-xr-x 2 root root 4096 Dec 1 08:16 cdh5.5.0 drwxr-xr-x 2 root root 4096 Dec 1 07:57 cm5.5.0 drwxr-xr-x 3 root root 4096 Dec 1 09:07 mysql [root@ip-172-31-30-175 cloudera]# cp -r cdh5.5.0 /var/www/html/ [root@ip-172-31-30-175 cloudera]# cp -r cm5.5.0 /var/www/html/ [root@ip-172-31-30-175 cloudera]# createrepo /var/www/html/cm5.5.0/ Spawning worker 0 with 7 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@ip-172-31-30-175 cloudera]# chmod -R ugo+rX /var/www/html
启动服务器:
[root@ip-172-31-30-175 cloudera]# service httpd status httpd is stopped [root@ip-172-31-30-175 cloudera]# service httpd start Starting httpd: [ OK ] [root@ip-172-31-30-175 cloudera]# service httpd status httpd (pid 3338) is running...
最后到http://172.31.30.175/cm5.5.0和http://172.31.30.175/cdh5.5.0上检查一下文件是否可以反问。
Index of /cm5.5.0
Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
cloudera-manager-agent-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 01-Dec-2015 11:53 | 4.7M | ||
cloudera-manager-daemons-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 01-Dec-2015 11:53 | 509M | ||
cloudera-manager-server-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 01-Dec-2015 11:53 | 8.2K | ||
cloudera-manager-server-db-2-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 01-Dec-2015 11:53 | 9.9K | ||
enterprise-debuginfo-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 01-Dec-2015 11:53 | 957K | ||
jdk-6u31-linux-amd64.rpm | 01-Dec-2015 11:53 | 68M | ||
oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm | 01-Dec-2015 11:53 | 135M | ||
repodata/ | 01-Dec-2015 11:53 | - | ||
Index of /cdh5.5.0
Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
CDH-5.5.0-1.cdh5.5.0.p0.8-el6.parcel | 01-Dec-2015 11:52 | 1.4G | ||
manifest.json | 01-Dec-2015 11:52 | 49K | ||
如果访问不了,检查一下目录/var/www/html的权限和http服务器的状态
5.安装JDK
[root@ip-172-31-30-175 cloudera]# yum install oracle-j2sdk1.7
6.安装cm server
[root@ip-172-31-30-175 cloudera]# yum install cloudera-manager-daemons cloudera-manager-server Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile * base: centos.sonn.com * extras: mirror.web-ster.com * updates: mirror.supremebytes.com Resolving Dependencies --> Running transaction check ---> Package cloudera-manager-daemons.x86_64 0:5.5.0-1.cm550.p0.61.el6 will be installed ---> Package cloudera-manager-server.x86_64 0:5.5.0-1.cm550.p0.61.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================== Installing: cloudera-manager-daemons x86_64 5.5.0-1.cm550.p0.61.el6 bootstrap 509 M cloudera-manager-server x86_64 5.5.0-1.cm550.p0.61.el6 bootstrap 8.2 k Transaction Summary =============================================================================================================================================================================================================== Install 2 Package(s) Total download size: 509 M Installed size: 701 M Is this ok [y/N]: y Downloading Packages: (1/2): cloudera-manager-daemons-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 509 MB 00:03 (2/2): cloudera-manager-server-5.5.0-1.cm550.p0.61.el6.x86_64.rpm | 8.2 kB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 137 MB/s | 509 MB 00:03 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : cloudera-manager-daemons-5.5.0-1.cm550.p0.61.el6.x86_64 1/2 Installing : cloudera-manager-server-5.5.0-1.cm550.p0.61.el6.x86_64 2/2 Verifying : cloudera-manager-server-5.5.0-1.cm550.p0.61.el6.x86_64 1/2 Verifying : cloudera-manager-daemons-5.5.0-1.cm550.p0.61.el6.x86_64 2/2 Installed: cloudera-manager-daemons.x86_64 0:5.5.0-1.cm550.p0.61.el6 cloudera-manager-server.x86_64 0:5.5.0-1.cm550.p0.61.el6 Complete! [root@ip-172-31-30-175 cloudera]#
启动CM:
[root@ip-172-31-30-175 cloudera]# service cloudera-scm-server start Starting cloudera-scm-server: [FAILED] [root@ip-172-31-30-175 cloudera]# vi /var/log/cloudera-scm-server/ cloudera-scm-server.log cloudera-scm-server.out db.log [root@ip-172-31-30-175 cloudera]# vi /var/log/cloudera-scm-server/cloudera-scm-server.log [root@ip-172-31-30-175 cloudera]#
发现启动出差,日志中信息如下:
2015-12-01 12:13:50,858 ERROR main:com.cloudera.server.cmf.Main: Server failed. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cloudera.server.cmf.TrialState': Cannot resolve reference to bean 'entityManagerFactoryBean' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean': FactoryBean threw exception on object creation; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: cmf.server] Unable to build EntityManagerFactory at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at com.cloudera.server.cmf.Main.bootstrapSpringContext(Main.java:364) at com.cloudera.server.cmf.Main.<init>(Main.java:224) at com.cloudera.server.cmf.Main.main(Main.java:198) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean': FactoryBean threw exception on object creation; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: cmf.server] Unable to build EntityManagerFactory at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1440) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:247) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 17 more Caused by: javax.persistence.PersistenceException: [PersistenceUnit: cmf.server] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at com.cloudera.enterprise.CommonMain.setupHibernate(CommonMain.java:171) at com.cloudera.server.cmf.bootstrap.EntityManagerFactoryBean.getObject(EntityManagerFactoryBean.java:107) at com.cloudera.server.cmf.bootstrap.EntityManagerFactoryBean.getObject(EntityManagerFactoryBean.java:60) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ... 22 more Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: HHH010003: JDBC Driver class not found: com.mysql.jdbc.Driver at org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:142) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
原因在于jdbc driver找不到。检查jdbc driver
[root@ip-172-31-30-175 cloudera]# cd /usr/share/java [root@ip-172-31-30-175 java]# ll total 11772 drwxr-xr-x 2 root root 4096 Oct 14 2014 gcj-endorsed -rw-r--r-- 1 root root 84746 Aug 22 2010 jline-0.9.94.jar lrwxrwxrwx 1 root root 16 Feb 21 2014 jline.jar -> jline-0.9.94.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 js-1.7.jar -> rhino-1.7.jar lrwxrwxrwx 1 root root 10 Feb 21 2014 js.jar -> js-1.7.jar -rw-r--r-- 1 root root 10143547 Oct 14 2014 libgcj-4.4.4.jar lrwxrwxrwx 1 root root 16 Dec 16 2014 libgcj-4.4.7.jar -> libgcj-4.4.4.jar -rw-r--r-- 1 root root 985603 Dec 1 09:09 mysql-connector-java-5.1.37-bin.jar lrwxrwxrwx 1 root root 31 Dec 1 09:10 mysql-connector-java.jar -> mysql-connector-java-5.1.37.jar -rw-r--r-- 1 root root 807405 Aug 21 2010 rhino-1.7.jar -rw-r--r-- 1 root root 18260 Aug 21 2010 rhino-examples-1.7.jar lrwxrwxrwx 1 root root 22 Feb 21 2014 rhino-examples.jar -> rhino-examples-1.7.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 rhino.jar -> rhino-1.7.jar
发现是由于书写错误mysql-connector-java.jar -> mysql-connector-java-5.1.37.jar,应该是mysql-connector-java-5.1.37-bin.jar
更正错误并重启CM服务:
[root@ip-172-31-30-175 java]# unlink mysql-connector-java.jar [root@ip-172-31-30-175 java]# ll total 11772 drwxr-xr-x 2 root root 4096 Oct 14 2014 gcj-endorsed -rw-r--r-- 1 root root 84746 Aug 22 2010 jline-0.9.94.jar lrwxrwxrwx 1 root root 16 Feb 21 2014 jline.jar -> jline-0.9.94.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 js-1.7.jar -> rhino-1.7.jar lrwxrwxrwx 1 root root 10 Feb 21 2014 js.jar -> js-1.7.jar -rw-r--r-- 1 root root 10143547 Oct 14 2014 libgcj-4.4.4.jar lrwxrwxrwx 1 root root 16 Dec 16 2014 libgcj-4.4.7.jar -> libgcj-4.4.4.jar -rw-r--r-- 1 root root 985603 Dec 1 09:09 mysql-connector-java-5.1.37-bin.jar lrwxrwxrwx 1 root root 35 Dec 1 12:41 mysql-connector-java.jar -> mysql-connector-java-5.1.37-bin.jar -rw-r--r-- 1 root root 807405 Aug 21 2010 rhino-1.7.jar -rw-r--r-- 1 root root 18260 Aug 21 2010 rhino-examples-1.7.jar lrwxrwxrwx 1 root root 22 Feb 21 2014 rhino-examples.jar -> rhino-examples-1.7.jar lrwxrwxrwx 1 root root 13 Feb 21 2014 rhino.jar -> rhino-1.7.jar [root@ip-172-31-30-175 java]# service cloudera-scm-server start Starting cloudera-scm-server: [ OK ]