4. 安装数据库MySql(Version 5.1 /5.5可以工作的很好,注:这里是mysql和Management Server安装在同一台机器上的情况)
4.1 yum install mysql-server
[root@coms-cluster etc]# yum install mysql-server
Setting up Install Process
Package mysql-server-5.1.61-4.el6.x86_64 already installed and latest version
Nothing to do
[root@coms-cluster etc]#
4.2 编辑MySQL的配置文件(/etc/my.cnf),在[mysqld]区域下面插入下面的内容。
[root@coms-cluster etc]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
innodb_rollback_on_timeout=1 # 红色标注的地方是需要插入的内容
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format='ROW'
socket=/var/lib/mysql/mysql.sock
user=mysql
# 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
注:max_connections参数应当设置为350*你配置的Management Server的数目
4.3 手动开启mysql:service mysqld start
[root@coms-cluster etc]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h cloudstackms.houqd.pub password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@coms-cluster etc]#
4.4 在RHEL和CentOS上mysql默认没有设置root的密码,强烈建议为了确保安全设置一个密码。在Ununtu上不同执行,因为在安装的时候会询问你设置root的密码。
[root@coms-cluster etc]# 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): #提示输入当前密码,由于是空直接回车,设置完新密码后,其它的询问均为Yes
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
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] 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? [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!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@coms-cluster etc]#
4.5 配置数据库,在数据库上创建一个名为“cloud”的用户
[root@coms-cluster etc]# cloud-setup-databases cloud:dell_456@localhost --deploy-as=root:dell_456
Mysql user name:cloud [ OK ]
Mysql user password:dell_456 [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port:3306 [ OK ]
Mysql root user name:root [ OK ]
Mysql root user password:dell_456 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 100.1.1.1, will use as cluster management server node IP[ OK ]
Preparing /etc/cloud/management/db.properties [ OK ]
Applying /usr/share/cloud/setup/create-database.sql [ OK ]
Applying /usr/share/cloud/setup/create-schema.sql [ OK ]
Applying /usr/share/cloud/setup/create-database-premium.sql [ OK ]
Applying /usr/share/cloud/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloud/setup/server-setup.sql [ OK ]
Applying /usr/share/cloud/setup/templates.sql [ OK ]
Applying /usr/share/cloud/setup/create-index-fk.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_db.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_schema.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_multipart.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_index.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_multipart_alter.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_bucketpolicy.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_policy_alter.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_offering.sql [ OK ]
Applying /usr/share/cloud/setup/bridge/db/cloudbridge_offering_alter.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, you can check your database configuration in /etc/cloud/management/db.properties
[root@coms-cluster etc]#
可能发生的错误:
[root@cloudstack ~]# cloud-setup-databases cloud:dell_456@localhost --deploy-as=root:dell_456
Mysql user name:cloud [ OK ]
Mysql user password:dell_456 [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port:3306 [ OK ]
Mysql root user name:root [ OK ]
Mysql root user password:dell_456 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 100.1.1.100, will use as cluster management server node IP[ OK ]
Preparing /etc/cloud/management/db.properties [ OK ]
Applying /usr/share/cloud/setup/create-database.sql
We apologize for below error:
***************************************************************
Encountering an error when executing mysql script
----------------------------------------------------------------------
table:
/usr/share/cloud/setup/create-database.sql
Error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) # 这说明你的mysql还没有启动,需要手动启动
Sql parameters:
{'passwd': 'dell_456', 'host': 'localhost', 'user': 'root', 'port': 3306}
----------------------------------------------------------------------
***************************************************************
Please run:
cloud-setup-database -h
for full help
[root@cloudstack ~]#
4.6 配置cloud-management(注:这一步一定不要忘记执行,开始的时候我忘记执行了,结果在web界面输入默认的admin和password提示无效的用户名或密码,虽然现在在数据库中是正确的也不行,还是在群里问的。)
[root@cloudstack management]# cloud-setup-management
Starting to configure CloudStack Management Server:
Configure sudoers ... [OK]
Configure Firewall ... [OK]
Configure CloudStack Management Server ...[OK]
CloudStack Management Server setup is Done!
[root@cloudstack management]#