Tag Archives: Centos

Centos7 view and close firewall

CentOS 7.0 defaults to firewall as a firewall

view firewall status

firewall-cmd --state

Stop is firewall

systemctl stop firewalld.service

firewall is prohibited to turn on

systemctl disable firewalld.service 

turn off from CentOS 6 and CentOS 7 firewall

close selinux
into /etc/selinux/config file

vi /etc/selinux/config

the SELINUX = instead of enforcing the SELINUX = disabled

confers the non-secret login command

ssh-keygen -t rsa 
ssh-copy-id root@master

scp -P 22 /Users/che/Downloads/jdk-8u161-linux-x64.rpm [email protected]:/software/

 安装: yum install -y jdk-8u161-linux-x64.rpm
 设置环境变量
 cd /usr/java/

 /usr/java/jdk1.8.0_161

 vi /etc/profile

 export JAVA_HOME=/usr/java/jdk1.8.0_161
 export PATH=$JAVA_HOME/bin:$PATH

install hadoop
download installation package
hadoop-26.5.tar.gz

cd /usr/
mv /software/hadoop-2.6.5.tar.gz  ./
解压
tar -xzvf ./hadoop-2.6.5.tar.gz

创建目录
   namenode目录:/data/hadoop/namenode
   data目录:    /data/hadoop/data
   tmp目录:     /data/hadoop/tmp
   mkdir -p /data/hadoop/namenode

