Linux下以特定用户运行命令
方法汇总:
1、su
2、sudo
3、runuser
比较常用的方式:su
示例:su - root -s /bin/sh -c "/usr/local/nginx/sbin/nginx",解释:以root身份,用/bin/sh运行命令。
[root@controller /]# su - nova -s /bin/locale
Last login: Wed Oct 14 09:35:01 CST 2020 on pts/1
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
[root@controller /]#
===========================================================
openstack 创建云主机No valid host was found. There are not enough hosts available.
1.openstack创建云主机时界面报错:No valid host was found. There are not enough hosts available.
2.查看nova下的调度信息出现(nova-scheduler.log)
2016-12-08 09:40:57.394 1269 WARNING nova.scheduler.host_manager [req-c721e8e3-53b3-446a-a71c-5a185f1bc3a4 7858bcc09cd14e8fbbff141fc1e7181f c5daa5b11e9448a7a494901b8f25f2ae - - -] Host mitaka has more disk space than database expected (25 GB > 17 GB)
2016-12-08 09:40:57.394 1269 INFO nova.filters [req-c721e8e3-53b3-446a-a71c-5a185f1bc3a4 7858bcc09cd14e8fbbff141fc1e7181f c5daa5b11e9448a7a494901b8f25f2ae - - -] Filter DiskFilter returned 0 hosts
2016-12-08 09:40:57.395 1269 INFO nova.filters [req-c721e8e3-53b3-446a-a71c-5a185f1bc3a4 7858bcc09cd14e8fbbff141fc1e7181f c5daa5b11e9448a7a494901b8f25f2ae - - -] Filtering removed all hosts for the request with instance ID 'a6b1e821-ee1d-4a01-b938-686dcad02c4e'. Filter results: ['RetryFilter: (start: 1, end: 1)', 'AvailabilityZoneFilter: (start: 1, end: 1)', 'RamFilter: (start: 1, end: 1)', 'DiskFilter: (start: 1, end: 0)']
3.解决方案:
修改nova的 配置文件,使得调度过滤器能够通过设置
#scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter
添加本句设置:scheduler_default_filters=AllHostsFilter
重启服务可以创建新实例了
===========================================================
===========================================================
rabbitmq默认账号密码:guest guest
dashboard默认账号密码 : default admin admin
https://www.cnblogs.com/elvi/p/7613861.html
https://www.cnblogs.com/elvi/p/7613861.html
1,hostname没有切换过来localhost
Error: unable to connect to node rabbit@localhost: nodedown
重启rabbitmq服务
2,Login was refused using authentication mechanism AMQPLAIN.
rabbitmqctl list_users
查看有没有opensatck用户,否则重建
3,安装文档中缺少restart L3服务
4,ml2.conf配置文件增加local
5,http的log对应dashboard的报错信息;
6,driver.py更新,重启nova-compute服务
7,跟踪虚机创建流程:tail -f var/log/nova/nova-compute.log
8,增加数据库mysql连接数An unexpected error prevented the server from fulfilling your request. (HTTP 500)
... [mysqld]
max_connections=1000 wait_timeout=5 ...
9,系统环境是中文编码
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
10,dashboard创建虚机的流程:
镜像---实例类型----网络----实例
11,修改dashboard配置文件 utf-8转码
[root@controller /]# ls etc/openstack-dashboard/local_settings
etc/openstack-dashboard/local_settings
[root@controller /]#
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
重启服务:
systemctl restart httpd
systemctl restart memcached.service
12,写个python来转码
s=[b'\xe5\xb9\xb3\xe9\x9d\xa2\xe4\xbe\x9b\xe5\xba\x94\xe5\x95\x86\xe7\xbd\x91\xe7\xbb\x9c\xe7\x9a\x84\xe7\x89\xa9\xe7\x90\x86\xe7\xbd\x91\xe7\xbb\x9c']
[root@controller /]# cat jiexi.py
#!/bin/python
s=[b'\xe4\xb8\x8d\xe6\x94\xaf\xe6\x8c\x81\xe7\x9a\x84\xe7\xbd\x91\xe7\xbb\x9c\xe7\xb1\xbb\xe5\x9e\x8b\xe5\x80\xbc']
a=s[0]
print(a.decode('utf-8'))
[root@controller /]# ./jiexi.py
不支持的网络类型值
[root@controller /]#
13,python系统环境转码
2)第二种:我们在/usr/lib/python2.7/site-packages/目录下添加一个sitecustomize.py文件,内容如下:
#!/usr/bin/python
import sys
sys.setdefaultencoding('utf-8')
阅读(4022) | 评论(0) | 转发(0) |