完整部署CentOS7.2+OpenStack+kvm 雲平臺環境(5)--問題解決

散盡浮華發表於2016-08-26

 

一、
[root@openstack-server ~]# nova list
ERROR (CommandError): You must provide a username or user id via --os-username, --os-user-id, env[OS_USERNAME] or env[OS_USER_ID]
解決辦法:
source一下環境變數來獲取 token
[root@openstack-server src]# source admin-openrc.sh
[root@openstack-server src]# nova list
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| 056c37a4-3e94-4280-96dd-5bc003469647 | kvmserver-01 | ACTIVE | - | Running | flat=192.168.1.121 |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+

二、
在進行keystone認證的時候,出現下面的報錯:
Maximum lock attempts on _lockusertokens-0b75ff3ce97a40caa6bf6753c962c82b occurred. (Disable debug mode to suppress these details.) (HTTP 500) (Request-ID: req-bb1c465e-33bc-412a-8ac2-c0d0a7e168ad)
或者
An unexpected error prevented the server from fulfilling your request. (HTTP 500) (Request-ID: req-bb1c465e-33bc-412a-8ac2-c0d0a7e168ad)
問題產生的可能原因及解決辦法:
1)admin_token使用者環境變數錯誤引起的。
解決辦法:
[root@linux-node1 ~]# export OS_TOKEN=35d6e6f377a889571bcf
[root@linux-node1 ~]# export OS_URL=http://192.168.1.17:35357/v3
[root@linux-node1 ~]# export OS_IDENTITY_API_VERSION=3
2)keystone資料同步失敗,沒有獲取到正確的token值引起的。
解決辦法:
刪除mysql資料庫中的keystone庫,重新建立keystone庫;
重新生成一個token,在keystone.conf中重新指定admin_token對應的新的token指;
然後初始化keystone資料,重啟memcaced服務,重新進行keystone的認證;
3)獲取的token無效引起的。
解決辦法:修改keystone.conf檔案中的[token]區域。
之前的配置,將token存放在memcache快取中
[token]
provider = uuid                 //或者是provider = keystone.token.providers.uuid.Provider
driver = memcache            //或者是driver = keystone.token.persistence.backends.memcache.Token
修改後的配置,將token存放在sql資料庫中
[token]
provider = uuid
driver = keystone.token.persistence.backends.sql.Token
----------------------------------------------------------------------------------------------------------------------------------------------
說明下:
keystone預設使用SQL資料庫儲存token,token預設有效期為1天(24h)。
Openstack中每個元件執行的每次命令(請求)都需要token來驗證,每次訪問都會建立token,增長速度非常快,token表資料也會越來越多。
隨著時間的推移,無效的記錄越來越多,企業私有云幾天的量就可以幾萬條、幾十萬條。這麼多無效的token導致針對token表的SQL語句變慢,效能也會變差!
這就需要手動寫個定時指令碼來清理token表。
但是更好的方法當然是將token存放在memcache快取中,利用memcached特性,自動刪除不使用的快取:
[memcache]
servers = localhost:11211
[token]
provider = keystone.token.providers.uuid.Provider
driver = keystone.token.persistence.backends.memcache.Token

預設的配置是:
[token]
provider = keystone.token.providers.uuid.Provider
driver = keystone.token.persistence.backends.sql.Token
--------------------------------------------------------------------------------------------------------------------------------------------

三、
No handlers could be found for logger "oslo_config.cfg"
原因:日誌檔案的配置項錯誤
解決辦法:
在/etc/keystone/keystone.conf、/etc/nova/nova.conf配置檔案裡修改logdir為:
log_dir=/var/log/keystone
log_dir=/var/log/nova

四、
之前在openstack裡建立的虛擬機器,後面刪除了。但是再建立虛擬機器並設定和之前刪除的虛擬機器一樣的ip的時候,就報錯說這個ip已經被佔用了!
但是之前建立的虛擬機器已經刪除了,這是為什麼?
這是因為虛擬機器雖然刪除了,但是所刪除虛擬機器在neutron組網內的ip還沒有被真正釋放出來。
需要登陸openstack的web介面,到“網路”部分裡面進行刪除:

 

 

 

 

 

五、
在上傳映象或檢視映象的時候,報錯:
[root@linux-node1 ~]# glance image-list
500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

測試登陸資料庫,發現登陸失敗!
[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p
Enter password:
ERROR 1040 (08004): Too many connections

解決辦法,這也是centos7下修改mysql連線數的做法:
1)臨時修改
MariaDB [(none)]> set GLOBAL max_connections=1000;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)

2)永久修改:
配置/etc/my.cnf
[mysqld]新新增一行如下引數:
max_connections=1000
重啟mariadb服務,再次檢視mariadb資料庫最大連線數,可以看到最大連線數是214,並非我們設定的1000。
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
這是由於mariadb有預設開啟檔案數限制。可以通過配置/usr/lib/systemd/system/mariadb.service來調大開啟檔案數目。

配置/usr/lib/systemd/system/mariadb.service
[Service]新新增兩行如下引數:
LimitNOFILE=10000
LimitNPROC=10000

重新載入系統服務,並重啟mariadb服務
systemctl --system daemon-reload
systemctl restart mariadb.service

再次檢視mariadb資料庫最大連線數,可以看到最大連線數已經是1000
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+

六、
openstack建立虛擬機器後,vnc進入vm後發現:
ifconfig命令沒有看到eth0資訊
[root@localhost ~]# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

重啟網路卡又報下面錯誤。
[root@localhost ~]# service network restart
Shutting down loopback insterface: [ OK ]
Bringing up loopback insterface:      [ OK ]
Bringing up interface eth0: Device eth0 does not seem to be present,delaying initialization. [FAILED]

解決辦法:
首先,開啟/etc/udev/rules.d/70-persistent-net.rules內容如下面例子所示:
[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:f0:f9:1c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="fa:16:3e:e9:ad:89", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

記錄下,eth1網路卡的mac地址fa:16:3e:e9:ad:89
接下來,開啟/etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="52:54:00:F0:F9:1C"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="af2a1e56-a502-42e9-9359-5c7dd6b1e1e9"

將ifcfg-eth0檔案下的DEVICE裝置名稱改為“eth1”
將mac地址即HWADDR改為上面記錄的eth1的地址:fa:16:3e:e9:ad:89
即修改後:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth1"
BOOTPROTO="dhcp"
HWADDR="fa:16:3e:e9:ad:89"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="af2a1e56-a502-42e9-9359-5c7dd6b1e1e9"

最後,重啟網路卡
[root@localhost ~]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth1... done.
[ OK ]

然後檢視,發現ifconfig後有ip資訊了!
[root@localhost ~]# ifconfig
eth1 Link encap:Ethernet HWaddr FA:16:3E:E9:AD:89
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::f816:3eff:fee9:ad89/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:678 errors:0 dropped:0 overruns:0 frame:0
TX packets:183 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:78238 (76.4 KiB) TX bytes:27488 (26.8 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

七、
openstack上建立vm例項後,狀態為ERROR問題解決
解決方法參考:http://www.cnblogs.com/kevingrace/p/6015732.html

相關文章