隨着公司硬件開發資源的不足,構建一個雲平臺彷佛重要了起來。固然,也不是這個平臺搭建的主力,出於工做的需求和我的興趣愛好,接下來就來學習一下OpenNebula相關的東西,這是第一節課,先來講一下OpenNebula的安裝,實現的目標是非快速安裝,把MySQL做爲OpenNebula的存儲資源庫前端
查看CPU是否支持KVM虛擬化
grep vmx /proc/cpuinfo
安裝KVM
sudo apt-get install kvm qemu-kvm ubuntu-vm-builder bridge-utils libvirt-bin virtinst
啓動KVM內核支持 【注】在服務器安裝界面啓用虛擬化支持,能夠忽略此步驟
modprobe kvm
modprobe kvm_intel
modprobe kvm_amd
將root加入kvm羣組中
adduser root kvm
驗證KVM是否成功
virsh -c qemu:///system list
lsmod | grep kvmmysql
上面的是quick install模式下的安裝,OpenNebula採用了默認的資料庫,官方的說明以下sql
2.2.5 Step 5. Enabling MySQL/MariaDB (Optional) You can skip this step if you just want to deploy OpenNebula as quickly as possible. However if you are deploying this for production or in a more serious environment, make sure you read the MySQL Setup section. Note that it is possible to switch from SQLite to MySQL, but since it’s more cumbersome to migrate databases, we suggest that if in doubt, use MySQL from the start.
這裏咱們能夠利用已經存在的任何一個OpenNebula服務能夠訪問的MySQL Server主機,也能夠在localhost安裝一個MySQL Server,爲了避免干擾其餘系統,我選擇在本地安裝一個新的MySQL Server,輸入mysql命令查看系統是否已經安裝了mysql服務數據庫
由上圖能夠看到系統中並不存在MySQL服務器,咱們須要首先在Ubuntu 16.04上安裝MySQL數據庫
ubuntu
sudo apt-get install mysql-server mysql-client瀏覽器
安裝過程當中會出現一個爲MySQL數據庫輸入ROOT密碼的界面,請牢記這個密碼服務器
看MySQL是否安裝成功(因爲在安裝過程當中,設置了密碼,因此不能匿名mysql登陸,須要加上mysql -u root -p)以下圖,安裝成功ide
使用MySQL的root用戶登陸後,執行下面的命令,以下圖所示學習
mysql> GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'oneadmin';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
Query OK, 0 rows affected (0.00 sec)ui
注意!注意!注意!這裏不須要建立opennebula數據庫,由於接下來咱們安裝OpenNebula的時候會設置相關信息,OpenNebula服務會自動的
幫助咱們建立一個咱們配置信息中的數據庫,只要給予oneadmin足夠的權限便可
下載opennebula repo源
wget -q -O- http://downloads.opennebula.org/repo/Debian/repo.key | apt-key add -
將下載的源存放到apt的source清單中
echo "deb http://downloads.opennebula.org/repo/5.2/Ubuntu/16.04 stable opennebula" > /etc/apt/sources.list.d/opennebula.list
更新系統和下載最新的opennebula軟件包
apt-get update
安裝opennebula Front-end須要的軟件包
apt-get install opennebula opennebula-sunstone opennebula-gate opennebula-flow
切換到oneadmin而且給oneadmin指定密碼(oneadmin是安裝opennebula相關服務的時候建立的一個用戶)
su - oneadmin
echo "oneadmin:youpassword" > ~/.one/one_auth
☆☆☆ 給OpenNebula配置MySQL內容存儲庫
找到/etc/one/oned.conf配置文件,修改內容以下,註釋掉默認的SQLite,而後保存這個修改
這個地方是十分重要的地方,若是這個操做沒有作千萬不要啓動OpenNebula服務,不然系統會默認OpenNebula的資料庫爲SQLite,會給之後形成麻煩,官網資料也給出了說明
【關於內容庫的說明】
2.3 MySQL Setup The MySQL/MariaDB back-end is an alternative to the default SQLite back-end. In this guide and in the rest of Open- Nebula’s documentation and configuration files we will refer to this database as the MySQL, however OpenNebula you can use either MySQL or MariaDB. The two back-ends cannot coexist (SQLite and MySQL), and you will have to decide which one is going to be used while planning your OpenNebula installation. Note: If you are planning to install OpenNebula with MySQL back-end, please follow this guide prior to start OpenNebula the first time to avoid problems with oneadmin and serveradmin credentials.
【關於MySQL配置時間點的說明】
確保上面的操做都完成後,就能夠啓動opennebula和sunstone服務
systemctl start opennebula
systemctl start opennebula-sunstone
或者使用Linux的 service 命令
service opennebula start
service opennebula-sunstone start
啓動的時候須要輸入OS的密碼進行驗證(若是不須要認證則直接跳過),在這個時候就會針對各類服務進行受權,以下圖所示,每次啓動一個服務後,輸入密碼
提示AUTHENTICATION COMPLETE,則說明認證完成啓動OK
查看one服務是否啓動成功
肯定啓動成功後,咱們再次用root用戶登陸mysql,能夠發現這個時候OpenNebula的數據庫已經自動建立好了
接下來咱們訪問OpenNebula前端服務UI,在瀏覽器輸入http://<fontend_address>:9869便可訪問OpenNebula的登陸頁面
使用你上面設置的oneadmin用戶的用戶名:oneadmin 密碼:youpassword進行登陸,登陸後便可看到OpenNebula的主管理界面
看着不舒服的話,能夠在設置裏面設置一下語言爲簡體中文,設置後會顯示中文的界面,以下圖所示
到這裏爲止,OpenNebula在Ubuntu16.04上面的基於MySQL內容庫的安裝已經所有完成了,這一天也該結束了。