1、問題
在docker上跑Selenium+ChromeDriver+Chrome無頭模式報錯:javascript
UnknownError: unknown error: session deleted because of page crash from tab crashed (Session info: chrome=43.0.2357.81) (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Linux 3.13.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 53 milliseconds Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' System info: host: 'zelenium', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.7.0_80' Session ID: b12eb3c43351dad58746798c40078ef9 Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/tmp/.com.google.Chrome.11yHIh}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=43.0.2357.81, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
2、分析
/dev/shm過小了,要擴容css
3、解決方案
3.1 若是環境是Kubernetes(k8s)請參考:Kubernetes(k8s) docker 修改 /dev/shm大小
3.2 如何修改/dev/shm大小?
/dev/shm在/etc/fstab中掛載,對應tmpfs,實際使用的是內存的空間。默認狀況下,/dev/shm爲物理內存大小的一半。於是,調整/dev/shm大小有兩種方式:html
-
加大Linux的物理內存java
-
在/etc/fstab中明確指定/dev/shm的掛載sizes大小參數web
[root@centos-fuwenchao mntsda3]# df -h /dev/shm Filesystem Size Used Avail Use% Mounted on tmpfs 935M 228K 935M 1% /dev/shm
[root@centos-fuwenchao mntsda3]# vi /etc/fstab 2 # 3 # /etc/fstab 4 # Created by anaconda on Fri Nov 1 21:18:42 2013 5 # 6 # Accessible filesystems, by reference, are maintained under '/dev/disk' 7 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 8 # 9 UUID=8e319772-a274-4031-a53f-1178b3ab4de6 / ext4 defaults 1 1 10 UUID=ad4de750-9575-4040-a403-08c0642f0f2c swap swap defaults 0 0 11 tmpfs /dev/shm tmpfs defaults 0 0 12 devpts /dev/pts devpts gid=5,mode=620 0 0 13 sysfs /sys sysfs defaults 0 0 14 proc /proc proc defaults 0 0
[root@centos-fuwenchao mntsda3]# cp /etc/fstab /etc/fstab.20140218 [root@centos-fuwenchao mntsda3]# vi /etc/fstab 1 2 # 3 # /etc/fstab 4 # Created by anaconda on Fri Nov 1 21:18:42 2013 5 # 6 # Accessible filesystems, by reference, are maintained under '/dev/disk' 7 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 8 # 9 UUID=8e319772-a274-4031-a53f-1178b3ab4de6 / ext4 defaults 1 1 10 UUID=ad4de750-9575-4040-a403-08c0642f0f2c swap swap defaults 0 0 11 tmpfs /dev/shm tmpfs defaults,size=1024M 0 0 12 devpts /dev/pts devpts gid=5,mode=620 0 0 13 sysfs /sys sysfs defaults 0 0 14 proc /proc proc defaults 0 0
從新掛載chrome
[root@centos-fuwenchao mntsda3]# mount -o remount /dev/shm [root@centos-fuwenchao mntsda3]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 9.7G 4.6G 4.7G 50% / tmpfs 1.0G 228K 1.0G 1% /dev/shm /dev/sr0 4.1G 4.1G 0 100% /media/CentOS_6.4_Final /dev/sda3 38G 176M 36G 1% /mnt/mntsda3
參考:docker