我正在使用 pandas 库将 mysql 数据库的内容写入 csv 文件。
但是当我写 CSV 时,每隔一行都是空白的:
此外,它正在向左打印我不想要的行号。第一列应为“帐号”。
这是我的代码:
destination = 'output_file.txt'
read_sql = """ SELECT LinkedAccountId,ProductName,ItemDescription,ResourceId,UnBlendedCost,UnBlendedRate,Name,Owner,Engagement FROM billing_info ;"""
fieldnames = ['Account Number', 'Product Name', 'Item Description', 'Resource ID', 'UnBlended Cost', 'UnBlended Rate', 'Name', 'Owner', 'Engagement']
# Open the file
f = open(destination, 'w')
cursor.execute(read_sql)
while True:
# Read the data
df = pd.DataFrame(cursor.fetchmany(1000))
# We are done if there are no data
if len(df) == 0:
break
# Let's write to the file
else:
df.to_csv(f, …Run Code Online (Sandbox Code Playgroud) 我们在我们公司使用自定义 yum 存储库。有些事情导致他们无法执行yum makecache命令。
我在CentOS Linux release 7.7.1908 (Core)。
这是我们运行时得到的错误yum makecache:
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this
Run Code Online (Sandbox Code Playgroud)
回购看起来像这样,我需要同时使用它们。
埃佩尔回购:
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch …Run Code Online (Sandbox Code Playgroud) 我正在尝试在munin设置一些新主机进行监控.由于某种原因,它没有发生!
这是我到目前为止所尝试的内容.
在已经监控其他几台主机的munin服务器上,我在/etc/munin/munin.conf中添加了我想要的主机
[db1]
address 10.10.10.25 # <- obscured the real IP address
use_node_name yes
Run Code Online (Sandbox Code Playgroud)
在db1主机上,我在/etc/munin/munin-node.conf中设置了这个
host_name db1.example.com
allow ^127\.0\.0\.1$
allow ^10\.10\.10\.26$
allow ^::1$
port 4949
Run Code Online (Sandbox Code Playgroud)
我确保在两台机器上重启服务.
从监控主机我可以telnet到我要在munin端口上监控的新服务器:
[root@monitor3:~] #telnet db1.example.com 4949
Trying 10.10.10.26...
Connected to db1.example.com.
Escape character is '^]'.
# munin node at db1.example.com
Run Code Online (Sandbox Code Playgroud)
等几分钟......什么都没有!新服务器不会出现在munin监控主机上的munin仪表板中.
在db1主机(我正在尝试监控的那个)上的/var/log/munin/munin-update.log日志中,我发现:
2015/11/30 03:20:02 [INFO] starting work in 14199 for db1/10.10.10.26:4949.
2015/11/30 03:20:02 [FATAL] Socket read from db1 failed. Terminating process. at /usr/share/perl5/vendor_perl/Munin/Master/UpdateWorker.pm line 254.
2015/11/30 03:20:02 [ERROR] Munin::Master::UpdateWorker<db1;db1> died with '[FATAL] Socket read …Run Code Online (Sandbox Code Playgroud) 我在我的网站上运行apache 2.4.6.我一直在我的apache错误日志中反复重复这条消息.
[Tue Nov 10 01:42:40.659710 2015] [authz_core:debug] [pid 10727] mod_authz_core.c(809): [client 107.170.139.115:58678] AH01626: authorization result of Require all granted: granted
Run Code Online (Sandbox Code Playgroud)
以下是VHOST中列出此站点的根目录的方式:
DocumentRoot /var/www/jf-beta
<Directory /var/www/jf-beta>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
究竟Apache在这里抱怨什么?那个目录列表对我来说似乎很合理!我如何让它停止抱怨这个错误?
如何检查我正在运行的 boto3 版本?
我尝试进入 REPL 并运行以下命令:
>>> import boto3
>>> boto3.Version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'boto3' has no attribute 'Version'
Run Code Online (Sandbox Code Playgroud) 我尝试使用部分服务器名称在 kibana 中搜索主机名:
B-wit-a2pgw-*
Run Code Online (Sandbox Code Playgroud)
我也试过:
hostname: B-wit-a2pgw-*
Run Code Online (Sandbox Code Playgroud)
和:
instance: B-wit-a2pgw-*
Run Code Online (Sandbox Code Playgroud)
我把时间安排到今天。但是 kibana 控制台中什么也没有出现。我究竟做错了什么?
我正在尝试使用cassandra 2.0.7启动一个新节点.两个节点都在数字海洋.种子节点已启动并正在运行,我可以从我尝试启动的节点远程登录到该主机上的端口7000.
[root@cassandra02 apache-cassandra-2.0.7]# telnet 10.10.1.94 7000
Trying 10.10.1.94...
Connected to 10.10.1.94.
Escape character is '^]'.
Run Code Online (Sandbox Code Playgroud)
但是当我在新节点上启动cassandra时,我看到以下异常:
INFO 00:01:34,744 Handshaking version with /10.10.1.94
ERROR 00:02:05,733 Exception encountered during startup
java.lang.RuntimeException: Unable to gossip with any seeds
at org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1193)
at org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:447)
at org.apache.cassandra.service.StorageService.prepareToJoin(StorageService.java:656)
at org.apache.cassandra.service.StorageService.initServer(StorageService.java:612)
at org.apache.cassandra.service.StorageService.initServer(StorageService.java:505)
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:362)
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:480)
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:569)
java.lang.RuntimeException: Unable to gossip with any seeds
at org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1193)
at org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:447)
at org.apache.cassandra.service.StorageService.prepareToJoin(StorageService.java:656)
at org.apache.cassandra.service.StorageService.initServer(StorageService.java:612)
at org.apache.cassandra.service.StorageService.initServer(StorageService.java:505)
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:362)
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:480)
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:569)
Exception encountered during startup: Unable …Run Code Online (Sandbox Code Playgroud) cassandra集群中的一个节点已经死亡.
我一直在使用cassandra 2.0.7.
当我执行nodetool状态时,这就是我所看到的(实际地址已被假10网取代)
[root@beta-new:/opt] #nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 10.10.1.94 171.02 KB 256 49.4% fd2f76ae-8dcf-4e93-a37f-bf1e9088696e rack1
DN 10.10.1.98 ? 256 50.6% f2a48fc7-a362-43f5-9061-4bb3739fdeaf rack1
Run Code Online (Sandbox Code Playgroud)
我尝试通过执行nodetool ring命令获取down节点的令牌ID,为IP打算并执行head -1以获取初始节点.
[root@beta-new:/opt] #nodetool ring | grep 10.10.1.98 | head -1
10.10.1.98 rack1 Down Normal ? 50.59% -9042969066862165996
Run Code Online (Sandbox Code Playgroud)
然后我开始关注如何替换节点的文档:
[ http://www.datastax.com/documentation/cassandra/2.0/cassandra/operations/ops_replace_node_t.html?scroll=task_ds_aks_15q_gk] [1 ]
所以我在新节点上安装了cassandra但没有启动它.
设置以下选项:
cluster_name: 'Jokefire Cluster'
seed_provider:
- seeds: "10.10.1.94"
listen_address: 10.10.1.94
endpoint_snitch: SimpleSnitch
Run Code Online (Sandbox Code Playgroud)
并将新安装的初始标记设置为我要在cssandra.yaml中替换的节点的标记-1:
initial_token: -9042969066862165995
Run Code Online (Sandbox Code Playgroud)
确认之后还没有数据:/ var/lib/cassandra
我启动了数据库:
[root@web2:/etc/alternatives/cassandrahome] …Run Code Online (Sandbox Code Playgroud) 我有一个 python 脚本,它在 AWS 中创建一些访问密钥并将它们存储在机密管理器中。
但是,当我存储密钥时,我收到一条错误消息:
The secret value can't be converted to key name and value pairs
Run Code Online (Sandbox Code Playgroud)
秘密在秘密管理器中像这样存储(混淆秘密密钥):
[{'Access Key': 'AKIA5AODVC64THTZNML7'}, {'Secret Key': 'SecretSecretsecretSecretSecretSecretSecr'}]
Run Code Online (Sandbox Code Playgroud)
我的脚本使用这些行来创建秘密:
secret_name = 'my_secret'
secret_description = 'describing the secret'
kms_key_id = create_kms_key()
key_info = str([{"Access Key":access_key},{"Secret Key":secret_key}])
aws_secret = `secrets_client.create_secret(Name=secret_name,Description=secret_description,KmsKeyId=kms_key_id,SecretString=key_info,Tags=[{'Key': 'Name','Value': user_name}])`
Run Code Online (Sandbox Code Playgroud)
如何将访问/秘密密钥转换为秘密管理器足以理解的格式以转换为键/值对?
我需要分几个步骤处理一些数据。
我首先在 AWS 中创建一个托管策略列表,并将该列表放入一个数组中:
readarray -t managed_policies < <(aws iam list-attached-user-policies --user-name tdunphy --output json --profile=company-nonprod | jq -r '.AttachedPolicies[].PolicyArn')
Run Code Online (Sandbox Code Playgroud)
但随后我需要在我的脚本中向该数组添加更多信息。我的问题是,我可以使用 readarray 来做到这一点吗?或者我是否只需要使用以下命令将数据修改到列表中:
managed_policies+=($(aws iam list-attached-group-policies --group-name grp-cloudops --profile=compnay-nonprod | jq -r '.AttachedPolicies[].PolicyArn'))
Run Code Online (Sandbox Code Playgroud)