配制
   core-site.xml
   hdfs-site.xml
   mapred-site.xml.template   mapred-site.xml
   cp mapred-site.xml.template   mapred-site.xml
   yarn-site.xml 

   slaves   (slave1,slave2)
   masters  (master)

   hadoop-env.sh
   export JAVA_HOME=/usr/java/jdk1.8.0_161

   将master的配制copy到slave1、slave2
   scp -r ./* root@slave1:/software/hadoop-2.6.5/etc/hadoop/

 格式化
   cd hadoop-2.6.5/bin
   ./hdfs namenode -format

 启动
   cd ../sbin/

   ./start-dfs.sh

   ssh-copy-id root@master 

   jps(检查一下)

   ./start-yarn.sh

   cd ../bin

   hadoop fs -ls /
   hadoop fs -mkdir /user

   /software/hadoop-2.6.5/bin

   vi/etc/profile

   export HADOOP_HOME=/software/hadoop-2.6.5
   export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$PATH

   source /etc/profile

   hadoop fs -put /software/hadoop-2.6.5.tar.gz /user

   测试2:
   cd share/hadoop/mapreduce
   hadoop jar ./hadoop-mapreduce-examples-2.6.5.jar pi 5 10

   192.168.1.100:50070
   192.168.1.100:8088

   修改ssh端口
   vim /etc/ssh/sshd_config  

set NTP time synchronization service
, install NTP
yum install -y NTP
2, set NTP service startup
chkconfig NTPD on
service NPTD start

Centos7 forgot the root password and could not log in to the system

1. First, start the system, enter the power-on interface, and press “e” in the interface to enter the editing interface. As shown in figure:

2. Next, go to the edit screen and use the up and down keys on the keyboard to move the cursor down to the number of lines starting with “Linux16”. At the end of the line, type init=/bin/sh. As shown in figure:

3. Then, after typing, press the shortcut key: Ctrl+x to enter the single-user mode.

4. Next, in the position where the cursor is flashing (the position of the last line), type: mount -o remount,rw/(note: there is a space between mount and -o and a space between rw and /, cannot be omitted), and press Enter on the keyboard when finished. As shown in figure:

5. Then, in the pop-up is to change the password in the content of operation, in the position of the cursor blink Enter a new password (password when the input is not show, just like have no reaction, only need to remember your input password is correct, the password must be no less than 8 bits, otherwise it will fail to modify), after the completion of the press of the keyboard Enter key (Enter). As shown in figure:

solves this problem by linking

6. Then, after the password change is successful, passwd… , indicating that the password was changed successfully.

Next, in the position where the mouse is blinking (in the last line) type: touch /. Autorelabel (note: touch and/followed by a space). When finished, press the Enter key on the keyboard

8. Password changed successfully, you can log in

successfully

U disk installation Linux system could not boot, / dev / root does not exist and the identified hard disk space is not available

UltraISO made U disk start disk

first use centos7, not successful, changed centos8 or not successful, then start to find the cause of the problem

1. Pay attention to the “easy start – write to new drive boot sector -Syslinux”

before writing

2, could not boot, /dev/root does not exist
because the configuration path in the installation boot is wrong,

solution 1,
in the option to install the page, press TAB, “hd:LABEL= XXXXX” in the XXXXX into their own usb disk name

solution two,
in emergency mode, CD /dev into the directory, ls to see all, the hard disk name is generally sda, SDB, SDC so, my computer has two hard disks, u disk should be SDC, then SDC, sdc4, restart back to the installation page to “hd:LABEL= XXXXX” to hd:/dev/sdc4 is ok, if not successful, just try a few sd

3 to enter after installation, hard disk space is not available,
1 t my hard drive, display 1000 k is available, the other is unavailable, this is because the computer before you install a Windows system, hard disk has been allocated a
select the hard disk, check the automatic partition,
and check the order I like to make additional space available click done
the pop-up dialog box select delete all can recycling all space

CentOS solves the problem of modulenotfounderror when salt calls python3 script remotely, and solves the problem that PIP3 module cannot be shared by different users

to describe the scenario, a function on the company’s Jboss server needs to call a python script on a centos7.3 machine with salt mode. Python version is 3.7, and the script will call back an HTTP interface to feedback the execution result. In the test environment, I had Linux machine root privileges, installed Python and dependent modules, and tested that the local execution of the PY script was normal and the JBoss Salt calls were normal. After publishing production, it was found that there were no callbacks after the call was issued, and the problem was located.

production environment configuration, the python script has been manually executed, confirm that the script can execute properly. First confirm that the command was actually sent to the Linux server. Listen to the /var/log/messages log and see the failed salt call:

there is an error reason: salt-minion: ModuleNotFoundError: No module named ‘openpyxl’, which is very strange. It is executed directly on the machine, and all the dependencies are there. Why does salt call fail?Therefore, I started to search various baidu sites, and found that there were a lot of materials in this field but not many directly related ones. Either it was a method to solve the installation of Python modules, or the salt-related package missing problem occurred when salt stack called Python, which could not solve my problem.

after communication with colleagues, colleagues suspected that it was caused by different paths of PIP installation modules for different users on the Linux machine. I had no root rights in the production environment, which was the most significant difference from the test environment. Based on this idea, I first inquired the path of the module installed in pip3:

modules were stored in the private path of the current user. Meanwhile, when I wanted sudo to execute the pip3 installation, I found that the system prompt command did not exist and the same error message appeared when I executed the python script as in the messages log:

$ sudo -H python3 static_analyzer.py

File "static_analyzer.py", line 7, i <module>
import openpyxl
ModuleNotFoundError: no module named 'openpyxl'


$ sudo -H pip3 install openpyxl -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --user

sudo:pip3: command not found

is a good idea, so I looked for ways to share the PIP installation module by user, or at least make it Shared by root. According to the command that this does not exist, one of the blog posts suggests a simple solution, which is to hang the soft connection directly so that root users can find python3 and pip3:

#如下软连接是为了使命令在root用户下 也能正常使用
sudo ln -snf /usr/local/python3/bin/python3  /usr/bin/python3

sudo ln -snf /usr/local/python3/bin/pip3  /usr/bin/pip3

Sure enough, after a soft connection, sudo mode can use python3 and pip3 normally:

sudo -H pip3 install openpyxl -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --user

With this in mind, let’s run the python script in sudo mode to verify that the current environment root user can execute properly:

sudo -H python3 python_script.py

is completely normal. Without the above soft connection, a ModuleNotFoundError in the Messages log would have appeared in the same command, and so far we have solved the problem that the root user of the PIP3 installed module cannot find.

at the end of the last, through the jboss production environment service page to submit the request, the whole process smoothly completed, perfect!

reference:

view the path to installing a python module using PIP install under Linux

solve pip3 command to install the installation package in the home. Local/lib/python3.5/dist – the problem of packages directory

python3: command not found

sudo used with python